;; -*- local-write-file-hooks: time-stamp; -*- ;; Time-stamp: <2007-07-09 17:11:53 mifrey> ;;-------------------------------------------------------------------- ;; Emacs configuration file ;;-------------------------------------------------------------------- ;; Global key bindings (global-set-key [f2] 'save-buffer) (global-set-key [f3] 'find-file) (global-set-key [f4] 'kill-this-buffer) (global-set-key [f10] 'indent-region) (global-set-key [f12] 'font-lock-fontify-buffer) (global-set-key [f9] 'compile) (global-set-key [(control z)] 'undo) (global-set-key [(meta g)] 'goto-line) ;; loadpath (setq load-path (cons (concat (concat "/home/" user-login-name) "/.emacs.d/ext/") load-path)) ;; Emacs server (Debian package: gnuserv) (cond ((fboundp 'gnuserv-start) (setq gnuserv-frame t) (gnuserv-start))) ;; Tramp (Transparent Remote Access, Multiple Protocol) (setq tramp-syntax 'url) (require 'tramp) ;; Mouse wheel support (mouse-wheel-mode t) ;; Scroll the *compilation* buffer window as output appears (setq compilation-scroll-output t) ;; Highlight the region when the mark is active (transient-mark-mode t) ;; Typed text replaces the selection if the selection is active (delete-selection-mode t) ;; Language stuffs (set-terminal-coding-system 'utf-8) (set-keyboard-coding-system 'utf-8) (set-language-environment 'utf-8) ;; Coding system for communicating with other X clients (setq selection-coding-system 'compound-text-with-extensions) ;; Inhibits the initial startup message (setq inhibit-startup-message t) ;; Hide the tool bar (tool-bar-mode 0) ;; No blinking cursor (blink-cursor-mode 0) ;; No truncate lines (setq truncate-partial-width-windows nil) ;; File ends in a newline when it is saved (setq require-final-newline t) ;; Automatic file compression and uncompression (auto-compression-mode t) ;; Allow to write "y" and "n" instead of "yes" and "no" (fset 'yes-or-no-p 'y-or-n-p) ;; Display the column et the line number in the mode line (column-number-mode t) (line-number-mode t) ;; Time format (setq display-time-24hr-format t) (setq display-time-day-and-date t) ;; Visible bell (flash the frame to represent a bell) instead audible bell (setq visible-bell t) ;; French dictionnary used by ispell (Debian packages: ispell, ifrench-gut) (setq ispell-dictionary "francais") ;; Turn on Font Lock mode (color syntax highlighting) automatically in all modes which support it (global-font-lock-mode t) ;; End of sentences (for M-a and M-e) (setq colon-double-space nil) (setq sentence-end-double-space nil) (setq sentence-end "[.?!][]\"»')}]*\\($\\| \\|\t\\)[ \t\n]*") ;; Highlight matching parenthesis (require 'paren) (show-paren-mode t) ;; Better buffer menu (require 'msb) (msb-mode 1) ;; Backup directory names ;; http://people.via.ecp.fr/~flo/2000/emacs-tut/ch-sec-some_cmds.html#s-sec-backup-files (setq backup-directory-alist '(("." . "~/.emacs.d/backup/"))) ;; Monday is the first day of the week (setq calendar-week-start-day 1) ;; European style of dates in the diary and in any displays (setq european-calendar-style t) ;; Show all the holidays that would appear in a complete Christiancalendar (setq all-christian-calendar-holiday t) ;; Default major mode is text-mode (setq default-major-mode 'text-mode) ;; Don't consider case significant in completion (setq completion-ignore-case t) ;; Tabs (setq-default indent-tabs-mode nil) ;; use spaces instead tabs ;; Pour l'impression avec les fonctions ps-print-buffer et ps-print-buffer-with-faces (setq ps-paper-type 'a4 ps-font-family 'Courier ps-font-size 10 ps-print-header nil ps-landscape-mode nil ;; Marge inferieure en points PostScript : (* 72 (/ 1.8 2.54)) = 1.8 cm ps-bottom-margin 51.02362204724409) ;; Pour n'avoir que le nom du buffer et /. (setq-default ps-header-lines 1) ;; Print friendly (defun ps-print-buffer2 () "Print buffer to PS file with the buffer filename." (interactive) (ps-print-buffer (concat (buffer-file-name) ".ps"))) ;; Minor mode to highlight the line about point in the current window. ;;(global-hl-line-mode t) ;; Number of lines to try scrolling a window by when point moves out. (0 => middle) (setq scroll-step 0) ;; Default fontload (set-default-font "-adobe-courier-medium-r-*-*-14-*-*-*-*-*-iso8859-1") ;; Access to recent files (when (require 'recentf) (setq recentf-auto-cleanup 'never) ; avoid to check distant files (recentf-mode 1)) ;; Term mode ;; (setq term-default-bg-color "black") ;; Saving Emacs Sessions ;; (desktop-load-default) ;; (desktop-read) ;; Info mode enhancement ;;(eval-after-load "info" '(require 'info+)) ;; Web developpement ;;(load "web.el") ;; Colors ;; ------ ;;(set-face-background 'region "SteelBlue") (set-face-background 'highlight "honeydew1") ;; (add-hook 'term-mode-hook ;; (function ;; (lambda () ;; (set-face-foreground 'term-default-bg-inv "white") ;; (set-face-background 'term-default-bg-inv "gray60") ;; (set-face-foreground 'term-bold "orange") ;; (set-face-underline-p 'term-underline nil) ;; (set-face-foreground 'term-underline "lightslategrey") ;; (set-face-bold-p 'term-underline t) ;; (setq term-prompt-regexp "^[^#$%>\n]*[#$%>] *\\|^[<]*[>]") ;; (make-local-variable 'mouse-yank-at-point) ;; (make-local-variable 'transient-mark-mode) ;; (setq transient-mark-mode nil) ;; (auto-fill-mode -1) ;; (setq tab-width 8 )))) ;; ecb, cedet, semantic ;; -------------------- ;; Directory name where semantic cache files are stored (setq semanticdb-default-save-directory "~/.emacs.d/semantic.cache/") ;; revive.el and windows.el ;; ------------------------ (autoload 'save-current-configuration "revive" "Save status" t) (autoload 'resume "revive" "Resume Emacs" t) (autoload 'wipe "revive" "Wipe Emacs" t) ;; key bindings (define-key ctl-x-map "S" 'save-current-configuration) (define-key ctl-x-map "F" 'resume) (define-key ctl-x-map "K" 'wipe) (setq revive:major-mode-command-alist-private '((your-own-mode . your-own) ("*Inferior Octave*" . run-octave) ("*Hanoi*" . hanoi))) ;; Latex ;; ----- (defun my-latex-hook () (turn-on-reftex) (flyspell-mode) (TeX-PDF-mode) ) (add-hook 'latex-mode-hook 'my-latex-hook) (add-hook 'LaTeX-mode-hook 'my-latex-hook) ;; Make AUCTeX aware of style files and multi-file documents right away (View AUCTex manual) (setq TeX-auto-save t) (setq TeX-parse-self t) (setq-default TeX-master nil) ;; Octave ;; ------ ;; Use Matlab mode instead of Octave mode to edit .m files (autoload 'matlab-mode "matlab" "Enter MATLAB mode." t) (setq auto-mode-alist (cons '("\\.m\\'" . matlab-mode) auto-mode-alist)) (autoload 'matlab-shell "matlab" "Interactive MATLAB mode." t) ;; Use Octave mode to edit .m files ;; (autoload 'octave-mode "octave-mod" nil t) ;; (setq auto-mode-alist ;; (cons '("\\.m$" . octave-mode) auto-mode-alist)) (defun RET-behaves-as-LFD () (let ((x (key-binding "\C-j"))) (local-set-key "\C-m" x))) (add-hook 'octave-mode-hook (lambda () (RET-behaves-as-LFD) (setq comment-column 32) (setq octave-comment-char ?%) (abbrev-mode 1) (auto-fill-mode 1) (if (eq window-system 'x) (font-lock-mode 1)) ;; Do not indent after the keyword "function" (delete "function" octave-begin-keywords) (setq octave-block-begin-regexp (concat "\\<\\(" (mapconcat 'identity octave-begin-keywords "\\|") "\\)\\>")) (delete "endfunction" octave-end-keywords) (setq octave-block-end-regexp (concat "\\<\\(" (mapconcat 'identity octave-end-keywords "\\|") "\\)\\>")) (local-set-key [?\C-\M-\;] '(lambda () (interactive) (insert "%% ") )) )) (add-hook 'inferior-octave-mode-hook (lambda() (turn-on-font-lock) ;; Cycle backward through command history (local-set-key [up] '(lambda () (interactive) (if (> (point-max) (point)) (goto-char (point-max)) (comint-previous-input 1) ) )) ;; Cycle forward through command history (local-set-key [down] '(lambda () (interactive) (if (> (point-max) (point)) (goto-char (point-max)) (comint-next-input 1) ) )) )) ;; Maxima ;; ------ (autoload 'maxima-mode "maxima" "Maxima mode" t) (autoload 'maxima "maxima" "Maxima interaction" t) (setq auto-mode-alist (cons '("\\.mac" . maxima-mode) auto-mode-alist)) ;; C/C++ ;; ----- ;; Some useful things (fset 'c-insert-braces [?\C-e ?{ return ?} up ?\C-e]) (defun c-insert-parentheses2() (interactive) (insert "()") (backward-char) (c-insert-spaces)) (defun c-insert-quotes() (interactive) (insert "\"\"") (backward-char)) (defun c-insert-brackets() (interactive) (insert "[]") (backward-char)) (defun c-insert-equal() (interactive) (insert " = ")) (defun c-insert-spaces() (interactive) (insert " ") (backward-char)) (defun c-source() (interactive) (insert-file "~/.emacs.d/templates/c-source.c")) (defun c-header() (interactive) (insert-file "~/.emacs.d/templates/c-header.h")) (defun c-comments-bold() (interactive) (insert-file "~/.emacs.d/templates/c-comments-bold.c")) (defun c-comments-separation() (interactive) (insert-file "~/.emacs.d/templates/c-comments-separation.c")) (defun point-to-register2() (interactive) (point-to-register 'p)) (defun register-to-point2() (interactive) (register-to-point 'p)) (defun c-c++-macros () (local-set-key [?\s-{] 'c-insert-braces) (local-set-key [?\s-(] 'c-insert-parentheses2) (local-set-key [?\s-\"] 'c-insert-quotes) (local-set-key [?\s-[] 'c-insert-brackets) (local-set-key [?\s-=] 'c-insert-equal) (local-set-key [?\s-\ ] 'c-insert-spaces) (local-set-key [?\s-s] 'c-source) (local-set-key [?\s-h] 'c-header) (local-set-key [?\s-c ?b] 'c-comments-bold) (local-set-key [?\s-c ?f] 'c-comments-function) (local-set-key [?\s-c ?F] 'c-comments-file) (local-set-key [?\s-c ?s] 'c-comments-separation) (local-set-key [?\s-p] 'point-to-register2) (local-set-key [?\s-P] 'register-to-point2) ) (add-hook 'c-mode-hook 'c-c++-macros) (add-hook 'c++-mode-hook 'c-c++-macros) ;; This is a way to hook tempo into cc-mode (defvar c-tempo-tags nil "Tempo tags for C mode") (defvar c++-tempo-tags nil "Tempo tags for C++ mode") ;;; C-Mode Templates and C++-Mode Templates (uses C-Mode Templates also) (require 'tempo) (setq tempo-interactive t) (add-hook 'c-mode-hook '(lambda () (local-set-key [f11] 'tempo-complete-tag) (tempo-use-tag-list 'c-tempo-tags) )) (add-hook 'c++-mode-hook '(lambda () (local-set-key [f11] 'tempo-complete-tag) (tempo-use-tag-list 'c-tempo-tags) (tempo-use-tag-list 'c++-tempo-tags) )) ;;; Preprocessor Templates (appended to c-tempo-tags) (tempo-define-template "c-include" '("include <" r ".h>" > n ) "include" "Insert a #include <> statement" 'c-tempo-tags) (tempo-define-template "c-define" '("define " (s clause) n> p n ) "define" "Insert a #define statement" 'c-tempo-tags) (tempo-define-template "c-ifdef" '("ifdef " (p "ifdef-clause: " clause) > n> p n "#else /* !(" (s clause) ") */" n> p n "#endif /* " (s clause)" */" n> ) "ifdef" "Insert a #ifdef #else #endif statement" 'c-tempo-tags) (tempo-define-template "c-ifndef" '("ifndef " (p "ifndef-clause: " clause) > n "#define " (s clause) n> p n "#endif /* " (s clause)" */" n> ) "ifndef" "Insert a #ifndef #define #endif statement" 'c-tempo-tags) ;;; C-Mode Templates (tempo-define-template "c-if" '(> "if (" (p "if-clause: " clause) ")" n> "{" > n> > r n "}" > n> ) "if" "Insert a C if statement" 'c-tempo-tags) (tempo-define-template "c-else" '(> "else" n> "{" > n> > r n "}" > n> ) "else" "Insert a C else statement" 'c-tempo-tags) (tempo-define-template "c-if-else" '(> "if (" (p "if-clause: " clause) ")" n> "{" > n > r n "}" > n "else" > n "{" > n> > r n "}" > n> ) "ifelse" "Insert a C if else statement" 'c-tempo-tags) (tempo-define-template "c-while" '(> "while (" (p "while-clause: " clause) ")" > n> "{" > n > r n "}" > n> ) "while" "Insert a C while statement" 'c-tempo-tags) (tempo-define-template "c-for" '(> "for (" (p "for-clause: " clause) ")" > n> "{" > n > r n "}" > n> ) "for" "Insert a C for statement" 'c-tempo-tags) (tempo-define-template "c-for-i" '(> "for (" (p "variable: " var) " = 0; " (s var) " < "(p "upper bound: " ub)"; " (s var) "++)" > n> "{" > n > r n "}" > n> ) "fori" "Insert a C for loop: for(x = 0; x < ..; x++)" 'c-tempo-tags) (tempo-define-template "c-main" '(> "int main(int argc, char *argv[])" > n> "{" > n> > r n > "return 0 ;" n> > "}" > n> ) "main" "Insert a C main statement" 'c-tempo-tags) (tempo-define-template "c-if-malloc" '(> (p "variable: " var) " = (" (p "type: " type) " *) malloc (sizeof(" (s type) ") * " (p "nitems: " nitems) ") ;" n> > "if (" (s var) " == NULL)" n> > "error_exit (\"" (buffer-name) ": " r ": Failed to malloc() " (s var) " \") ;" n> ) "ifmalloc" "Insert a C if (malloc...) statement" 'c-tempo-tags) (tempo-define-template "c-if-calloc" '(> (p "variable: " var) " = (" (p "type: " type) " *) calloc (sizeof(" (s type) "), " (p "nitems: " nitems) ") ;" n> > "if (" (s var) " == NULL)" n> > "error_exit (\"" (buffer-name) ": " r ": Failed to calloc() " (s var) " \") ;" n> ) "ifcalloc" "Insert a C if (calloc...) statement" 'c-tempo-tags) (tempo-define-template "c-switch" '(> "switch (" (p "switch-condition: " clause) ")" n> "{" > n> "case " (p "first value: ") ":" > n> p n "break;" > n> p n "default:" > n> p n "break;" > n "}" > n> ) "switch" "Insert a C switch statement" 'c-tempo-tags) (tempo-define-template "c-case" '(n "case " (p "value: ") ":" > n> p n "break;" > n> p ) "case" "Insert a C case statement" 'c-tempo-tags) (tempo-define-template "c++-class" '("class " (p "classname: " class) p > n> " {" > n "public:" > n "" > n "protected:" > n "" > n "private:" > n "" > n "};" > n ) "class" "Insert a class skeleton" 'c++-tempo-tags) (defconst my-c-style '((c-tab-always-indent . t) (c-comment-only-line-offset . 0) (c-hanging-braces-alist . ( ;; brace that opens a function definition (defun-open before after) ;; brace that closes a function definition (defun-close before) ;; the first line in a top-level defun (defun-block-intro before) ;; brace that opens a class definition (class-open before) ;; brace that closes a class definition (class-close before) ;; brace that opens an in-class inline method (inline-open) ;; brace that closes an in-class inline method (inline-close before) ;; statement block open brace (block-open before) ;; statement block close brace (block-close before) ;; open brace of an enum or static array list (brace-list-open) ;; close brace of an enum or static array list (brace-list-close before) ;; first line in an enum or static array list (brace-list-intro before) ;; the first line in a case block starting with brace (statement-case-open before) ;; a C statement (statement before after) ;; the first line after a conditional (substatement before) ;; the brace that opens a substatement block (substatement-open before after) ;; the `else' of an `if'-`else' construct (else-clause before) ;; brace that opens an external language block (extern-lang-open before) ;; brace that closes an external language block (extern-lang-close before) ;; brace that opens a C++ namespace block. (namespace-open before) ;; brace that closes a C++ namespace block. (namespace-close before) )) (c-hanging-colons-alist . ( (member-init-intro before) (inher-intro) (case-label after) (label after) (access-label after) )) (c-cleanup-list . (scope-operator empty-defun-braces defun-close-semi)) ;; note: C-c C-s shows syntactic information (c-offsets-alist . ( ;; inside multi-line string ;(string . c-lineup-dont-change) ;; inside a multi-line C style block comment ;(c . c-lineup-C-comments) ;; brace that opens a function definition (defun-open . 0) ;; brace that closes a function definition (defun-close . 0) ;; the first line in a top-level defun (defun-block-intro . 2) ;; brace that opens a class definition ;(class-open . 0) ;; brace that closes a class definition ;(class-close . 0) ;; brace that opens an in-class inline method ;(inline-open . 0) ;; brace that closes an in-class inline method ;(inline-close . 0) ;; the region between a function definition's ;; argument list and the function opening brace (excluding K&R ;; argument declarations). In C, you cannot put anything but ;; whitespace and comments between them; in C++ and Java, `throws' ;; declarations and other things can appear in this context. ;(func-decl-cont . +) ;; first line of a K&R C argument declaration ;(knr-argdecl-intro . 5) ;; subsequent lines in a K&R C argument declaration ;(knr-argdecl . 0) ;; the first line in a topmost definition ;(topmost-intro . 0) ;; topmost definition continuation lines ;(topmost-intro-cont . 0) ;; first line in a member initialization list ;(member-init-intro . +) ;; subsequent member initialization list lines ;(member-init-cont . 0) ;; first line of a multiple inheritance list ;(inher-intro . +) ;; subsequent multiple inheritance lines ;(inher-cont . c-lineup-multi-inher) ;; statement block open brace (block-open . 0) ;; statement block close brace (block-close . 0) ;; open brace of an enum or static array list (brace-list-open . 0) ;; close brace of an enum or static array list (brace-list-close . 0) ;; first line in an enum or static array list ;(brace-list-intro . +) ;; subsequent lines in an enum or static array list ;(brace-list-entry . 0) ;; a C statement ;(statement . 0) ;; a continuation of a C statement ;(statement-cont . +) ;; the first line in a new statement block (statement-block-intro . 2) ;; the first line in a case `block' ;(statement-case-intro . +) ;; the first line in a case block starting with brace ;(statement-case-open . +) ;; the first line after a conditional ;(substatement . +) ;; the brace that opens a substatement block (substatement-open . 0) ;; a case or default label (case-label . +) ;; C++ access control label ;(access-label . -) ;; any non-special C label ;(label . 0) ;; the `while' that ends a `do'-`while' construct ;(do-while-closure . 0) ;; the `else' of an `if'-`else' construct ;(else-clause . 0) ;; a line containing only a comment introduction ;(comment-intro . c-lineup-comment) ;; the first line in an argument list ;(arglist-intro . c-lineup-arglist-intro-after-paren) ;; subsequent argument list lines when no arguments ;; follow on the same line as the the arglist opening paren ;(arglist-cont . 0) ;; subsequent argument list lines when at ;; least one argument follows on the same line as the arglist opening ;; paren ;(arglist-cont-nonempty . c-lineup-arglist) ;; the solo close paren of an argument list ;(arglist-close . c-lineup-arglist) ;; lines continuing a stream operator ;(stream-op . c-lineup-streamop) ;; the line is nested inside a class definition ;(inclass . +) ;; the start of a C preprocessor macro definition ;(cpp-macro . -1000) ;; subsequent lines of a multi-line C ;; preprocessor macro definition ;(cpp-macro-cont . c-lineup-dont-change) ;; a C++ friend declaration ;(friend . 0) ;; the first line of an Objective-C method definition ;(objc-method-intro . -1000) ;; lines continuing an Objective-C method definition ;(objc-method-args-cont . c-lineup-ObjC-method-args) ;; lines continuing an Objective-C method call ;(objc-method-call-cont . c-lineup-ObjC-method-call) ;; brace that opens an external language block ;(extern-lang-open . 0) ;; brace that closes an external language block ;(extern-lang-close . 0) ;; analogous to `inclass' syntactic symbol, but ;; used inside external language blocks (e.g. `extern "C" {'). (inextern-lang . 0) ;; brace that opens a C++ namespace block. ;(namespace-open . 0) ;; brace that closes a C++ namespace block. ;(namespace-close . 0) ;; analogous to `inextern-lang' syntactic symbol, ;; but used inside C++ namespace blocks. ;(innamespace . +) ;; C++ template argument list continuations ;(template-args-cont . +) )) (c-echo-syntactic-information-p . t) ) "My C Programming Style") ;; Customizations for all of c-mode, c++-mode, and objc-mode (defun my-c-mode-common-hook () ;; add my personal style and set it for the current buffer (c-add-style "PERSONAL" my-c-style t) ;; offset customizations not in my-c-style (c-set-offset 'member-init-intro '++) ;; other customizations (setq tab-width 4 ;; this will make sure spaces are used instead of tabs indent-tabs-mode nil) ;; auto-newline and hungry-delete (c-toggle-hungry-state 1) (c-toggle-auto-state 1) ;; no newline after semicolon (setq c-hanging-semi&comma-criteria nil) ;; Hide/Show minor mode (hs-minor-mode 1) ;; Column to indent right-margin comments to (setq comment-column 0) ;; keybindings for all supported languages. We can put these in ;; c-mode-base-map because c-mode-map, c++-mode-map, objc-mode-map, ;; java-mode-map, and idl-mode-map inherit from it. (define-key c-mode-base-map "\C-m" 'newline-and-indent) ) (add-hook 'c-mode-common-hook 'my-c-mode-common-hook) ;; Custom ;; ------ (custom-set-variables ;; custom-set-variables was added by Custom -- don't edit or cut/paste it! ;; Your init file should contain only one such instance. '(ecb-options-version "2.27") '(ecb-tip-of-the-day nil)) (custom-set-faces ;; custom-set-faces was added by Custom -- don't edit or cut/paste it! ;; Your init file should contain only one such instance. )