;;; -*- coding: utf-8-unix -*- ;;;+----------------------------------------------------------+ ;;;| | ;;;| Seki's dotemacs | ;;;| | ;;;+----------------------------------------------------------+ ;;; Time-stamp: <09/05/2023 11:44 seb@macseb.seki.fr> ;; ;; This .emacs is the result of a never finished tuning process of ;; tailoring the one-editor to my needs and habits, in addition to the ;; utilisation of Emacs on a various list of systems each having ;; its own features and limitiations. ;; ;; It includes the reusing of the configuration files found in the ;; web, the compilation of some code snippets, and also interactions ;; with other users via the newsgroups or IRC. ;; ;; Thanks to : ;; - fr.comp.applications.emacs ;; - gnu.emacs.help ;; - Sébastien Dinot ;; - Mathieu Roy ;; - Matthieu Moy ;; - Florent Georges (aka drkm on fca.emacs and also for his drkm-lib ;; http://drkm-lib.sourceforge.net/) ;; - Emacs Wiki : ;; - DotEmacs : ;; ;; Look here to access the dedicated mailing-lists and their archives : ;; ;;;============================================================ ;;; Définition de l'environnement ;; Déterminer si on emploie Emacs ou XEmacs (defvar sk:is-xemacs (string-match "XEmacs" emacs-version) "Variable interne différente de nil si on est dans XEmacs") ;;chez moi (defvar sk:home (expand-file-name "~") "Home sweet home") ;;(if sk:is-xemacs ;; (setq sk:home (expand-file-name sk:home))) ;; Ajouter mon répertoire personnel à la liste des chemins de recherche ;(defvar sk:elisp-path (concat sk:home "/.elisp") "Chemin vers mes packages elisp") (defvar sk:elisp-path "~/.elisp" "Chemin vers mes packages elisp") ;(if sk:is-xemacs ; (setq sk:elisp-path (expand-file-name sk:elisp-path))) ;(message (format "%s" load-path)) (add-to-list 'load-path sk:elisp-path) (progn (cd sk:elisp-path) (normal-top-level-add-subdirs-to-load-path) (cd sk:home)) ;(message (format "%s" load-path)) ;; chemin d'un Gnus custom (si présent) (let ((gnusp (concat sk:elisp-path "/gnus"))) (when (file-exists-p gnusp) (add-to-list 'load-path gnusp))) ;; localisation des fichiers gnus (ne peut pas être dans .gnus !) (setq gnus-home-directory (concat sk:home "/.gnus.d")) (setq message-directory (concat gnus-home-directory "/Mail")) (setq gnus-directory (concat gnus-home-directory "/News")) (setq gnus-agent-directory (concat gnus-home-directory "/agent")) ;; Gnus est notre courielleur (setq read-mail-command 'gnus) ;marche pas terrible ? (setq mail-user-agent 'gnus-user-agent ;smtpmail-default-smtp-server "lumiere.ens.fr" ;smtpmail-smtp-server "lumiere.ens.fr" ;message-mail-user-agent 'gnus-user-agent ) ;; on a un environnement français (set-language-environment 'French) ;met à dispo latin-1 et latin-9 (prefer-coding-system 'utf-8) ;mais on préfère utf-8 (set-locale-environment "fr_FR.UTF-8") ;pour utiliser les locales françaises (utile sous OSX car LC_xx n'est pas défini) (add-hook 'dired-mode-hook ;ceci corrige les problèmes de locales avec xx.UTF-8 (lambda () (make-local-variable 'coding-system-for-read) (setq coding-system-for-read 'utf-8))) ;; pour pas se prendre les pieds dans le tapis entre latin-1 et latin-9 ;; Emacs considère séparément les caractères identiques entre latin-1 et latin-9 (when (< emacs-major-version 23) ;;(require 'ucs-tables) (unify-8859-on-encoding-mode t) ; les caractères encodables en latin-9 le seront directement (unify-8859-on-decoding-mode t) ; au décodage, les caractères latins représentables en latin-1 ; sont remappés, les autres passent en mule-unicode-0100-24ff ; ça permet par exemple de comparer «é» latin-1 identique à «é» latin-9 ) ;;;======= SPECIFIQUE PLATEFORME ========================================================== (cond ((eq system-type 'darwin) ; réglages pour le mac (message "on est sous mac") (setq process-connection-type t) ;en shell pour voir l'affichage ;;(setq mac-command-key-is-meta t);pomme = meta (removed from emacs22 cvs) (setq mac-option-modifier 'none);control, meta, alt, super, or hyper (none = no interpretation) (setq mac-command-modifier 'meta) ;obsolete ? (setq mac-pass-command-to-system nil) ;évite de cacher emacs avec M-h ;; iso-latin-1 input encoding ? ;;(setq mac-keyboard-text-encoding kTextEncodingISOLatin1) ;;(set-keyboard-coding-system 'iso-latin-1) ;; To modify mac/unix/dos encodings: CTRL-X RET f ;(set-terminal-coding-system 'latin-9) ;;(set-keyboard-coding-system 'mac-roman) ;dejà positionné ? ;;(set-frame-font "fontset-mac") ;;(setq default-buffer-file-coding-system 'iso-latin-9-mac) ;attention prefer-coding-system + bas ;(setq mac-wheel-button-is-mouse-2 t) ;??? ;(setq mac-emulate-three-button-mouse 1) ; option = mouse2 / command = mouse3 (if window-system (progn (set-background-color "gray90") ;;X fonts specs format (désignation des fontes X) ;;-FOUNDRY-FAMILY-WEIGHT-SLANT-WIDTH--PIXELS-POINTS-HRES-VRES-SPACING-AVEWIDTH-CHARSET ;; Set frame size, color and fonts ;; (create-fontset-from-fontset-spec ;; "-apple-monaco-medium-r-normal--9-*-*-*-*-*-fontset-monaco, ;; ascii:-apple-monaco-medium-r-normal--9-90-75-75-m-90-mac-roman, ;; mule-unicode-0100-24ff:-apple-lucida grande-medium-r-normal--0-0-75-75-m-0-mac-roman, ;; mule-unicode-2500-33ff:-apple-bitstream vera sans mono bold-medium-r-normal--0-0-75-75-m-0-mac-roman, ;; latin-iso8859-15:-apple-monaco-medium-r-normal--9-90-75-75-m-90-mac-roman, ;; latin-iso8859-1:-apple-monaco-medium-r-normal--9-90-75-75-m-90-mac-roman") ;;-- ;;-apple-unifont medium-medium-r-normal--0-0-75-75-m-0-mac-roman ;; (create-fontset-from-fontset-spec ;; "-apple-unifont medium-medium-r-normal--0-0-75-75-m-0-fontset-monaco, ;; ascii:-apple-unifont medium-medium-r-normal--0-0-75-75-m-0-mac-roman, ;; mule-unicode-0100-24ff:-apple-unifont medium-medium-r-normal--0-0-75-75-m-0-mac-roman, ;; mule-unicode-2500-33ff:-apple-unifont medium-medium-r-normal--0-0-75-75-m-0-mac-roman, ;; latin-iso8859-15:-apple-unifont medium-medium-r-normal--0-0-75-75-m-0-mac-roman, ;; latin-iso8859-1:-apple-unifont medium-medium-r-normal--0-0-75-75-m-0-mac-roman") (create-fontset-from-fontset-spec "-misc-seki-medium-r-*-12-*-*-*-*-*-*-fontset-custom_seki") (set-fontset-font "fontset-custom_seki" 'latin-iso8859-1 '("Monaco" . "iso8859-1")) ;;(set-fontset-font "fontset-custom_seki" 'latin-iso8859-1 '("American Typewriter" . "iso8859-1")) (set-fontset-font "fontset-custom_seki" 'latin-iso8859-15 '("Monaco" . "iso8859-15")) ;;(set-fontset-font "fontset-custom_seki" 'latin-iso8859-15 '("American Typewriter" . "iso8859-15")) (set-fontset-font "fontset-custom_seki" '(#x2200 . #x2200) '("Monaco" . "iso8859-15")) ;;(set-fontset-font "fontset-custom_seki" '(#x2200 . #x2200) (font-spec :family "Arial Unicode MS" :size 24 :slant 'italic)) ;(set-face-font 'default "-misc-seki-medium-r-*-*-*-*-*-*-*-*-fontset-custom_seki" nil) ;;non working with Emacs26? ;;(set-frame-font "-misc-seki-medium-r-*-12-*-*-*-*-*-*-fontset-custom_seki") ;;replaced by (set-frame-font "-*-Consolas-normal-normal-normal-*-13-*-*-*-m-0-iso10646-1") (create-fontset-from-fontset-spec "-apple-monaco-medium-r-normal--12-*-*-*-*-*-fontset-monaco") ;(set-fontset-font "" 'latin-iso8859-1 '("American Typewriter" . "iso8859-1")) ;(set-fontset-font "fontset-custom_seki" 'latin-iso8859-15 '("American Typewriter" . "iso8859-15")) ;(set-fontset-font "fontset-custom_seki" '(#x2200 . #x2200) (font-spec :family "Arial Unicode MS" :size 24)) ;(set-face-font 'default "-misc-seki-medium-r-*-*-*-*-*-*-*-*-fontset-custom_seki" nil) (setq default-frame-alist '((width . 120) (height . 44) (top . 76) ;pixels (left . 260) ;pixels ;(font . "-misc-seki-medium-r-*-12-*-*-*-*-*-*-fontset-custom_seki") ; not working with Emacs26...? (font "-*-Consolas-normal-normal-normal-*-13-*-*-*-m-0-iso10646-1") (font . "fontset-monaco");fontset-mac ;; preferences ;(font . (create-fontset-from-mac-roman-font "-apple-monaco-medium-r-normal--9-90-75-75-m-90-mac-roman")) ;(font . (create-fontset-from-mac-roman-font "unifont medium")) (cursor-type . bar) (cursor-color . "purple") (background-color . "gray90") )) ;;(setq default-frame-alist initial-frame-alist) ) ) (global-set-key (kbd "") 'delete-char) ;touche suppr (global-set-key (kbd "") "/") ;touche division sur pavé num (inactif sur mon poste ?) (global-set-key (kbd "") (kbd "")) ;idem / (global-set-key (kbd "") (kbd "")) ;idem / ;;Aargh, change default Mac behavior for home / end keys (global-set-key (kbd "") 'beginning-of-line) (global-set-key (kbd "") 'end-of-line) ;;(global-set-key "?" (sk-insere-euro t));j'arrive pas avec l'euro ;( €€ et si ! ;;impressions (setq printer-name "IMP_DEV_PROJ") ;;pour imprimer les caractères latin-9 (setq ps-mule-font-info-database-default '((latin-iso8859-15 (normal nil nil iso-latin-9)) (latin-iso8859-1 (normal nil nil iso-latin-1)))) ) ;;================================================================= ((eq system-type 'windows-nt) ; réglages pour windows (progn (message "on est sous ouin-ouin") (global-set-key [128] 'sk-insere-euro) ; C-h l donne \200 pour l'euro soit 128 en décimal ;;weird bug of M-x not functionning when other M- combo work (when (string-match "^PC-SEBASTIEN" system-name) (setq w32-alt-is-meta nil) (setq w32-lwindow-modifier 'meta)) ;; Mouse wheel (defun up-slightly () (interactive) (scroll-up 5)) (defun down-slightly () (interactive) (scroll-down 5)) (global-set-key [mouse-4] 'down-slightly) (global-set-key [mouse-5] 'up-slightly) (defun up-one () (interactive) (scroll-up 1)) (defun down-one () (interactive) (scroll-down 1)) (global-set-key [S-mouse-4] 'down-one) (global-set-key [S-mouse-5] 'up-one) (defun up-a-lot () (interactive) (scroll-up)) (defun down-a-lot () (interactive) (scroll-down)) (global-set-key [C-mouse-4] 'down-a-lot) (global-set-key [C-mouse-5] 'up-a-lot) ;; Mouse wheel (if window-system (progn (set-background-color "gray90") ;;(set-cursor-color "#aa88dd") (set-cursor-color "#ff00aa") ;;-outline-Lucida Console-normal-r-normal-normal-11-82-96-96-c-70-iso8859-1 ;; Set frame size, color and fonts (create-fontset-from-fontset-spec "-*-lucida console-*-*-*-*-10-*-*-*-*-*-fontset-lucida, ascii:-*-lucida console-*-*-*-*-10-*-*-*-*-*-iso8859-1, latin-iso8859-1:-*-lucida console-*-*-*-*-10-*-*-*-*-*-iso8859-1") (create-fontset-from-fontset-spec "-*-consolas-*-*-*-*-12-*-*-*-*-*-fontset-consolas, ascii:-*-consolas-*-*-*-*-12-*-*-*-*-*-iso8859-1, latin-iso8859-1:-*-consolas-*-*-*-*-12-*-*-*-*-*-iso8859-1, latin-iso8859-15:-*-consolas-*-*-*-*-12-*-*-*-*-*-iso8859-15, uniscribe:-*-Arial Unicode MS-*-*-*-*-12-*-*-*-*-*-iso8859-15") ;; (create-fontset-from-fontset-spec ;; "-apple-monaco-medium-r-normal--9-*-*-*-*-*-fontset-monaco, ;; ascii:-apple-monaco-medium-r-normal--9-90-75-75-m-90-mac-roman, ;; latin-iso8859-1:-apple-monaco-medium-r-normal--9-90-75-75-m-90-mac-roman") (setq default-frame-alist '((width . 100) (height . 44) (top . 50) ;pixels (left . 50) ;pixels (font . "fontset-consolas") ;fontset-mac (cursor-type . bar) (cursor-color . "purple") (background-color . "grey90") )) ;;(setq default-frame-alist initial-frame-alist) ) ) ) ) ;;================================================================= ((eq system-type 'gnu/linux) ; réglages pour Linux (progn (message "on est avec le pingouin") () ;rien d'autre ;; Mouse wheel ;; remplacé par mwheel (mouse-wheel-mode est t par défaut) ;; (defun up-slightly () (interactive) (scroll-up 5)) ;; (defun down-slightly () (interactive) (scroll-down 5)) ;; (global-set-key [mouse-4] 'down-slightly) ;; (global-set-key [mouse-5] 'up-slightly) ;; (defun up-one () (interactive) (scroll-up 1)) ;; (defun down-one () (interactive) (scroll-down 1)) ;; (global-set-key [S-mouse-4] 'down-one) ;; (global-set-key [S-mouse-5] 'up-one) ;; (defun up-a-lot () (interactive) (scroll-up)) ;; (defun down-a-lot () (interactive) (scroll-down)) ;; (global-set-key [C-mouse-4] 'down-a-lot) ;; (global-set-key [C-mouse-5] 'up-a-lot) ;; Mouse wheel (if window-system (progn (set-background-color "gray90") (create-fontset-from-fontset-spec "-gnu-unifont-*-*-*-*-16-*-*-*-*-*-fontset-unifont, ascii:-gnu-unifont-medium-r-normal--16-160-75-75-c-80-iso10646-1, latin-iso8859-1:-gnu-unifont-medium-r-normal--16-160-75-75-c-80-iso10646-1") ;; ascii:-gnu-unifont-*-*-*-*-*-120-*-*-*-*-iso10646-1, ;; latin-iso8859-1:-gnu-unifont-*-*-*-*-*-120-*-*-*-*-iso10646-1") ;; -PfEd-Menlo-normal-normal-normal-*-11-*-*-*-m-0-fontset-auto4 (create-fontset-from-fontset-spec "-Misc-Fixed-Medium-R-SemiCondensed--12-*-*-*-*-*-fontset-obelix, latin-iso8859-1:-Misc-Fixed-Medium-R-SemiCondensed--12-110-75-75-C-60-ISO8859-1, latin-iso8859-15:-Misc-Fixed-Medium-R-SemiCondensed--12-110-75-75-C-60-ISO8859-15, mule-unicode-2500-33ff:-Misc-Fixed-Medium-R-SemiCondensed--12-110-75-75-C-60-ISO10646-1, unicode-bmp:-Misc-Fixed-Medium-R-SemiCondensed--12-110-75-75-C-60-ISO10646-1, chinese-gb2312:-Misc-Fixed-Medium-R-SemiCondensed--12-110-75-75-C-60-ISO10646-1, chinese-gbk:-Misc-Fixed-Medium-R-SemiCondensed--12-110-75-75-C-60-ISO10646-1") (setq initial-frame-alist '((width . 110) (height . 45) (top . 80);pixels (left . 180);pixels ;;(font . "fontset-unifont") ;;(font . "6x12") (font . "fontset-obelix") (cursor-type . bar) (background-color . "grey90") )) (setq default-frame-alist initial-frame-alist) ;;(setq browse-url-browser-function (quote browse-url-galeon) ;; browse-url-galeon-arguments (quote ("-n"))) (defun browse-url-firefox-new-tab (url &optional new-window) "Open URL in a new tab in Firefox." (interactive (browse-url-interactive-arg "URL: ")) (let ((cmd (shell-command-to-string (concat "mozilla-firefox -a firefox -remote 'openURL(" url ",new-tab)' > /dev/null")))) (unless (string= "" cmd) (message "Starting Firefox...") (start-process (concat "firefox " url) nil "/bin/sh" "-c" (concat "mozilla-firefox " url "|| true")) (message "Starting Firefox...done")))) (setq browse-url-browser-function 'browse-url-firefox-new-tab) (set-face-attribute 'region nil :background "#ada0d0");can also provide :foreground "#ffffff" ) ) ;;(setq printer-name "Idefix") ;; (setq printer-name "Obelix") ;;(setq ps-printer-name "Obelix") ;; (setq printer-name "Lexmark-T654") (setq printer-name "Canon2") ) ) ;;================================================================= (t (message "Plateforme non identifiée")) ) ;;;========== ERGONOMIE ========================= ;; Inhiber l'affichage du message d'accueil (setq inhibit-startup-message t ;Emacs gnus-inhibit-startup-message t) ;Gnus ;; C'est fastidieux de taper « yes » pour confirmer, raccourcissons ;; cela à « y » (idem pour « no », désormais « n »). (fset 'yes-or-no-p 'y-or-n-p) ;; beep visuel (setq visible-bell t) ;; curseur en barre et non clignotant ;;(setq cursor-type 'bar) -> default-frame-alist (blink-cursor-mode 0) ;;(set-cursor-color "black") ;; Ne pas utiliser de boîte de dialogue mais le minibuffer pour poser une question ;; (les dialogues marchent mal sous OSX pour choisir un fichier inexistant) (setq use-dialog-box nil use-file-dialog nil) ;; Supprimer les fichiers de sauvegarde en quittant. ;; (vous savez, ces fameux fichiers dont le nom se termine par « ~ ») (setq make-backup-files nil) ;; Gestion et affichage corrects des accents. ;;(require 'iso-acc) à éviter d'après f.c.a.emacs ;; Aide interne de la fonction ci-dessous ;; Non-nil means display unibyte text according to language environment. ;; Specifically this means that unibyte non-ASCII characters ;; are displayed by converting them to the equivalent multibyte characters ;; according to the current language environment. As a result, they are ;; displayed according to the current fontset. ;(setq unibyte-display-via-language-environment t) ;; Afficher les caractères de contrôle sous la forme d'un caractère ;; « ^ » suivi de la lettre correspondante au lieu de la forme octale. (setq-default ctl-arrow 'latin-9) ;;ne pas afficher les espaces insécables précédés d'un "\" ;;nouveauté emacs 21.3.50 (cvs) (setq show-nonbreak-escape nil) ;; Laisser le curseur en place lors d'un défilement par pages. ;; Par défaut, Emacs place le curseur en début ou fin d'écran ;; selon le sens du défilement. (setq scroll-preserve-screen-position t) ;; Faire apparaître la position du curseur dans la ligne modale (setq column-number-mode t) (setq line-number-mode t) ;; Montrer la taille totale dans la ligne modale (setq size-indication-mode t) ;; mise à jour auto des time-stamps (add-hook 'before-save-hook 'time-stamp);;était write-file-hooks ;; se rappeler de la position dans le fichier entre les sessions (when (require 'saveplace) (setq-default save-place t)) ;; Pour l'impression, du papier au format A4 est utilisé (setq ps-paper-type 'a4) ;; Si cette variable est différente de 'nil', lorsque l'on est à la fin ;; d'une ligne, le déplacement vertical du curseur s'accompagne d'un ;; déplacement horizontal pour atteindre la fin de la ligne courante. ;; Si cette variable vaut 'nil', le déplacement est strictement vertical. ;;(setq track-eol nil) ;; La fin d'une phrase n'est pas marquée par un point suivi de deux espaces, ;; un seul suffit. (setq sentence-end-double-space nil) ;; s'assurer que les fichiers comportent des newline finaux ;; nil n'ajoute pas de newline ;; non-nil pose la question ;; t rajoute les newlines automatiquement (setq require-final-newline 1 mode-require-final-newline 1) ;; Stolen from sensible-defaults: ;; When saving a file in a directory that doesn't exist, offer to (recursively) create ;; the file's parent directories. (add-hook 'before-save-hook (lambda () (when buffer-file-name (let ((dir (file-name-directory buffer-file-name))) (when (and (not (file-exists-p dir)) (y-or-n-p (format "Directory %s does not exist. Create it?" dir))) (make-directory dir t)))))) ;; Nouveauté 22.00 : mouse-1 sur un lien suit ce lien ;; je préfère l'ancien comportement ;; (setq mouse-1-click-follows-link nil) ;; en fait il suffit de cliquer plus longtemps que la valeur de cette ;; variable (par défaut 350 ms) ;; En rendant nulle la variable ci-dessous, l'insertion d'un texte par ;; « copier-coller » à la souris se fait au niveau du point cliqué et ;; non à la position du curseur texte. (setq mouse-yank-at-point nil) ;; Mise en surbrillance des lignes sélectionnées et écrasement de ces ;; dernières lorsqu'on saisit du texte dans la foulée. ;; (if sk:is-xemacs ;; ; on utilise XEmacs ;; (progn ;; (require 'pending-del) ;; (custom-set-variables '(pending-delete-mode t t))) ;; ;; on utilise Emacs ;; ;; Avec emacs 21, la surbrillance est disponible en mode console. Cool ! ;; (progn ;; (delete-selection-mode t) ;; (transient-mark-mode t)) ;; ) ;; Si cette variable est différente de 'nil', lorsque l'on est à la fin ;; d'une ligne, le déplacement vertical du curseur s'accompagne d'un ;; déplacement horizontal pour atteindre la fin de la ligne courante. ;; Si cette variable vaut 'nil', le déplacement est strictement vertical. (setq track-eol 'nil) ;; montre les lignes inutilisées et les limites d'un buffer (setq-default indicate-empty-lines t) ;;indicate-buffer-boundaries 'right) ;; saisie universelle des caractères accentués par c-' c-` c-" + lettre ;; pratique pour les majuscules ;;(define-key key-translation-map [(control ?^)] 'iso-transl-ctl-8-x-map) (define-key key-translation-map [(control ?')] (lookup-key key-translation-map [(control ?x) ?8 ?'])) (define-key key-translation-map [(control ?`)] (lookup-key key-translation-map [(control ?x) ?8 ?`])) (define-key key-translation-map [(control ?")] (lookup-key key-translation-map [(control ?x) ?8 ?"])) (global-set-key [(control ?6)] (lookup-key key-translation-map [(control ?x) ?8 ?^])) (if (eq system-type 'gnu/linux) (define-key key-translation-map [(control 2226)] (lookup-key key-translation-map [(control ?x) ?8])) (define-key key-translation-map [(control 178)] (lookup-key key-translation-map [(control ?x) ?8])) ) ;; Completion automatique via Shift-Tab (EmacsFR) ;; (global-set-key (quote [S-iso-lefttab]) 'dabbrev-expand) ;; (global-set-key (quote [S-tab]) 'dabbrev-expand) (global-set-key (quote [S-iso-lefttab]) 'hippie-expand) (global-set-key (quote [S-tab]) 'hippie-expand) ;; Changement de fenetre moins fatigant que Ctrl-x o (EmacsFR) (global-set-key [(control tab)] `other-window) ;(global-set-key [C-S-iso-lefttab] '(lambda () (interactive) (other-window -1))) ;; Changement de frame avec C-S-Tab en plus de C-x 5 o (global-set-key [(control meta tab)] `other-frame) ;(global-set-key [C-M-S-iso-lefttab] '(lambda () (interactive) (other-frame -1))) ;; Changement de buffer C-x b amélioré ;(iswitchb-mode) (when (require 'ido nil t) (ido-mode t) (setq ido-enable-regexp t) ) ;; goto-line n'est mappé par défaut que dans le menu (global-set-key "\C-cg" 'goto-line) ;; Suivi des fichiers récents (when (require 'recentf) (setq recentf-auto-cleanup 'never) ;; évite de vérifier les fichiers distants au démarrage (recentf-mode 1)) ;; parcours du kill-ring pour insertion ;; module de Matthieu Moy http://www-verimag.imag.fr/~moy/emacs/kill-ring-rotate.el (require 'kill-ring-rotate nil t) ;; par défaut, ediff ignore les blancs (setq-default ediff-ignore-similar-regions t ediff-custom-diff-options "-u" ;; -c = context -u = unified format ediff-backup-specs "-z .orig -b" ) (add-hook 'ediff-cleanup-hook (lambda () (ediff-janitor nil nil))) ;; nettoyage des buffers ediff ;;"il manque un newline à la fin du fichier" n'est pas vraiment une erreur ;; --> ajout du Français et de l'Allemand à la regex magique ;; see http://stackoverflow.com/a/9246184/317266 (setq ediff-diff-ok-lines-regexp (concat "^\\(" "[0-9,]+[acd][0-9,]+\C-m?$" "\\|[<>] " "\\|---" "\\|.*Warning *:" "\\|.*No +newline" "\\|.*missing +newline" "\\|.*Pas +de +fin +de +ligne" "\\|.*Kein +Zeilenumbruch +am +Dateiende" "\\|^\C-m?$" "\\)")) ;; Colorisation syntaxique maximale dans tous les modes ;; Avec emacs 21, la colorisation est disponible en mode texte. Cool ! (global-font-lock-mode t) (setq font-lock-maximum-decoration t) ;; Montrer la correspondance des parenthèses ;; (systématiquement et non seulement après la frappe) (when (require 'paren) (show-paren-mode t) (setq blink-matching-paren t) (setq blink-matching-paren-on-screen t) (setq show-paren-style 'parenthesis) ;;(setq show-paren-style 'expression) (setq blink-matching-paren-dont-ignore-comments t)) ;; (dé)compression automatique des fichiers lus et écrits (auto-compression-mode t); nil (jka-compr)) ;; pas de toolbar (tool-bar-mode -1) ;; rechercher et matcher sans casse :) (setq case-fold-search t) ;; une tabulation = 4 espaces (setq-default tab-width 4); set tab width to 4 for all buffers (setq-default indent-tabs-mode nil) ; always replace tabs with spaces (defvaralias 'c-basic-offset 'tab-width) (defvaralias 'cperl-indent-level 'tab-width) ;; ,----[ boxquote ] ;; | insertion de texte en boîte ;; | comme ceci ;; `---- (require 'boxquote nil t) ;; choix de la base décimale pour la saisie de caractères quotés (C-q n°) ;;(setq read-quoted-char-radix 10) ;; choix de la base hexadécimale pour la saisie de caractères unicode quotés (C-q n°) (setq read-quoted-char-radix 16) ;; complétion intelligente (defconst dabbrev-always-check-other-buffers t) ;; ??? (defconst dabbrev-abbrev-char-regexp "\\sw\\|\\s_") (setq hippie-expand-try-functions-list '(try-expand-dabbrev try-expand-dabbrev-all-buffers try-expand-dabbrev-from-kill try-complete-file-name-partially try-complete-file-name try-complete-lisp-symbol-partially try-complete-lisp-symbol try-expand-whole-kill)) ;; Amélioration de home / end ;; trouvé sur : http://www.dotemacs.de/dotfiles/DavidJolley.emacs.html ;; Redefine the Home/End keys to (nearly) the same as visual studio behaviour... ;; special home and end by Shan-leung Maverick WOO (global-set-key [home] 'My-smart-home) (global-set-key [end] 'My-smart-end) (defun My-smart-home () "Odd home to beginning of line, even home to beginning of text/code." (interactive) (if (and (eq last-command 'My-smart-home) (/= (line-beginning-position) (point))) (beginning-of-line) (beginning-of-line-text)) ) (defun My-smart-end () "Odd end to end of line, even end to begin of text/code." (interactive) (if (and (eq last-command 'My-smart-end) (= (line-end-position) (point))) (end-of-line-text) (end-of-line)) ) (defun end-of-line-text () "Move to end of current line and skip comments and trailing space. Require `font-lock'." (interactive) (end-of-line) (let ((bol (line-beginning-position))) (unless (eq font-lock-comment-face (get-text-property bol 'face)) (while (and (/= bol (point)) (eq font-lock-comment-face (get-text-property (point) 'face))) (backward-char 1)) (unless (= (point) bol) (forward-char 1) (skip-chars-backward " \t\n")))) ) ;; interface impression ;(when (require 'printing nil t) ; ;;(pr-menu-bind) ; ) ;;bizarre : ce n'est plus automatique ? ;limite l'affichage de la charge système au dessus d'un certain seuil (setq display-time-load-average-threshold 1.0) ;; ========= Serveur ======================================== ;;démarrage du serveur pour que emacsclient fonctionne (server-start) ;;démarrage de gnuserver ;(gnuserv-start) ;;comportement avec les buffers du serveur : les fermer après usage ;;(setq server-kill-new-buffers t) ;defaut ;;hooks pour les server buffers : ;; - ouvrir dans une nouvelle frame ;; - et la fermer après usage (add-hook 'server-switch-hook (lambda () (let ((server-buf (current-buffer))) (bury-buffer) (switch-to-buffer-other-frame server-buf)))) (add-hook 'server-done-hook (lambda () (delete-frame))) ;;extension chrome "Edit with Emacs" (when (require 'edit-server nil 't) (setq edit-server-new-frame t) (edit-server-start)) ;; (when (and (require 'edit-server nil t) (daemonp)) ;; (edit-server-start)) ;;;============== DATE et HEURE ===================================== ;; La semaine commence le lundi (setq calendar-week-start-day 1) ;; Afficher l'heure dans la barre d'état (format 24 heures) (setq display-time-24hr-format t) (display-time) ;; Nom en clair des jours et mois apparaissant dans le calendrier (defvar calendar-day-abbrev-array ["dim" "lun" "mar" "mer" "jeu" "ven" "sam"]) (defvar calendar-day-name-array ["dimanche" "lundi" "mardi" "mercredi" "jeudi" "vendredi" "samedi"]) (defvar calendar-month-abbrev-array ["jan" "fév" "mar" "avr" "mai" "jun" "jul" "aoû" "sep" "oct" "nov" "déc"]) (defvar calendar-month-name-array ["janvier" "février" "mars" "avril" "mai" "juin" "juillet" "août" "septembre" "octobre" "novembre" "décembre"]) ;;format de date français (setq calendar-date-display-form '(dayname " " day " " monthname " " year)) ;;localisation de Metz (setq calendar-location-name "Metz, FR" calendar-latitude [49 07 north] calendar-longitude [6 10 east]) ;; vacances (setq mark-holidays-in-calendar t general-holidays nil hebrew-holidays nil islamic-holidays nil bahai-holidays nil oriental-holidays nil) (setq local-holidays '((holiday-fixed 5 1 "Fête du travail") (holiday-fixed 5 8 "Victoire 1945") (holiday-fixed 7 14 "Fête nationale") (holiday-fixed 8 15 "Assomption") (holiday-fixed 11 1 "Toussaint") (holiday-fixed 11 11 "Armistice 1918") (holiday-float 5 0 2 "Fête des mères") (holiday-float 6 0 3 "Fête des pères"))) ;;============== paramétrage BBDB ======================================= (when (require 'bbdb nil t) (progn (bbdb-initialize 'gnus 'message) (setq gnus-optional-headers 'bbdb/gnus-lines-and-from bbdb-complete-name-allow-cycling t bbdb-send-mail-style 'gnus) ;'message) (autoload 'bbdb/gnus-lines-and-from "bbdb-gnus") (autoload 'bbdb "bbdb-com" "Insidious Big Brother Database" t) (autoload 'bbdb-name "bbdb-com" "Insidious Big Brother Database" t) (autoload 'bbdb-company "bbdb-com" "Insidious Big Brother Database" t) (autoload 'bbdb-net "bbdb-com" "Insidious Big Brother Database" t) (autoload 'bbdb-notes "bbdb-com" "Insidious Big Brother Database" t) (autoload 'bbdb-insinuate-vm "bbdb-vm" "Hook BBDB into VM") (autoload 'bbdb-insinuate-rmail "bbdb-rmail" "Hook BBDB into RMAIL") (autoload 'bbdb-insinuate-mh "bbdb-mhe" "Hook BBDB into MH-E") (autoload 'bbdb-insinuate-gnus "bbdb-gnus" "Hook BBDB into GNUS") (autoload 'bbdb-insinuate-sendmail "bbdb" "Hook BBDB into sendmail") (add-hook 'gnus-startup-hook 'bbdb-insinuate-gnus) ;;ajout des contacts à l'envoi (autoload 'bbdb/send-hook "moy-bbdb" "Function to be added to `message-send-hook' to notice records when sending messages" t) (add-hook 'message-send-hook 'bbdb/send-hook) ;; par defaut bbdb est configure pour accepter les numeros de ;; telephone au format americain ici on desactive cette option (setq bbdb-north-american-phone-numbers-p nil) ;; permet d'eviter d'avoir une fenetre bbdb qui montre en permanence ;; les mises a jour dans bbdb lorsque l'on utilise VM, MH, RMAIL ou ;; GNUS (setq bbdb-use-pop-up nil) ;; pas de code de localisation par defaut pour les numeros de ;; telephone (setq bbdb-default-area-code nil) ;; permet d'empecher a bbdb de creer une nouvelle entree a chaque fois ;; qu'un mail d'une nouvelle personne est lu avec GNUS, RMAIL, VM ou ;; MH. (setq bbdb/mail-auto-create-p nil bbdb/news-auto-create-p nil bbdb/send-auto-create-p nil bbdb/send-prompt-for-create-p t ) ;;de moy-bbdb ;; nombre de lignes desire dans la fenetre popup de bbdb lorsque l'on ;; utilise VM/MH/RMAIL ou GNUS. (setq bbdb-pop-up-target-lines 7) ;; ne pas m'enquiquiner si bbdb voit un correspondant connu avec une adresse différente (setq bbdb-always-add-addresses nil bbdb-quiet-about-name-mismatches t) ;; ne pas me demander si je veux sauver la base (setq bbdb-offer-save 'savenoprompt) ;; je veux insérer le nom complet même s'il est identique à l'adresse ;; exemple "John Doe (setq bbdb-dwim-net-address-allow-redundancy t) ) ); modif pour ne pas avoir d'erreur de chargement de bbdb avec eudc-bbdb ;; réglages Emacs Unified Directory Client (require 'eudc nil t) (if (featurep 'bbdb) (require 'eudcb-bbdb nil t)) (require 'eudcb-mab nil t) ; support Macintosh Address Book - nécessite l'outil contacts ; http://www.newartisans.com/johnw/Emacs/eudcb-mab.el ; http://gnufoo.org/contacts/contacts.html (setq eudc-inline-expansion-servers 'hotlist) ;chercher dans l'ordre de la hotlist (add-to-list 'eudc-server-hotlist '("localhost" . bbdb) t) (eudc-protocol-set 'eudc-inline-query-format '((firstname) (lastname) (firstname lastname) (net)) 'bbdb) (eudc-protocol-set 'eudc-inline-expansion-format '("%s %s <%s>" firstname lastname net) 'bbdb) (when (string-match "\\`goudurix" system-name) (add-to-list 'eudc-server-hotlist '("localhost" . mab) t) (add-to-list 'eudc-server-hotlist '("metz-exchange" . ldap) t) (setq ldap-host-parameters-alist '(("metz-exchange" base "o=SAGE" auth nil scope subtree)) eudc-query-form-attributes '(uid name firstname email)) (eudc-protocol-set 'eudc-inline-query-format '((name) (email)) 'mab) (eudc-protocol-set 'eudc-inline-expansion-format '("%s <%s>" name email) 'mab) (eudc-protocol-set 'eudc-inline-query-format '( ;;(cn) ;;(cn cn) ;;(cn cn cn) ;;(sn) ;;(givenname) ;;(surname) ;;(givenname surname) ;;(fullname) (uid) (name) ;;(surname) (mail)) 'ldap) (eudc-protocol-set 'eudc-inline-expansion-format '("%s <%s>" cn mail) 'ldap)) (setq eudc-default-return-attributes nil eudc-strict-return-matches nil) (if (featurep 'bbdb) (eudc-set-server "localhost" 'bbdb t)) ;serveur principal = bbdb if available ;;;========== Spelling ================================================== (when (require 'ispell) (setq ispell-program-name "aspell") (setq ispell-dictionary "fr");"francais") (autoload 'flyspell-mode "flyspell" "On-the-fly spelling." t) ) ;; ;;régler le problème des accents ignorés ;; (setq ispell-dictionary-alist ;; '((nil ; francais.aff ;; "[A-Za-zÀÂÇ-ËÎÏÔÙÛÜàâç-ëîïôùûü]" "[^A-Za-zÀÂÇ-ËÎÏÔÙÛÜàâç-ëîïôùûü]" ;; "[---']" nil ("-n") "~nroff") ;; ("english" ; rosbif ;; "[A-Za-z]" "[^A-Za-z]" "[---']" nil ("-B") nil) ;; ("american" ; yankee ;; "[A-Za-z]" "[^A-Za-z]" "[---']" nil nil nil) ;; ("francais" ; francais.aff ;; "[A-Za-zÀÂÇ-ËÎÏÔÙÛÜàâç-ëîïôùûü]" "[^A-Za-zÀÂÇ-ËÎÏÔÙÛÜàâç-ëîïôùûü]" ;; "[---']" nil ("-n") "~nroff") ;; ("francais-TeX" ; francais.aff ;; "[A-Za-zÀÂÇ-ËÎÏÔÙÛÜàâç-ëîïôùûü\\]" "[^A-Za-zÀÂÇ-ËÎÏÔÙÛÜàâç-ëîïôùûü\\]" ;; "[---'^`\"]" t nil "~tex") ;; ("espanol" ; espa~nol.aff ;; "[A-Za-záéíóúüñÁÉÍÓÚÜÑ]" "[^A-Za-záéíóúüñÁÉÍÓÚÜÑ]" ;; "[---'^`\"]" t nil "~nroff") ;; )) ;;;========== Customize ================================================== ;;transféré dans .emacs-custom ;; customize ne doit pas écrire dans ~/.emacs (defvar sk:custom-directory (concat sk:home "/.emacs.d") "Chemin vers les fichiers de configuration d'Emacs") (setq custom-file (concat sk:custom-directory "/.emacs-custom")) (when (file-exists-p custom-file) (load-file custom-file)) ;;;========== Styles des langages ========================================= (setq c-basic-offset 4 c-offsets-alist (quote ((case-label . +))) c-style-variables-are-local-p nil c-tab-always-indent (quote other)) ;;;=== Styles ECB ======================================== (eval-after-load "ecb" (setq ecb-directories-menu-user-extension-function nil ecb-history-menu-user-extension-function nil ecb-layout-name "left3" ecb-methods-menu-user-extension-function nil ecb-new-ecb-frame t)) ;;; ===== FONCTIONS ========================= ;; fonction pour insérer l'euro (fonction à 10 EUR ;o) (defun sk-insere-euro (&optional arg) "Insère le symbole Euro ISO 8859-15. Avec un préfixe, insère la version Unicode." (interactive "*P") (if arg (insert (make-char 'mule-unicode-0100-24ff 116 76)) (insert (make-char 'latin-iso8859-15 164)))) ;; caractère oe (defun sk-oe (&optional arg) "Insère le e dans l'o." (interactive "*P") ;; (if arg ;; (insert (make-char 'mule-unicode-0100-24ff 116 76)) (insert (make-char 'latin-iso8859-15 #xBD))) ;; Macintosh : interface vers AppleScript (if (eq system-type 'darwin) (progn (defvar sw-last-applescript nil "Stores the last Applescript command executed from Emacs.") (defvar sw-applescript-buffer-name "*AppleScript output*" "Name for the buffer to display AppleScript output.") (defun sw-applescript-run-buffer () "Execute the whole buffer as an Applescript" (interactive) (setq sw-last-applescript (buffer-string)) (sw-run-and-display-applescript (buffer-string))) (defun sw-applescript-run-region () "Execute the region as an Applescript" (interactive) (let ((region (buffer-substring (region-beginning) (region-end)))) (setq sw-last-applescript region) (sw-run-and-display-applescript region))) (defun sw-run-last-applescript () "Run the last Applescript command again" (interactive) (sw-run-and-display-applescript sw-last-applescript)) (defun sw-run-and-display-applescript (code) "Switch to the AppleScript buffer, erase it, run the code and display the results." (switch-to-buffer (get-buffer-create sw-applescript-buffer-name)) (erase-buffer) (insert (do-applescript code))) )) ;; Effacer tous les espaces en fin de ligne (defun delete-trailing-spaces () ;--> delete-trailing-whitespace ??? "Effacer les espaces et tabulations en fin de chaque ligne du tampon" (interactive) (progn (save-excursion (goto-line 1) (replace-regexp "[ \t]+$" "")))) ;; Conversion des fins de lignes du format MS-DOS au format Unix (defun dos2unix () (interactive) (goto-char (point-min)) (while (search-forward "\r" nil t) (replace-match ""))) ;; Conversion des fins de ligne du format Unix au format MS-DOS (defun unix2dos () (interactive) (goto-char (point-min)) (while (search-forward "\n" nil t) (replace-match "\r\n"))) ;; Montrer la table des caractères ASCII étendus ;; Fonction fournie par Alex Schroeder (defun ascii-table () "Afficher la table de caractères ASCII." (interactive) (switch-to-buffer "*ASCII*") (erase-buffer) (insert (format "Caractères ASCII de code 1 à 254.\n")) (let ((i 0)) (while (< i 254) (setq i (+ i 1)) (insert (format "%4d %c\n" i i)))) (beginning-of-buffer)) ;insertion date v2 ; File: .emacs-key-time ; Purpose: Insert date and time into the current buffer. ; ; a remplacer quand je pourrais (load-library "calendar.elc") ;; (defun emacs-key-time () "\ ;; Return a string containing the current Emacs date and time from ;; the system." ;; (interactive) ;; (if (interactive-p) ;; (insert (current-time-string)))) ;; (global-set-key "\C-x\/" 'emacs-key-time) ; define date and time key. ;;(global-set-key "\e\/" 'emacs-key-time) ; define date and time key. ;; insertion de la date courante (defun sk-insere-date () (interactive) (insert (calendar-date-string (calendar-current-date)))) ;; insertion de la date sélectionnée dans le calendrier ;; le focus doit être dans le buffer où l'on insère (defun sk-insere-date-sel () (interactive) (when (and (boundp 'calendar-buffer) (buffer-live-p (get-buffer calendar-buffer)) (let ((str (with-current-buffer calendar-buffer (calendar-date-string (calendar-cursor-to-date t))))) (insert str))))) ;;;===== Temporaire pour TEST ============================== ;; Atomatic proposal to compare binary files via hexl-mode (defvar ediff-do-hexl-diff nil "variable used to store trigger for doing diff in hexl-mode") (defadvice ediff-files-internal (around ediff-files-internal-for-binary-files activate) "catch the condition when the binary files differ the reason for catching the error out here (when re-thrown from the inner advice) is to let the stack continue to unwind before we start the new diff otherwise some code in the middle of the stack expects some output that isn't there and triggers an error" (let ((file-A (ad-get-arg 0)) (file-B (ad-get-arg 1)) ediff-do-hexl-diff) (condition-case err (progn ad-do-it) (error (if ediff-do-hexl-diff (let ((buf-A (find-file-noselect file-A)) (buf-B (find-file-noselect file-B))) (with-current-buffer buf-A (hexl-mode 1)) (with-current-buffer buf-B (hexl-mode 1)) (ediff-buffers buf-A buf-B)) (error (error-message-string err))))))) (defadvice ediff-setup-diff-regions (around ediff-setup-diff-regions-for-binary-files activate) "when binary files differ, set the variable " (condition-case err (progn ad-do-it) (error (setq ediff-do-hexl-diff (and (string-match-p "^Errors in diff output. Diff output is in.*" (error-message-string err)) (string-match-p "^\\(Binary \\)?[fF]iles .* and .* differ" (buffer-substring-no-properties (line-beginning-position) (line-end-position))) (y-or-n-p "The binary files differ, look at the differences in hexl-mode? "))) (error (error-message-string err))))) (eval-after-load "gnus-start" '(progn ;gnus-start ? (make-face 'my-gnus-group-line-ticked-face) (make-face 'my-gnus-group-line-new-face) (make-face 'my-gnus-group-line-unread-face) (make-face 'my-gnus-topic-line-face) (make-face 'my-gnus-mouse-group-line-ticked-face) (make-face 'my-gnus-mouse-group-line-new-face) (make-face 'my-gnus-mouse-group-line-unread-face) (make-face 'my-gnus-mouse-group-line-groupname-face) (make-face 'my-gnus-mouse-topic-line-face) (make-face 'my-gnus-group-line-groupname-face) (make-face 'my-gnus-group-line-groupname-read-face-1) (make-face 'my-gnus-group-line-groupname-read-face-2) (make-face 'my-gnus-group-line-groupname-read-face-3) (make-face 'my-gnus-group-line-groupname-read-face-4) (make-face 'my-gnus-group-line-groupname-unread-face-1) (make-face 'my-gnus-group-line-groupname-unread-face-2) (make-face 'my-gnus-group-line-groupname-unread-face-3) (make-face 'my-gnus-group-line-groupname-unread-face-4) ;; Here we assign the faces to the gnus-faces (setq gnus-face-1 'my-gnus-group-line-ticked-face) (setq gnus-face-2 'my-gnus-group-line-new-face) (setq gnus-face-3 'my-gnus-group-line-unread-face) (setq gnus-face-5 'my-gnus-topic-line-face) (setq gnus-face-8 'my-gnus-summary-line-tree-face) (setq gnus-mouse-face-1 'my-gnus-mouse-group-line-ticked-face) (setq gnus-mouse-face-2 'my-gnus-mouse-group-line-new-face) (setq gnus-mouse-face-3 'my-gnus-mouse-group-line-unread-face) (setq gnus-mouse-face-4 'my-gnus-mouse-group-line-groupname-face) (setq gnus-mouse-face-5 'my-gnus-mouse-topic-line-face) )) ;; ===== Customization de ps-print ========================= ;;masquer les local-variables à l'impression (defvar sk:ps-hide-local-variables t "FIXME:...") (defun sk:hide-local-variables () (narrow-to-region (point-min) (progn (end-of-buffer) ;; TODO: Set the BOUND arg. (when (re-search-backward "Local Variables" nil t) ;deux points omis volontairement (forward-line -1)) (point)))) (defadvice ps-print-buffer (around sk:ps-print-buffer activate) "FIXME:..." (save-excursion (save-restriction (when sk:ps-hide-local-variables (sk:hide-local-variables)) ad-do-it))) (defadvice ps-print-buffer-with-faces (around sk:ps-print-buffer-with-faces activate) "FIXME:..." (save-excursion (save-restriction (when sk:ps-hide-local-variables (sk:hide-local-variables)) ad-do-it))) (defadvice ps-spool-buffer (around sk:ps-spool-buffer activate) "FIXME:..." (save-excursion (save-restriction (when sk:ps-hide-local-variables (sk:hide-local-variables)) ad-do-it))) (defadvice ps-spool-buffer-with-faces (around sk:ps-spool-buffer-with-faces activate) "FIXME:..." (save-excursion (save-restriction (when sk:ps-hide-local-variables (sk:hide-local-variables)) ad-do-it))) (defun sk:ps-date-format () "Retourne le format de date dd/mm/yy" (format-time-string "%d/%m/%y")) (setq ps-right-header '("/pagenumberstring load" sk:ps-date-format ps-time-stamp-hh:mm:ss)) ;; ============= ps-print ===================================== ;; ce qui ne recherche pas les variables et les fonctions non-interactives ;; alors que M-x apropos recherche tout. On va unifier les deux (setq apropos-do-all t) (global-set-key (kbd "C-h a") 'apropos) ;; ====================================================================== ;; `apropos-value()': ;; ================== ;; ;; Il est question ici de créer un advice autour de ;; `apropos-value()' afin de permettre qu'un argument numérique ;; négatif fixe `apropos-do-all' à nil. En effet, cette commande ;; est très lourde, et je fixe cette variable à t, ce qui ;; n'arrange rien. La version originale permet d'« activer » ;; `apropos-do-all' par un argument préfixe, mais pas de le ;; désactiver. ;; ;; TODO: Implémentation à vérifier ... Il serait sans doute plus ;; judicieux de créer de nouvalles variables, ayant la même ;; sémantique que `apropos-do-all', mais « spécialisées » pour ;; chaque commande d'apropos. De même, il serait intéressant de ;; pouvoir limiter les symboles sur lesquels chercher (par ;; exemple par une régexp, ou un préfixe). Souvent, en effet, on ;; connait le préfixe de package, et cela peut faire gagner ;; beaucoup de temps sur cette fonction lente ... ;; ---------------------------------------------------------------------- (defadvice apropos-value (around drkm-my:apropos-value activate) "FIXME: ..." (let ((apropos-do-all (if (let ((arg (ad-get-arg 1))) (or (eq arg '-) (and (numberp arg) (< arg 0)))) (ad-set-arg 1 nil) apropos-do-all))) ad-do-it)) ;; ==== Comportement du MANuel ===================== ;; les pages de manuel font frame à part (setq Man-notify-method 'newframe ;;pushy Man-frame-parameters '((foreground-color . "black") (background-color . "grey90") (cursor-color . "black") (mouse-color . "gold") (width . 80) (tool-bar-lines . 0))) ;; ==== MAN ======================================== ;; ==== Affichage d'Info dans une autre frame ====== ;; code piqué chez Tony Finch http://dotat.at/prog/rcfiles/emacs ;; {{{ info (require 'info) (let ((infop (concat sk:elisp-path "/info"))) (when (file-exists-p infop) (setq Info-directory-list Info-default-directory-list) ;;ignore $INFOPATH (push infop Info-directory-list))) (when (or (string-match "\\`goudurix" system-name) (string-match "\\`zebigbos" system-name)) (push "/sw/share/info" Info-directory-list) (push "/Applications/Emacs.app/Contents/Resources/info" Info-directory-list) ;; not built-in ? ) (setq Info-fontify-maximum-menu-size 1000000) ;; {{{ Info-other-frame (defun Info-other-frame (&optional file) "Start *info* mode in another frame." (interactive (if current-prefix-arg (list (read-file-name "Info file name: " nil nil t)))) (let ((pop-up-frames t) (buffer (current-buffer))) (pop-to-buffer buffer t) (raise-frame (window-frame (selected-window))) (info file))) ;; }}} ;; {{{ Info-uniquify-buffer (defun Info-uniquify-buffer () "Rename an *info* buffer uniquely." (rename-buffer "*info*" 't)) ;; }}} ;; {{{ Info-rename-buffer (defun Info-rename-buffer (suffix) "Rename an *info* buffer according to the user's choice." (interactive "sBuffer name suffix: ") (rename-buffer (concat "*info-" suffix "*"))) ;; }}} ;; {{{ Info-search-again (defun Info-search-again (regexp) "Search an info file with a better user-interface than Info-search." (interactive (list (if Info-search-history (car Info-search-history) (read-string "Regexp search: " nil 'Info-search-history)))) (Info-search regexp)) ;; }}} (global-set-key "\C-x5i" 'Info-other-frame ) (add-hook 'Info-mode-hook 'Info-uniquify-buffer) (define-key Info-mode-map "s" 'Info-search-again) (define-key Info-mode-map "S" 'Info-search) (define-key Info-mode-map "r" 'Info-rename-buffer) ;; }}} ;;====== Info ================================== ;; déplacement vertical dans les lignes wrappées (require 'screen-lines2 nil t) ;; ouverture d'un fichier avec chemin relatif ;; et ouverture d'un fichier le nom est indiqué par le point ;; de Patrick Percot et Matthieu Moy ;; C-x a f: ltf-find-file ;; C-x a v: ltf-find-file-at-point ;; C-u C-x a v : find file at point, in another window. (require 'find-this-file nil t) ;; Load CEDET ;; (setq semantic-load-turn-useful-things-on t) ;; (setq semantic-load-turn-everything-on t) ;; (let ((cedet-f (concat sk:elisp-path "/cedet/common/cedet.el"))) ;; (when (file-exists-p cedet-f) ;; (load-library cedet-f) ;; ;; Enabling SEMANTIC minor modes. See semantic/INSTALL for more ideas. ;; (semantic-load-enable-excessive-code-helpers) ;; (setq semanticdb-default-save-directory (concat sk:home "/tmp")) ;; (global-ede-mode 1) ; Enable the Project management system ;; (semantic-load-enable-code-helpers) ; Enable prototype help and smart completion ;; (global-srecode-minor-mode 1) ; Enable template insertion menu ;; )) ;; ecb ;;(when (require 'ecb-autoloads nil t) ;;(when (require 'ecb nil t) ;;(setq semantic-load-turn-useful-things-on t) ;; ) ;; vb mode (require 'visual-basic-mode nil t) ; caractères OEM DOS ; (require 'iso-oem) ; (standard-display-iso-oem) ;; auctex ;;(require 'tex-site nil t) ;;(load "preview-latex.el" nil t t) ;;(autoload 'whizzytex-mode ;; "whizzytex" ;; "WhizzyTeX, a minor-mode WYSIWIG environment for LaTeX" t) ; folding mode (if (load "folding" 'nomessage 'noerror) (folding-mode-add-find-file-hook)) ; Reglages DocBook ; DocBook IDE mode ;(autoload 'docbook-mode "docbookide" "Major mode for DocBook documents." t) ; Turn on font lock when in DocBook mode (add-hook 'docbook-mode-hook 'turn-on-font-lock) ;; Emacs/W3 Configuration ;(setq load-path (cons "/sw/share/emacs/site-lisp" load-path)) ;(condition-case () (require 'w3-auto "w3-auto") (error nil)) (when (require 'w3m-load nil t) (if (string-match "\\`goudurix" system-name) (setq w3m-icon-directory (concat sk:elisp-path "/w3m/icons")))) ;(put 'dired-find-alternate-file 'disabled nil) ;; we want dired not not make always a new buffer if visiting a directory ;; but using only one dired buffer for all directories. ;; (eval-after-load "dired" ;; '(progn ;; (defadvice dired-advertised-find-file (around dired-subst-directory activate) ;; "Replace current buffer if file is a directory." ;; (interactive) ;; (let ((orig (current-buffer)) ;; (filename (dired-get-filename))) ;; ad-do-it ;; (when (and (file-directory-p filename) ;; (not (eq (current-buffer) orig))) ;; (kill-buffer orig)))))) (eval-after-load "dired" '(progn (defadvice dired-advertised-find-file (around dired-subst-directory activate) "Replace current buffer if file is a directory." (interactive) (let* ((orig (current-buffer)) (filename (dired-get-filename)) (bye-p (file-directory-p filename))) ad-do-it (when (and bye-p (not (string-match "[/\\\\]\\.$" filename))) (kill-buffer orig)))))) ;; add improved sorting for dired ;; dired-quick-sort was installed with MELPA (when (require 'dired-quick-sort nil t) (dired-quick-sort-setup) ;; \C-x = Ctrl-x ;; \M-x = Meta-x ;; xy = x y (define-key dired-mode-map ";" 'dired-do-symlink) ; S is stolen by dired-quick-sort ) ;; paramétrage Pymacs (autoload 'pymacs-load "pymacs" nil t) (autoload 'pymacs-eval "pymacs" nil t) (autoload 'pymacs-apply "pymacs") (autoload 'pymacs-call "pymacs") ;;(eval-after-load "pymacs" ;; '(add-to-list 'pymacs-load-path "your-pymacs-directory")) (unless window-system (progn (global-set-key "\eOp" "0") (global-set-key "\eOq" "1") (global-set-key "\eOr" "2") (global-set-key "\eOs" "3") (global-set-key "\eOt" "4") (global-set-key "\eOu" "5") (global-set-key "\eOv" "6") (global-set-key "\eOw" "7") (global-set-key "\eOx" "8") (global-set-key "\eOy" "9") ;; (global-set-key "\eOk" "+") ;;attention, pour l'émulation xterm-R6 ;; (global-set-key "\eOo" "/") ;; ;; (global-set-key "\eOj" "*") ;; ;; (global-set-key "\eOm" "-") ;; ;; (global-set-key "\eOn" ".") (global-set-key "\eOQ" "/") (global-set-key "\eOR" "*") (global-set-key "\eOS" "-") (global-set-key "\eOl" "+") (global-set-key "\eOm" 'newline-and-indent) ;;(define-key function-key-map "\eOM" [kp-enter]) ;;(define-key function-key-map "\eOM" 'newline-and-indent) (global-set-key "\eOn" ".") )) ;;interface cdcd (require 'cdi nil t) ;;interface emms (when (require 'emms nil t) (when (require 'emms-default nil t) (emms-setup 'advanced (concat sk:home "/mp3")))) ;;évaluation de l'application non libre xref (when (string-match "\\`goudurix" system-name) (setq load-path (cons "/Users/seki/Appl/xref/emacs" load-path)) (setq exec-path (cons "/Users/seki/Appl/xref" exec-path)) (load "xrefactory")) ;; pouvoir souligner la région avec des ^^^ ;; provient du module under.el du package emacs-goodies (autoload 'underhat-region "under" "Underline the region" t) (global-set-key "\C-c\C-u" 'underhat-region) ;; ERC (when (require 'erc-auto nil t) (require 'erc-menu) (require 'erc-nicklist) (setq erc-nick "seki" erc-user-full-name "Sébastien Kirche" erc-public-away-p nil erc-port 6667 erc-prompt-for-password nil) ;; erc menu entrys in Tools ;(require 'easymenu) ;(easy-menu-add-item nil '("tools") ; ["Connect to Freenode (ERC)" erc-freenode t]) ;; erc connect ;; (defmacro de-erc-connect (command server port nick) ;; "Create interactive command `command', for connecting to an IRC server. The ;; command uses interactive mode if passed an argument." ;; (fset command ;; `(lambda (arg) ;; (interactive "p") ;; (if (not (= 1 arg)) ;; (call-interactively 'erc) ;; (erc :server ,server :port ,port :nick ,nick))))) ;; (autoload 'erc "erc" "" t) ;; (de-erc-connect erc-freenode "irc.freenode.net" 6667 "Nick") ;; (de-erc-connect erc-bitlbee "im.bitlbee.org" 6667 "Nick") (setq erc-default-coding-system '(utf-8 . undecided)) (setq erc-paranoid t) ; Show CTCP-messages. (load (concat sk:home "/.emacs_ercpass")) (require 'erc-services) (erc-services-mode 1) (setq erc-prompt-for-nickserv-password nil) (setq erc-nickserv-passwords '((freenode (("seki" . ,freenode-nickone-pass) ("seki_zzzz" . ,freenode-nickone-pass))) ;; ;;(DALnet (("nickname" . "password"))) ) ) (setq erc-encoding-coding-alist '()) (add-to-list 'erc-encoding-coding-alist '("#emacsfr" . utf-8)) (add-to-list 'erc-encoding-coding-alist '("#fmbl" . latin-0)) (add-to-list 'erc-encoding-coding-alist '("#seki" . latin-0)) (add-to-list 'erc-encoding-coding-alist '("#seki8" . utf-8)) ;; erc identify ;(add-hook 'erc-after-connect ; '(lambda (SERVER NICK) ; (cond ; ((string-match "freenode\\.net" SERVER) ; (erc-message "PRIVMSG" "NickServ identify Passwd")) ; ; ;((string-match "bitlbee\\.org" SERVER) ; ;(erc-message "PRIVMSG" "Nickserv identify Passwd")) ;(setq erc-default-coding-system '(utf-8 . undecided)) ; ;; Some stupid channels require obsolete charsets. ; (push '("#udvikleren.dk" . (iso-latin-1 . undecided)) ; erc-encoding-coding-alist) ) ;; planner / wiki (when (require 'planner nil t) (require 'muse-mode nil t) (require 'remember-planner nil t) (setq planner-directory (concat sk:home "/Plans")) (setq planner-publishing-directory (concat planner-directory "/wiki")) (setq planner-project "WikiPlanner" planner-default-page "TaskPool") (setq muse-project-alist `((,planner-project (,planner-directory :default ,planner-default-page :major-mode planner-mode :visit-link planner-visit-link) (:base "xhtml" :path ,planner-publishing-directory))))) ;; nxml (let ((nxml-loader (concat sk:elisp-path "/nxml/rng-auto.el"))) (when (file-exists-p nxml-loader) (load nxml-loader) (add-to-list 'auto-mode-alist '("\\.\\(xml\\|xsl\\|rng\\|xhtml\\)" . nxml-mode)))) ;; rescale des polices ==> pour la version de MacEmacs JP / Carbon Emacs ;; http://home.att.ne.jp/alpha/z123/emacs-mac-e.html (if (eq system-type 'darwin) (setq face-font-rescale-alist '((".*osaka-bold.*" . 1.15) (".*osaka-medium-i.*" . 1.2) (".*osaka-medium-r.*" . 1.2) (".*courier-medium.*" . 1.0) (".*courier-bold.*" . 1.0) ;;(".*monaco-bold.*" . 0.9) ;;(".*ayuthaya-bold.*" . 0.9) ("-cdac$" . 1.3)))) ;;;* Remembrance Agent (aka savant) (when (require 'remem nil t) (setq remem-log-p t) (setq remem-database-dir "~/R-Agent") ;;(setq remem-prog-dir (expand-file-name "/home/zedek/bin/")) (setq remem-scopes-list '( ("notes" 6 5 50) ; mkdir ~/R-Agent/notes && ra-index -v ~/R-Agent/notes ~/mnt/winhome/notes ;; ("mail" 6 5 50) ;; ("docspersos" 6 5 50) ;;("tech" 3 5 50) ;; RFC, W3C recomandation, etc... ;;("mail" 6 5 50) ;; Few mails to remember ;;("note" 2 10 50) ;; Notes, memos )) ) ;;;=================================================== ;; use the ghostscript printer program to open a standard printer ;; dialog, works like a charm!! (cond ((eq system-type 'windows-nt) ;;(setq-default ps-lpr-command (concat UTILS_DIR "/gs/gsview/gsprint.exe")) (setq-default ps-lpr-command "C:/Program Files/Ghostgum/gsview/gsprint.exe") (setq-default ps-printer-name t) (setq-default ps-printer-name-option nil) (setq ps-lpr-switches '("-query")) ; show printer dialog ) ) ;; Add Consolas ;; https://superuser.com/a/366203/86175 (setq ps-font-info-database (append '((Consolas (fonts (normal . "Consolas") (bold . "Consolas-Bold") (italic . "Consolas-Italic") (bold-italic . "Consolas-Bold-Italic")) (size . 10.0) (line-height . 13.0) (space-width . 6.04688) (avg-char-width . 6.04688))) ps-font-info-database)) (setq ps-font-family 'Consolas) (setq ps-font-size 9) ;; utilisation de org-mode (add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode)) (global-set-key "\C-cl" 'org-store-link) (global-set-key "\C-ca" 'org-agenda) ;; tramp initialization (when (require 'tramp nil t) ;; Define a new tramp method name to avoid the conflict of ;; default version of 'plink' ;; see https://www.emacswiki.org/emacs/TrampMode ;; so we can edit with /ecpl:user@host:path/to/file (add-to-list 'tramp-methods (list "ecpl" ;use it with /ecpl: instead of /ssh: '(tramp-login-program "plink") (cons 'tramp-login-args (list (list '("-l" "%u") '("-P" "%p") '("-ssh") '("-t") '("-a") '("-x") (if (equal system-type 'windows-nt) (progn (setq keyfilename (expand-file-name (concat (getenv "HOME") "/.ssh/kirchse-priv.ppk"))) (if (file-exists-p keyfilename) (list "-i" (concat "\"" keyfilename "\""))))) '("%h") '("\"") '("env 'TERM=dumb' 'PROMPT_COMMAND=' 'PS1=#$ '") '("/bin/sh") '("\"") ))) '(tramp-remote-shell "/bin/sh") '(tramp-remote-shell-login ("-l")) '(tramp-remote-shell-args ("-c")) '(tramp-default-port 22)) t) ;; tramp backup path (if not set, save in local backup directory) (setq tramp-backup-directory-alist nil) (setq tramp-auto-save-directory nil) ;; Ces réglages sont incorrects : ils définissent tramp-shell-prompt-pattern en fonction ;; du système où Emacs tourne et pas du système distant ;; ;; correction du prompt attendu par tramp ;; (when (or (string-match "\\`obelix" system-name) ;; (string-match "\\`petisuix" system-name)) ;; ;; mon prompt zsh est du style 1:36 seki@petisuix ~/directory% ;; ;; TODO : cette regexp n'est pas ancrée mais il y a un problème si je l'ancre au début ;; (setq tramp-shell-prompt-pattern "[0-9]+:[0-9]+ \\w+@\\w+ [^#%]*[#%] *")) ;; ;; (when (string-match "\\`macseb" system-name) ;; (setq tramp-shell-prompt-pattern "\\[\\w+@\\w+ [^\\]]*\\] [#%] *")) ) ;; pretty-print xml ;; source: https://davidcapello.com/blog/emacs/reformat-xml-on-emacs/ (when (require 'sgml-mode nil t) (defun reformat-xml () (interactive) (save-excursion (sgml-pretty-print (point-min) (point-max)) (indent-region (point-min) (point-max)))) ) ;; Markdown mode - https://jblevins.org/projects/markdown-mode/ (autoload 'markdown-mode "markdown-mode" "Major mode for editing Markdown files" t) (add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode)) (add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode)) (autoload 'gfm-mode "markdown-mode" "Major mode for editing GitHub Flavored Markdown files" t) (add-to-list 'auto-mode-alist '("README\\.md\\'" . gfm-mode)) ;; imenu integration to Markdown (add-hook 'markdown-mode-hook 'imenu-add-menubar-index) (setq imenu-auto-rescan t) ;; also install imenu-list from https://github.com/bmag/imenu-list ;; and ei - https://github.com/Fanael/edit-indirect/ ;; commandes activées (put 'upcase-region 'disabled nil) (put 'downcase-region 'disabled nil) (put 'narrow-to-region 'disabled nil) ;;; This was installed by package-install.el. ;;; This provides support for the package system and ;;; interfacing with ELPA, the package archive. ;;; Move this code earlier if you want to reference ;;; packages in your .emacs. (let ((elpa-dir (expand-file-name "~/.emacs.d/elpa"))) (when (require 'package nil t) ;; (when (and (file-exists-p elpa-dir) ;; (load (concat (file-name-as-directory elpa-dir) "package.el"))) ;; use bleeding edge packages ;; (add-to-list 'package-archives ;; (cons "melpa" (concat proto "://melpa.org/packages/")) t) ;; use stable packages ;; (add-to-list 'package-archives ;; '("melpa-stable" . "http://stable.melpa.org/packages/") t) (setq package-archives '(("GNU ELPA" . "https://elpa.gnu.org/packages/") ("MELPA Stable" . "https://stable.melpa.org/packages/") ("MELPA" . "https://melpa.org/packages/")) package-archive-priorities '(("MELPA Stable" . 10) ("GNU ELPA" . 5) ("MELPA" . 20))) (package-initialize)) ) (when (file-exists-p "c:/dev/perl/Emacs-PDE-0.2.16") (add-to-list 'load-path "c:/dev/perl/Emacs-PDE-0.2.16/lisp/") (load "pde-load")) ;; breadcrumbs in dired headlines ;; https://emacs.stackexchange.com/questions/13354/dired-heading-directory-with-text-properties-to-jump-to-parent-directories/13380#13380 ;; and https://emacs.stackexchange.com/questions/13354/dired-heading-directory-with-text-properties-to-jump-to-parent-directories (when (require 'dired nil t) (defface dired-mouseover-face '((t (:foreground "green"))) "Face for `dired-mouseover-face'." :group 'dired) (defvar dired-mouse-map (let ((map (make-sparse-keymap))) (define-key map [mouse-2] 'dired-follow-link) (define-key map [return] 'dired-follow-link) (define-key map [follow-link] 'mouse-face) map) "Keymap for mouse when in `dired-mode'.") ;; Author: Drew Adams -- http://emacs.stackexchange.com/a/13411/2287 (defun dired-follow-link (event) "Follow the link in the dired directory heading, causing a new dired buffer to be opened." (interactive (list last-nonmenu-event)) (run-hooks 'mouse-leave-buffer-hook) (with-current-buffer (window-buffer (posn-window (event-start event))) (let ((path (get-text-property (posn-point (event-start event)) 'breadcrumb))) (dired path)))) (defun dired-propertize-directory-heading () (interactive) (unless (buffer-narrowed-p) (let* ( p beg end path peol (inhibit-read-only t) ) (save-excursion (goto-char (point-min)) (setq peol (point-at-eol)) (set-text-properties (point) peol nil) (re-search-forward "\\([^/\\]+\\)[/\\]" peol t) (when (looking-back "\\(^ +\\)\\([a-zA-Z]:\\)?/") (setq p (match-end 1)) (setq path (if (match-string 2) (concat (match-string 2) "/") "/")) (add-text-properties (point-min) (1- (match-end 0)) (list 'breadcrumb path 'mouse-face 'dired-mouseover-face 'help-echo (format "mouse-2, RET: Follow the link to \"%s\"." path) 'keymap dired-mouse-map))) (while (re-search-forward "\\([^/\\]+\\)[/\\]" peol t) (setq beg (match-beginning 1)) (setq end (match-end 1)) (setq path (buffer-substring-no-properties p end)) (add-text-properties beg end (list 'breadcrumb path 'mouse-face 'dired-mouseover-face 'help-echo (format "mouse-2, RET: Follow the link to \"%s\"." path) 'keymap dired-mouse-map))) (setq path (buffer-substring-no-properties p (1- peol))) (add-text-properties (point) (1- peol) (list 'breadcrumb path 'mouse-face 'dired-mouseover-face 'help-echo (format "mouse-2, RET: Follow the link to \"%s\"." path) 'keymap dired-mouse-map)))))) (add-hook 'dired-after-readin-hook 'dired-propertize-directory-heading) ) ;; Mastodon.el (setq mastodon-instance-url "https://framapiaf.org" mastodon-active-user "sebkirche") ;; For lingva.el (setq lingva-target "fr") ;;trucs utiles elisp ;; trouver le code d'une touche -> M-: (read-key-sequence "") ;gestionnaire de signal USR1 (possible avec USR2) ;(defun test-seki ()"" (interactive )(message "key usr1")) ;(global-set-key [usr1-signal] 'test-seki ) ;(add-hook 'signal-USR1-hook (lambda () (test-seki))) ;; Local Variables: ;; mode: emacs-lisp ;; truncate-lines: t ;; time-stamp-format: "%02d/%02m/%:y %02H:%02M %u@%s" ;; End: