;; these are standard headers needed to keep emacs quiet (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. ) (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. ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; ;; DEFAULT SETTINGS ;; ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (message "setting new default configuration") ;; To highlight during search / replace (setq-default query-replace-highlight t) (setq-default search-highlight t) (setq-default auto-fill-mode t) (setq-default c-tab-always-indent nil) (setq-default calendar-date-display-form (quote ((if dayname (concat dayname " ")) day " " monthname " " year))) (setq-default case-fold-search t) (setq-default column-number-mode t) (setq-default current-language-environment "French") (setq-default default-input-method "latin-1-prefix") (setq-default indent-tabs-mode nil) (setq-default line-number-mode t) (setq-default standard-indent 3) (setq-default c-basic-offset 3) (setq-default tab-always-indent nil) (setq-default indent-tabs-mode nil) ;; no toolbar (setq toolbar-visible-p nil) ;; display active region (setq transient-mark-mode t) ;; only one C-k is needed to erase a ligne (setq kill-whole-line t) (setq default-tab-width 2) (show-paren-mode t) (setq calendar-week-start-day 1) (setq view-calendar-holidays-initially nil) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; ;; HOME BREWED ;; ;; FUNCTIONS ;; ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (message "creating some home-brewed functions") (defun bruce-template () "remet en frome correctement" (interactive) (delete-other-windows) (split-window-horizontally) (split-window-vertically) (split-window-vertically) (other-window) (other-window) (other-window) (split-window-vertically)) (defun bruce-encadre-bloc-util (begin end style) "encadre un bloc" (interactive "*ddx") (let* ((entering (car style)) (closing (cadr style)) (cadre (car (cddr style))) (content ()) (rendu ()) (debut-suppression 0) (end-suppression 0) (start begin) ) (goto-char end) (setq end-suppression (point-at-eol)) (goto-char begin) (setq debut-suppression (point-at-bol)) (while (< start end) (let* ((debut-contenu ((lambda () (goto-char (point-at-bol)) (search-forward-regexp "\\b")))) (fin-contenu ((lambda () (goto-char (point-at-eol)) (search-backward-regexp "\\b")))) (contenu (buffer-substring debut-contenu fin-contenu))) (setq content (cons contenu content))) (setq start (+ (point-at-eol) 1)) (forward-line 1)) (let* ((taille-beg (length entering)) (taille-end (length closing)) (pleine (concat entering (make-string (- fill-column (+ taille-beg taille-end)) cadre) closing "\n")) (vide (concat entering (make-string 1 cadre) (make-string (- fill-column (+ taille-beg taille-end 2)) 32) (make-string 1 cadre) closing "\n"))) (setq rendu (cons pleine rendu)) (setq rendu (cons vide rendu)) (while (setq line (car content)) (let* ((avant (/ (- fill-column (+ (+ taille-beg taille-end 2) (length line))) 2)) (apres (- fill-column (+ (+ taille-beg taille-end 2) (length line ) avant))) (interet (concat entering (make-string 1 cadre) (make-string avant 32) line (make-string apres 32) (make-string 1 cadre) closing "\n"))) (setq content (cdr content)) (setq rendu (cons interet rendu)))) (setq rendu (cons vide rendu)) (setq rendu (cons pleine rendu))) (delete-region debut-suppression end-suppression) (while (setq line (car rendu)) (setq rendu (cdr rendu)) (insert line)))) (defun bruce-intelligent-encadre (style) "supprime la sélection ou si rien n'est sélectionné, le caractère courant" (interactive "*x") (if (and mark-active transient-mark-mode) (let ((beg (min (point) (mark))) (end (max (point) (mark)))) (bruce-encadre-bloc-util beg end style)) (bruce-encadre-bloc-util (point-at-bol) (point-at-eol) style))) (defun set-frame-icon (icon-file &optional frame) "Set the icon for the given frame. If no frame is given the current frame is used" (interactive) (modify-frame-parameters (or frame (selected-frame)) (list (cons 'icon-type icon-file)))) (defun bruce-insert-buffer-file-name () "insère le nom du buffer courant" (interactive) (insert (file-name-nondirectory buffer-file-name)) ) (defun bruce-intelligent-delete () "supprime la sélection ou si rien n'est sélectionné, le caractère courant" (interactive) (if (and mark-active transient-mark-mode) (let ((beg (min (point) (mark))) (end (max (point) (mark)))) (delete-region beg end )) (delete-char 1))) (global-unset-key [(control d)]) (global-set-key [(control d)] 'bruce-intelligent-delete) (defun bruce-intelligent-comment () (interactive ) (if (and mark-active transient-mark-mode) (let ((beg (min (point) (mark))) (end (max (point) (mark)))) (comment-region beg end )) (let ((beg (line-beginning-position)) (end (line-end-position))) (comment-region beg end )))) (defun bruce-toggle-html-php () (interactive) (cond ((equal mode-name "HTML") (php-mode)) ((equal mode-name "PHP") (html-mode))) (font-lock-fontify-buffer) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; ;; SPECIFIC MODES AND REQUIRES ;; ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (message "loading some modules and setting fonctionalities") ;; keep trace of opened files (require 'recentf) (recentf-mode t) ;; keep session (load "desktop") (setq desktop-enable t) ;; start "clean" > without startup message (setq inhibit-startup-message t) ;; use case sensitive abbreviation for dabbrev mode (setq case-fold-search nil) (setq dabbrev-case-replace nil) ;; always ask with "y or n" instead of "yes or no" (fset 'yes-or-no-p 'y-or-n-p) ;;on a windowed system (X or windows), C-z acts as undo instead of "set in background" (when window-system (global-unset-key "\C-z") (global-set-key "\C-z" 'undo)) ;; auto-update buffers when visited files are modified (global-auto-revert-mode t) ;; use syntax enlightment (font-lock-mode t) ;; no useless menu (menu-bar-mode -1) ;; needed to print (require 'ps-print) (setq ps-paper-type 'a4) ;; 'zonage', usefull to avoid an undesired look on your screen (require 'zone) (setq zone-idle 90) (setq zone-program '(zone-pgm-jitter zone-pgm-putz-with-case zone-pgm-dissolve zone-pgm-whack-chars zone-pgm-rotate zone-pgm-rotate-LR-lockstep zone-pgm-rotate-RL-lockstep zone-pgm-rotate-LR-variable zone-pgm-rotate-RL-variable zone-pgm-drip zone-pgm-drip-fretfully zone-pgm-paragraph-spaz zone-pgm-stress)) ;; only one of the following lines should be uncommented ;;(zone-when-idle zone-idle) (zone-leave-me-alone) ;; remove toolbar (tool-bar-mode -1) ;; set syntax highlight (setq font-lock-maximum-decoration t) (global-font-lock-mode t) ;; resize minibuffer to be able to use it... ;;(setq resize-minibuffer-mode t) ;;(resize-minibuffer-mode) ;; Home made time display : time, date and week (setq display-time-format "%H:%M ~ %a %d %b ~ Sem %W") (display-time) ;; buffer name for status bar (setq frame-title-format (concat "Emacs ~ %b ~ %f ~ " system-name)) (setq icon-title-format "Emacs - %b") ;; use abbreviations (setq save-abbrevs t) (quietly-read-abbrev-file) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; ;; FUNCTION STUB ;; ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (message "creating functions stubs which may be overriden by specific code") (defun c-workstation-specific nil) (defun text-workstation-specific nil) (defun tex-workstation-specific nil) (defun java-workstation-specific nil) (defun sql-workstation-specific nil) (defun php-workstation-specific nil) (defun html-workstation-specific nil) (defun nxml-workstation-specific nil) (defun emacs-lisp-workstation-specific nil) (defun cperl-workstation-specific nil) (defun c-os-specific nil) (defun text-os-specific nil) (defun tex-os-specific nil) (defun java-os-specific nil) (defun sql-os-specific nil) (defun php-os-specific nil) (defun html-os-specific nil) (defun nxml-os-specific nil) (defun emacs-lisp-os-specific nil) (defun cperl-os-specific nil) (defun os-specific (a) nil) (defun workstation-specific (a) nil) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; ;; UNSETTING UNUSED KEYS ;; ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (global-unset-key [(control l)]) (global-unset-key [(meta g)]) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; ;; OS DEPENDANT CONFIGURATION ;; ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (message "OS Specific code") (cond ((string-match "i686-pc-linux" system-configuration) (message "customizing GNU Emacs for Linux") (load "~/lisp/specific-linux.el") ) ((string-match "nt" system-configuration) (message "customizing GNU Emacs for Win NT") (load "~/lisp/specific-nt.el") ) (t (message "unhandled os, change .emacs if you wan't a specific behaviour"))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; ;; WORKSTATION OS DEPENDANT CONFIGURATION ;; ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (message "Workstation Specific code") (cond ((string-match "PC3737" system-name) (message "~Taff Nagra Secure~") (load "~/lisp/specific-nagra-secure.el") ) ((string-match "PC2397" system-name) (message "~Taff Nagra Corporate~") (load "~/lisp/specific-nagra-corporate.el") ) ((string-match "GVAW" system-name) (message "~Taff BNP~") (load "~/lisp/specific-bnp.el") ) ((string-match "tortue" system-name) (message "~Gateway~") (load "~/lisp/specific-maison.el")) ((string-match "TOUTNOIR" system-name) (message "~PC sous windows de la maison~") (load "~/lisp/specific-maison2.el")) (t (message "~Default configuration~") (message "> No workstation setting") )) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; ;; KEYS BINDINGS ;; ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (message "Setting global keys bindings") (global-set-key [f1] 'describe-bindings) (global-set-key [C-f1] 'apropos) (global-set-key [S-f1] 'recentf-open-files) (global-set-key [(M-f1)] 'woman) ;; f2 cancels last modification and reverts to file written on disk (global-set-key [f2] 'revert-buffer) (global-set-key [C-f2] 'vc-annotate) ;; Use f3 like in many windows apps : F3 search forward, c-f3, search backward (global-set-key [f3] 'isearch-forward) (global-set-key [C-f3] 'isearch-backward) (global-set-key [S-f3] (lambda () "" (interactive) (set-mark-command 1))) (global-set-key [f4] 'call-last-kbd-macro) (global-set-key [C-f4] 'inverse-add-mode-abbrev) (global-set-key [f5] 'compile) (global-set-key [S-f5] 'kill-compilation) ;; C-f5 recomputes syntax highlight for current buffer (global-set-key [C-f5] 'font-lock-fontify-buffer) (global-set-key [f6] 'ediff-buffers) (global-set-key [C-f6] 'ediff-revision) ;; prefix f7 is used to prefix operations in block mode (global-set-key [(f7) (control y)] 'yank-rectangle) (global-set-key [(f7) (control k)] 'kill-rectangle) (global-set-key [(f7) (control d)] 'delete-rectangle) (global-set-key [(f7) (insert)] 'string-insert-rectangle) (global-set-key [f8] 'bookmark-bmenu-list) (global-set-key [C-f8] 'bookmark-set) (global-set-key [M-f8] 'list-buffers) ;; These are really 2 shortcuts wasted (global-set-key [f9] 'next-error) (global-set-key [C-f9] 'zone-leave-me-alone) (global-set-key [M-f9] 'zone) ;; do we REALLY need this ? (global-set-key [f11] 'calendar) (global-set-key [C-f11] 'calculator) ;; f12 (global-set-key [(M-f12)] 'kill-buffer) (global-set-key [(f12)] 'other-window) (global-set-key [(C-f12)] 'shell) ;; C-Tab is used like in windows, to switch between different buffers (global-set-key [C-tab] 'bury-buffer) (global-set-key [(meta p)] 'dabbrev-completion) (global-set-key [(control c) (control u) (control c)] 'uncomment-region) ;; M-g pour aller vers une ligne (global-set-key [(meta g)] 'goto-line) ;; raccourci standard : centrer la page, pas utilisé (global-set-key [(control l) (control c)] 'flyspell-check-previous-highlighted-word) (global-set-key [(control l) (t)] 'nagra-log-cvs) (global-set-key [(control l) (f) (r)] 'fill-region) (global-set-key [(control c) (control c)] 'bruce-intelligent-comment) (global-set-key [(control meta up)] 'bs-cycle-next) (global-set-key [(control meta down)] 'bs-cycle-previous) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; ;; SKELETONS ;; ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (message "defining some strange skeletons") ;; I assume their existence and usage is useless, but I keep them in name of ;; nostalgy (define-skeleton web-index-entry "template of an index entry" "" "

" vt " : " "\n" "

\n" ) (define-skeleton bruce-c-fixme "template d'un commentaire cvs" nil "/* FIXME (FRE) : " (setq vt (skeleton-read "Entry? ")) " */ \n" _ ) (define-skeleton nagra-log-cvs "template d'un commentaire cvs" nil "PRMS ID: " (setq vt (skeleton-read "Entry? ")) (upcase-word -1) "\n" "- "_ "\n" ) ;; tst, non encore utilisé à ce jour (define-skeleton java-main "template de la fonction main en java" nil \n > "public static void main (String[] arg){" \n > _ "}" \n > ) (define-skeleton bruce-java-doc "template de commentaire javadoc" nil \n > "/**" \n > "* " _ > \n > "*/" > ) (define-skeleton bruce-insert-links "template de lien du site web " nil "insert into skel_links values ('"_ "','','',3,0,'fr');" ) (define-skeleton nagra-insert-header "header nagra" nil "/**" \n " ** @brief" > \n " * "_ > \n " * @pre" > \n " * "_ > \n " *" > \n " * @post" > \n " * "_ > \n " *" > \n " * @param" > \n " * "_ > \n " *" > \n " * @return "_ > \n " */" ) (define-skeleton xml-semicolon "" nil " :" ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; ;; HOOKS ;; ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (autoload 'ansi-color-for-comint-mode-on "ansi-color" nil t) (message "Defining mode specific behaviour") ;; search mode (add-hook 'isearch-mode-hook (function (lambda () (define-key isearch-mode-map [f3] 'isearch-repeat-forward) (define-key isearch-mode-map [C-f3] 'isearch-repeat-backward) ))) ;; c-mode (add-hook 'c-mode-hook (function (lambda () (setq indent-tabs-mode nil) (auto-fill-mode t) (define-key c-mode-map [(control c) (control j) (r)] "@return ") (define-key c-mode-map [(control c) (control j) (p)] "@param ") (define-key c-mode-map [(control c) (control j) (b)] "@brief ") (define-key c-mode-map [(control c) (control i)] 'indent-region) (define-key c-mode-map [(control c) (f)] 'bruce-insert-buffer-file-name) (define-key c-mode-map [(control c) (control c)] 'bruce-intelligent-comment) (define-key c-mode-map [(control d)] 'bruce-intelligent-delete) (define-key c-mode-map [(control c)(e)] (lambda () nil (interactive) (bruce-intelligent-encadre (list "/" "/" ?*)))) (define-key c-mode-map [(control c)(r)] (lambda () nil (interactive) (bruce-intelligent-encadre (list "/*" "*/" ?#)))) (os-specific c-mode-map) (workstation-specific c-mode-map) (c-os-specific) (c-workstation-specific) ))) ;; text mode (add-hook 'text-mode-hook (lambda () (abbrev-mode t) (auto-fill-mode t) ;; (flyspell-mode t) (os-specific text-mode-map) (workstation-specific text-mode-map) (text-os-specific) (text-workstation-specific) (define-key text-mode-map [(control c)(e)] (lambda () nil (nteractive) (bruce-intelligent-encadre (list "" "" ?*)))) )) ;; (La)Tex mode (add-hook 'tex-mode-hook (function (lambda () (abbrev-mode t) (os-specific tex-mode-map) (workstation-specific tex-mode-map) (tex-os-specific) (tex-workstation-specific) ))) ;; java mode ;; java (add-hook 'java-mode-hook (function (lambda () (define-key java-mode-map [(control c) (control c)] 'bruce-intelligent-comment) (define-key java-mode-map [(control c) (control j) (r)] "@return ") (define-key java-mode-map [(control c) (control j) (p)] "@param ") (define-key java-mode-map [(control c) (control j) (a)] "@author ") (define-key java-mode-map [(control c) (control j) (v)] "@version ") (define-key java-mode-map [(control c) (control j) (t)] "true si tout est ok ") (define-key java-mode-map [(control c) (control j) (e)] '"/**\n * \n * @author Florent REVELUT\n * @version Developpement \n */\n") (define-key java-mode-map [(control c) (control j) (control j)] 'bruce-java-doc) (define-key java-mode-map [(control d)] 'bruce-intelligent-delete) (os-specific java-mode-map) (workstation-specific java-mode-map) (java-os-specific) (java-workstation-specific) ))) ;; sql mode (add-hook 'sql-mode-hook (function (lambda () (define-key sql-mode-map [(control c) (b)] 'sql-set-sqli-buffer) (define-key sql-mode-map [(control c) (control y)] 'bruce-insert-links) (os-specific sql-mode-map) (workstation-specific sql-mode-map) (sql-os-specific) (sql-workstation-specific) ))) ;; php mode (add-hook 'php-mode-user-hook (function (lambda () (define-key php-mode-map [(f2)] 'bruce-toggle-html-php) (define-key php-mode-map [(f5)] 'font-lock-fontify-buffer) (os-specific php-mode-map) (workstation-specific php-mode-map) (php-os-specific) (php-workstation-specific) ))) ;; html-mode (add-hook 'html-mode-hook (function (lambda () (define-key html-mode-map [(f2)] 'bruce-toggle-html-php) (define-key html-mode-map [(f5)] 'font-lock-fontify-buffer) (os-specific html-mode-map) (workstation-specific html-mode-map) (html-os-specific) (html-workstation-specific) ))) ;; nxml mode (add-hook 'nxml-mode-hook (function (lambda () (abbrev-mode t) (os-specific nxml-mode-map) (workstation-specific nxml-mode-map) (nxml-os-specific) (nxml-workstation-specific) (flyspell-mode nil) (auto-fill-mode t) (define-key nxml-mode-map [(:)] (lambda () nil (interactive) (insert " : "))) (define-key nxml-mode-map [(\?)] (lambda () nil (interactive) (insert " ? "))) (define-key nxml-mode-map [(\!)] (lambda () nil (interactive) (insert " ! "))) (define-key nxml-mode-map [(\;)] (lambda () nil (interactive) (insert " ; "))) (define-key nxml-mode-map [(apps) ?\ ] (lambda () nil (interactive) (insert " "))) (define-key nxml-mode-map [(apps) ?- ] (lambda () nil (interactive) (insert "—"))) (define-key nxml-mode-map [(apps) ?< ] (lambda () nil (interactive) (insert "<"))) (define-key nxml-mode-map [(apps) ?> ] (lambda () nil (interactive) (insert ">"))) ))) ;; elisp mode (add-hook 'emacs-lisp-mode-hook (function (lambda () (abbrev-mode t) (define-key emacs-lisp-mode-map [(control c)(e)] (lambda () nil (interactive) (bruce-intelligent-encadre (list ";" ";" ?;)))) (define-key emacs-lisp-mode-map [(control c)(tab)] 'indent-region) (os-specific emacs-lisp-mode-map) (workstation-specific emacs-lisp-mode-map) (emacs-lisp-os-specific) (emacs-lisp-workstation-specific) ))) ;; CPerl mode (add-hook 'cperl-mode-hook (function (lambda () (abbrev-mode t) (define-key cperl-mode-map [(control c)(e)] (lambda () nil (interactive) (bruce-encadre-c ?# "" "" ))) (define-key cperl-mode-map [(f5)] 'perldb) (os-specific cperl-mode-map) (workstation-specific cperl-mode-map) (cperl-os-specific) (cperl-workstation-specific) ))) (add-hook 'perldb-mode-hook (function (lambda () (define-key gud-mode-map [(f10)] 'gud-step) (define-key gud-mode-map [(f11)] 'gud-next))))