(defmacro GNUEmacs (&rest x) (list 'if (string-match "GNU Emacs" (version)) (cons 'progn x))) (defmacro XEmacs (&rest x) (list 'if (string-match "XEmacs" (version)) (cons 'progn x))) (cond ((string-match ".*macs *21\..*" (emacs-version)) (setq emacs-major-version 21)) ((string-match ".*macs *20\..*" (emacs-version)) (setq emacs-major-version 20)) ((string-match ".*macs *19\..*" (emacs-version)) (setq emacs-major-version 19)) ) ;;-------------------------------------------------------------------- ;; Chemin des librairies (setq moy-lisp-directory (expand-file-name "~/emacs-lisp/")) ;(require 'verimag) ;(add-to-list 'load-path verimag-lisp-directory) ;(add-to-list 'load-path verimag-ognus-directory) ;(add-to-list 'load-path verimag-bbdb-directory) (add-to-list 'load-path "/usr/local/common/share/emacs21/site-lisp/ognus") (add-to-list 'load-path (concat moy-lisp-directory "bbdb")) (add-to-list 'load-path (concat moy-lisp-directory "Stephe")) (add-to-list 'load-path (concat moy-lisp-directory "moy")) (add-to-list 'load-path moy-lisp-directory) ;(add-to-list 'load-path "/usr/share/emacs/site-lisp/gnuserv/") ;;-------------------------------------------------------------------- ;; .. Et des fichiers info (require 'info) (add-to-list 'Info-directory-list "/usr/share/info") (add-to-list 'Info-directory-list "/home/moy/man/info") ;(add-to-list 'Info-directory-list "/home/moy/src/auctex-10.0g/doc") (add-to-list 'Info-directory-list "/usr/info") ;; devrait être là par défaut, mais il semble que la ligne précédante ;; efface tout ... ;;--------------------------------------------------------------------- ;; Paths are OK. Now, autoload the installed libraries : (require 'moy-autoloads "/home/moy/.autoloads") ;;-------------------------------------------------------------------- ;; On passe en ISO 8859 Latin-1 (les accents, ...) (if (>= emacs-major-version 21) (progn (set-language-environment 'latin-1) (set-terminal-coding-system 'latin-1) (set-keyboard-coding-system 'latin-1) ) (progn (set-terminal-coding-system 'latin-1) (set-keyboard-coding-system 'latin-1) (set-language-environment 'latin-1) ) ) ;;-------------------------------------------------------------------- ;; La barre de menu ne me sert (presque) jamais ... ;(menu-bar-mode -1) (if (>= emacs-major-version 21) (progn (tool-bar-mode -1) (scroll-bar-mode -1) (setq-default cursor-in-non-selected-windows nil) )) ;;-------------------------------------------------------------------- ;; Dans la série des trucs que j'aime pas : le curseur clignottant (if (>= emacs-major-version 21) (blink-cursor-mode -1)) ;;-------------------------------------------------------------------- ;; iswitch (require 'iswitchb) (iswitchb-default-keybindings) ;;-------------------------------------------------------------------- ;; Templates (add-hook 'find-file-hooks 'auto-insert) (load-library "autoinsert") (setq auto-insert-directory "~/emacs-templates/") ;(setq auto-insert-alist (append '((latex-mode . "tex-insert.tex")) auto-insert-alist)) ;;-------------------------------------------------------------------- ;; BBDB : An address book for gnus (require 'bbdb) (bbdb-initialize 'gnus) (add-hook 'gnus-startup-hook 'bbdb-insinuate-gnus) ;;-------------------------------------------------------------------- ;; Utiliser gnus par défaut (setq mail-user-agent 'gnus-user-agent) (defun moy-show-gnus-group-buffer () "Manages to show the group buffer of gnus. If gnus is not running, launch it in another frame. Else, just display the group buffer." (if (gnus-alive-p) (progn (switch-to-buffer gnus-group-buffer) (delete-other-windows) ) (gnus-other-frame))) ;;-------------------------------------------------------------------- ;; Pour que la couleur marche en mode shell. (autoload 'ansi-color-for-comint-mode-on "ansi-color" nil t) (add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on) (defun to-bottom () (interactive) "Recenter screen so that current line is on the bottom of the screen" (recenter -1) ) (defun set-key-to-bottom () (interactive) (local-set-key "\C-l" 'to-bottom) ) (add-hook 'shell-mode-hook 'set-key-to-bottom) ;;-------------------------------------------------------------------- ;; Des espaces pour indenter. (setq indent-tabs-mode nil) ;;-------------------------------------------------- ;; DESKTOP SAVING ;; ;; use M-x desktop-save to res-save the desktop ;;(load "desktop") ;;(desktop-load-default) ;;(desktop-read) ;;-------------------------------------------------------------------- ;; Scheme avec Ravi (setq scheme-program-name "ravi") (add-hook 'scheme-mode-hook '(lambda () (auto-fill-mode t) ; des lignes pas trop longues (local-set-key [return] 'newline-and-indent) )) ;;-------------------------------------------------------------------- ;; L'Ada est sans doute mon language préféré ... ;;(require 'moy-ada) (defun semicolon-and-indent () "insert a ; and indent" (interactive) (insert ";") (indent-according-to-mode) ) (defun set-key-semicolon-and-indent () (interactive) (local-set-key ";" 'semicolon-and-indent)) (autoload 'gnat-fix-compiler-error "gnat-fix-error" "fix error in Ada" t) (add-hook 'ada-mode-hook '(lambda () (auto-fill-mode t) (setq indent-tabs-mode nil) (abbrev-mode t) (local-set-key [return] 'reindent-then-newline-and-indent) (set-key-semicolon-and-indent) ; doesn't work ! (local-set-key [C-tab] 'other-window) (local-unset-key [down-mouse-3]) (local-set-key "\C-\M-z" 'ada-nice-guess) ) t ; To put it at the end of the hook. ) ;;-------------------------------------------------------------------- ;; Correspondance des parenthèses (setq show-paren-style 'expression) (show-paren-mode) (global-set-key [M-right] 'forward-sexp) (global-set-key [M-left] 'backward-sexp) ;;Pompée sur le .emacs de Mandrake (licence GPL) (defun match-paren (arg) "Go to the matching parenthesis if on parenthesis otherwise insert %." (interactive "p") (cond ((looking-at "\\s\(") (forward-list 1) (backward-char 1)) ((looking-at "\\s\)") (forward-char 1) (backward-list 1)) (t (self-insert-command (or arg 1))))) (global-set-key "%" 'match-paren) ;;-------------------------------------------------------------------- ;; Flyspell-mode (ispell-change-dictionary "american") (setq ispell-dictionary "american") ;(autoload 'flyspell-mode "flyspell" "On-the-fly spelling checking" t) (add-hook 'latex-mode-hook 'flyspell-mode) ;; Pour eviter les erreurs au lancement du mode scheme avant le premier ;; appel a flyspell-mode. (defun flyspell-mode-off () '()) (add-hook 'scheme-mode-hook 'flyspell-mode-off) ;;-------------------------------------------------------------------- ;; AUC Tex : Un mode LaTeX particulièrement bien foutu (require 'tex-site) (require 'font-latex) (setq TeX-save-query nil) ;(load "tex-site") ;;-------------------------------------------------------------------- ;; sweb : Programmation litéraire en Scheme (add-to-list 'auto-mode-alist (cons "\\.sw\\'" 'scheme-mode)) (add-hook 'latex-mode-hook '(lambda () (local-set-key [f12] 'scheme-mode))) (add-hook 'scheme-mode-hook '(lambda () (local-set-key [f12] 'latex-mode))) ;;-------------------------------------------------------------------- ;; Clips-mode ;;(autoload 'clips-mode "clips-mode" "Mode for clips editing" t) ;;-------------------------------------------------------------------- ;; Pour les fichiers de config : shell-script mode par défaut (add-to-list 'auto-mode-alist (cons "\\.fvwm.*rc$" 'shell-script-mode)) (add-to-list 'auto-mode-alist (cons "\\.muttrc$" 'shell-script-mode)) ;;-------------------------------------------------------------------- ;; Pour utiliser emacsclient (server-start) ;(autoload 'gnuserv-start "gnuserv" "Better Emacs server support" t) ;(gnuserv-start) ;; Translate `C-h' to DEL. ;;(keyboard-translate ?\C-h ?\C-?) ;;---------------------------------------------------------------------- ;; Xdvi pour le mode TeX (setq tex-dvi-view-command "xdvi") ;;---------------------------------------------------------------------- ;; affiche des trucs sur la mode line (line-number-mode t) (column-number-mode t) (global-set-key [C-kp-add] 'enlarge-window-horizontally) (global-set-key [C-kp-subtract] 'shrink-window-horizontally) (global-set-key [M-kp-add] 'enlarge-window) (global-set-key [M-kp-subtract] 'shrink-window) (defun big () (interactive) (enlarge-window-horizontally 2) (enlarge-window 2) ) (defun small () (interactive) (shrink-window-horizontally 2) (shrink-window 2) ) (global-set-key [M-C-kp-add] 'big) (global-set-key [M-C-kp-subtract] 'small) ;;---------------------------------------------------------------------- ;; Mode VIPER : emulation VI ;(setq viper-mode t) ;(require 'viper) ;;---------------------------------------------------------------------- ;; Mode auto-fill : retour ligne au bout de 80 caractères (add-hook 'text-mode-hook (lambda () (auto-fill-mode t) (setq default-justification 'full)) ) (global-set-key "\M-s" 'dabbrev-expand) (GNUEmacs (global-set-key "\M-g" 'goto-line) (global-set-key [C-tab] 'other-window)) (global-set-key "\C-z" 'comment-region) (font-lock-mode t) (global-font-lock-mode t) (setq font-lock-maximum-decoration 5) ;;string face (set-face-foreground 'font-lock-string-face "Cyan") ;;Comment face (set-face-foreground 'font-lock-comment-face "OrangeRed") ;;keywords (set-face-foreground 'font-lock-keyword-face "Wheat") (set-face-bold-p 'font-lock-keyword-face t) ;;type (set-face-foreground 'font-lock-type-face "Wheat") (set-face-underline-p 'font-lock-type-face t) ;;var and functions (set-face-foreground 'font-lock-function-name-face "LightBlue") (set-face-background 'font-lock-function-name-face "Navy") ;(set-face-bold-p 'font-lock-function-name-face nil) (set-face-foreground 'font-lock-variable-name-face "Green") ;;reference: this is for example what follows a case (set-face-foreground 'font-lock-constant-face "White") (set-face-background 'font-lock-constant-face "BlueViolet") ;;---------------------------------------------------------------------- ;; COMPILATION ;;---------------------------------------------------------------------- ( setq-default compile-command "make" ;; -j 8 pour lancer 8 processus en parallèle. compilation-read-command t compilation-ask-about-save nil compilation-window-height 12 ) (defun make-install () (interactive) "Compile with \"make install\" as a compilation command" (setq old-compile-command compile-command) (setq compile-command "make install") (recompile) (setq compile-command old-compile-command) ) ;;--------------------------------------------------------------------- ;; Shell toggle ;(autoload 'shell-toggle "shell-toggle" ; "Toggles between the *shell* buffer and whatever buffer you are editing." ; t) ;(autoload 'shell-toggle-cd "shell-toggle" ; "Pops up a shell-buffer and insert a \"cd \" command." t) (global-set-key [f11] 'shell-toggle) (global-set-key [M-f11] 'shell-toggle-cd) (global-set-key [C-f11] '(lambda () (interactive) (shell-toggle nil) (shell-toggle nil) (compile compile-command))) (global-set-key [M-f9] 'compile) (global-set-key [f9] 'recompile) (global-set-key [C-M-f9] 'make-install) (global-set-key [f10] 'next-error) (global-set-key [M-f10] 'previous-error) (global-set-key [C-f10] 'gnat-fix-compiler-error) (global-set-key [f12] 'ff-find-other-file) ;;---------------------------------------------------------------------- ;; MOVING THE CURSOR IN THE BUFFER ;; when moving the cursor to the bottom/top of screen, scroll up/down 2 lines (setq scroll-step 3) ;; when moving page up/down, keep 1 line in common (setq next-screen-context-lines 1) (global-set-key [home] 'beginning-of-line) (global-set-key [end] 'end-of-line) ;; Le curseur reste toujours à la même position quand on scroll (setq scroll-preserve-screen-position t) ;; Une touche DEL qui fait vraiment DEL !!! (and window-system (functionp 'normal-erase-is-backspace-mode) (normal-erase-is-backspace-mode nil)) ;; Options Menu Settings ;; ===================== (cond ((and (string-match "XEmacs" emacs-version) (boundp 'emacs-major-version) (or (and (= emacs-major-version 19) (>= emacs-minor-version 14)) (= emacs-major-version 20)) (fboundp 'load-options-file)) (load-options-file "/home/moy/.xemacs-options"))) ;; ============================ ;; End of Options Menu Settings (require 'thumbs) (require 'hachette) (auto-image-file-mode t) (if (eq window-system 'x) (progn (set-face-foreground 'default "#A595FF") (set-face-background 'default "#000050") ) ) ;;--------------------------------------------------------------------- ;; Customize file (setq custom-file (expand-file-name "~/.emacs-customize")) (load custom-file) ;;--------------------------------------------------------------------- ;; Nice drawing in Emacs. ;;; See http://www.lysator.liu.se/~tab/artist/ ;(autoload 'artist-mode "artist" "Enter artist-mode" t) ;;--------------------------------------------------------------------- ;; Window configuration (defun moy-prefered-window-configuration () (interactive) (shell-toggle 'nil) (shell-toggle 'nil) (delete-other-windows) (split-window-horizontally) (other-window 1) (split-window-vertically 24) (split-window-vertically) (switch-to-buffer "*compilation*") (other-window 1) (switch-to-buffer "*shell*") (other-window 1) (ff-find-other-file) (other-window -3) ) (defun moy-compile-window-configuration () (interactive) (shell-toggle 'nil) (shell-toggle 'nil) (delete-other-windows) (split-window-vertically 12) (switch-to-buffer "*compilation*") (other-window 1) ) (defun moy-gnus-window () (interactive) (delete-other-windows) (switch-to-buffer "*Group*") ) (global-set-key [C-f5] 'moy-prefered-window-configuration) (global-set-key [C-f6] 'moy-compile-window-configuration) (global-set-key [C-f7] 'moy-gnus-window)