3 (add-to-list 'load-path "~/.emacs.d/lisp/egg")
5 ;;; uncomment this line to disable loading of "default.el" at startup
6 ;; (setq inhibit-default-init t)
8 ;; enable visual feedback on selections
9 ;(setq transient-mark-mode t)
11 ;; default to better frame titles
12 (setq frame-title-format
13 (concat "%b - emacs@" (system-name)))
15 ;; default to unified diffs
16 (setq diff-switches "-u")
18 ;; always end a file with a newline
19 ;(setq require-final-newline 'query)
21 ;;; uncomment for CJK utf-8 support for non-Asian users
22 ;; (require 'un-define)
24 (set-background-color "black")
25 (set-foreground-color "grey")
26 (set-cursor-color "white")
27 (set-mouse-color "white")
29 (setq delete-auto-save-files t)
30 (setq inhibit-startup-message t)
35 (electric-indent-mode 0)
37 ;; (require 'color-theme)
39 ;; (color-theme-emacs-21)
40 ;; (color-theme-hober))
43 (set-frame-font "7x14")
46 (defun sd-mousewheel-scroll-up (event)
47 "Scroll window under mouse up by five lines."
49 (let ((current-window (selected-window)))
52 (select-window (posn-window (event-start event)))
54 (select-window current-window))))
56 (defun sd-mousewheel-scroll-down (event)
57 "Scroll window under mouse down by five lines."
59 (let ((current-window (selected-window)))
62 (select-window (posn-window (event-start event)))
64 (select-window current-window))))
66 (global-set-key (kbd "<mouse-5>") 'sd-mousewheel-scroll-up)
67 (global-set-key (kbd "<mouse-4>") 'sd-mousewheel-scroll-down)
69 ; Montrer la correspondance des parenthèses
70 ; (systématiquement et non seulement après la frappe)
73 (setq blink-matching-paren t)
74 (setq blink-matching-paren-on-screen t)
75 (setq blink-matching-paren-dont-ignore-comments t)
77 ; Afficher l'heure dans la barre d'état (format 24 heures)
78 (setq display-time-24hr-format t)
81 ; Nom en clair des jours et mois apparaissant dans le calendrier
82 (setq european-calendar-style t)
83 (setq calendar-week-start-day 1)
84 (defvar calendar-day-name-array
85 ["dimanche" "lundi" "mardi" "mercredi" "jeudi" "vendredi" "samedi"])
86 (defvar calendar-month-name-array
87 ["janvier" "février" "mars" "avril" "mai" "juin"
88 "juillet" "août" "septembre" "octobre" "novembre" "décembre"])
90 ; C'est fastidieux de taper « yes » pour confirmer, raccourcissons
91 ; cela à « y » (idem pour « no », désormais « n »).
92 (fset 'yes-or-no-p 'y-or-n-p)
95 (global-set-key [f2] 'egg-status)
96 (global-set-key [f3] 'cvs-status)
97 (global-set-key [f4] 'cvs-quickdir)
98 (global-set-key [f5] 'toggle-read-only)
99 (global-set-key [f6] 'goto-line)
100 (global-set-key [f7] 'rgrep)
101 (global-set-key [f8] 'revert-buffer)
102 (global-set-key [f9] 'compile)
103 (global-set-key [f10] 'next-error)
104 (global-set-key [f11] 'toggle-fill-mode)
105 (global-set-key [f12] 'toggle-whitespace-begin-space)
107 (global-set-key "\M-?" 'tags-search)
108 (global-set-key "\M-s" 'search-word)
109 (global-set-key (kbd "C-x <down>") 'rotate-windows)
112 ;; page up, page down
118 (global-set-key "\M-p" 'page-up)
119 (global-set-key "\M-n" 'page-down)
121 ;; Pour utiliser gnumake par defaut
123 (custom-set-variables
124 ;; custom-set-variables was added by Custom.
125 ;; If you edit it by hand, you could mess it up, so be careful.
126 ;; Your init file should contain only one such instance.
127 ;; If there is more than one, they won't work right.
128 '(compile-command "make")
129 '(ediff-split-window-function (quote split-window-horizontally))
130 '(ediff-window-setup-function (quote ediff-setup-windows-plain))
131 '(egg-buffer-hide-section-type-on-start nil)
132 '(egg-mode-key-prefix "C-x !")
133 '(rst-adornment-faces-alist (quote ((t . font-lock-keyword-face) (nil . font-lock-keyword-face) (nil . rst-level-1-face) (nil . rst-level-2-face) (nil . rst-level-3-face) (nil . rst-level-4-face) (nil . rst-level-5-face) (nil . rst-level-6-face))))
134 '(shell-file-name "/bin/bash")
135 '(vc-handled-backends (quote (RCS CVS SVN SCCS Bzr Hg Mtn Arch))))
137 ; Effacer tous les espaces en fin de ligne
138 (defun delete-trailing-spaces ()
139 "Effacer les espaces et tabulations en fin de chaque ligne du tampon"
144 (replace-regexp "[ \t]+$" "")
150 ; Conversion des fins de lignes du format MS-DOS au format Unix
153 (goto-char (point-min))
154 (while (search-forward "\r" nil t)
160 ; Conversion des fins de ligne du format Unix au format MS-DOS
163 (goto-char (point-min))
164 (while (search-forward "\n" nil t)
165 (replace-match "\r\n")
170 ; Montrer la table des caractères ASCII étendus
171 ; Fonction fournie par Alex Schroeder <asc@bsiag.com>
172 (defun ascii-table ()
173 "Afficher la table de caractères ASCII."
175 (switch-to-buffer "*ASCII*")
177 (insert (format "Caractères ASCII de code 1 à 254.\n"))
179 (while (< i 254) (setq i (+ i 1))
180 (insert (format "%4d %c\n" i i))
183 (beginning-of-buffer)
187 ; Activation des fonctions « upcase-region » et « downcase-region »
188 ; Ces fonctions sont désactivées par défaut sous Emacs 21 ; pourquoi ?
189 (put 'upcase-region 'disabled nil)
190 (put 'downcase-region 'disabled nil)
192 ; taille de la fenetre de compil
193 (setq compilation-window-height 15)
197 (defun my-build-tab-stop-list (width)
198 (let ((num-tab-stops (/ 80 width))
201 (while (<= counter num-tab-stops)
202 (setq ls (cons (* width counter) ls))
203 (setq counter (1+ counter)))
204 (set (make-local-variable 'tab-stop-list) (nreverse ls))))
206 ; from linux/Documentation/CodingStyle
208 (defun c-lineup-arglist-tabs-only (ignored)
209 "Line up argument lists by tabs, not spaces"
210 (let* ((anchor (c-langelem-pos c-syntactic-element))
211 (column (c-langelem-2nd-pos c-syntactic-element))
212 (offset (- (1+ column) anchor))
213 (steps (floor offset c-basic-offset)))
220 '("linux" (c-offsets-alist
221 (arglist-cont-nonempty
223 c-lineup-arglist-tabs-only))))
225 (add-hook 'c-mode-hook
227 (c-set-style "linux-tabs-only"))
230 (add-hook 'c-mode-common-hook
232 (font-lock-add-keywords nil
233 '(("\\<\\(FIXME\\|TODO\\|HACK\\|fixme\\|todo\\|hack\\|XXX\\)" 1
234 font-lock-warning-face t)))))
236 (defun set-indent-quagga ()
238 (setq c-basic-offset 2)
239 (setq tab-width 8 indent-tabs-mode nil)
242 (defun set-indent-xms ()
244 (setq c-basic-offset 4)
245 (setq tab-width 8 indent-tabs-mode nil)
248 (defun set-indent-std ()
250 (c-set-offset 'arglist-cont-nonempty 8)
251 (c-set-offset 'arglist-intro '+)
252 (c-set-offset 'arglist-close 0)
253 (setq c-basic-offset 8)
254 (setq tab-width 8 indent-tabs-mode 1)
258 (defun set-indent-dpdk ()
260 (c-set-offset 'arglist-cont-nonempty 16)
261 (c-set-offset 'arglist-intro '+)
262 (c-set-offset 'arglist-close 0)
263 (setq c-basic-offset 8)
264 (setq tab-width 8 indent-tabs-mode 1)
267 (defun toggle-whitespace-begin-space ()
269 (whitespace-toggle-options '(indentation::tab indentation))
273 '(sh-indent-after-function (quote -))
274 '(sh-indent-comment t)
276 ;; indentation of shell scripts
277 (defun set-sh-indent-8 ()
278 "My own personal preferences for `sh-mode'.
280 This is a custom function that sets up the parameters I usually
281 prefer for `sh-mode'. It is automatically added to
282 `sh-mode-hook', but is can also be called interactively."
284 (setq sh-basic-offset 8
286 sh-indent-comment t))
287 (add-hook 'sh-mode-hook 'set-sh-indent-8)
290 (defun set-sh-indent-4 ()
292 (setq sh-basic-offset 4
295 indent-tabs-mode nil))
298 ;; custom-set-faces was added by Custom.
299 ;; If you edit it by hand, you could mess it up, so be careful.
300 ;; Your init file should contain only one such instance.
301 ;; If there is more than one, they won't work right.
304 ;; (set-terminal-coding-system 'latin-9)
305 ;; (set-keyboard-coding-system 'latin-9)
306 ;; (set-language-environment 'latin-9)
308 (add-to-list 'kill-emacs-query-functions
309 (lambda () (y-or-n-p "Should Emacs really close? ")))
313 (define-key global-map [(control f3)] 'cscope-set-initial-directory)
314 (define-key global-map [(control f4)] 'cscope-unset-initial-directory)
315 (define-key global-map [(control f5)] 'cscope-find-this-symbol)
316 (define-key global-map [(control f6)] 'cscope-find-global-definition)
317 (define-key global-map [(control f7)] 'cscope-find-global-definition-no-prompting)
318 (define-key global-map [(control f8)] 'cscope-pop-mark)
319 (define-key global-map [(control f9)] 'cscope-next-symbol)
320 (define-key global-map [(control f10)] 'cscope-next-file)
321 (define-key global-map [(control f11)] 'cscope-prev-symbol)
322 (define-key global-map [(control f12)] 'cscope-prev-file)
323 (define-key global-map [(meta f9)] 'cscope-display-buffer)
324 (define-key global-map [(meta f10)] 'cscope-display-buffer-toggle)
325 ;(setq cscope-display-cscope-buffer nil)
329 "Simulate a :set nolist in Vi."
331 (standard-display-ascii ?\t "\t")
332 (standard-display-ascii ?\ "\ ") )
337 (insert "Signed-off-by: Olivier Matz <olivier.matz@6wind.com>")
343 (let ((string (read-string "Name: " nil 'my-history)))
344 (insert (shell-command-to-string (concat "acked-by.py " string))))
348 (defun sign-choice ()
351 (let ((string (read-string "Name: " nil 'my-history)))
352 (insert (shell-command-to-string (concat "acked-by.py -s " string))))
356 (defun toggle-fill-mode ()
357 "toggle fill mode between 72 and 80"
359 (if (<= fill-column 72)
360 (setq-default fill-column 80)
361 (setq-default fill-column 72)))
363 (defun rotate-windows-helper(x d)
364 (if (equal (cdr x) nil) (set-window-buffer (car x) d)
365 (set-window-buffer (car x) (window-buffer (cadr x))) (rotate-windows-helper (cdr x) d)))
367 (defun rotate-windows ()
369 (rotate-windows-helper (window-list) (window-buffer (car (window-list))))
370 (select-window (car (last (window-list)))))
372 ;; http://www.emacswiki.org/emacs/WhiteSpace
373 (require 'whitespace)
374 (global-whitespace-mode 1)
375 (setq whitespace-style '(face trailing lines-tail indentation::tab indentation
376 space-after-tab::tab space-after-tab::space
377 space-after-tab space-before-tab::tab
378 space-before-tab::space space-before-tab))
379 ;; for xms, remove indentation::tab and indentation
380 ;; (setq whitespace-style '(face trailing lines-tail
381 ;; space-after-tab::tab space-after-tab::space
382 ;; space-after-tab space-before-tab::tab
383 ;; space-before-tab::space space-before-tab))
386 (defun bf-pretty-print-xml-region (begin end)
387 "Pretty format XML markup in region. You need to have nxml-mode
388 http://www.emacswiki.org/cgi-bin/wiki/NxmlMode installed to do
389 this. The function inserts linebreaks to separate tags that have
390 nothing but whitespace between them. It then indents the markup
391 by using nxml's indentation rules."
396 (while (search-forward-regexp "\>[ \\t]*\<" nil t)
397 (backward-char) (insert "\n"))
398 (indent-region begin end))
399 (message "Ah, much better!"))
404 ; fill column to 80 when we use M-q
405 (setq-default fill-column 80)
407 ; to remove once fixed (make 4.0 compat)
408 (setq-default compilation-directory-matcher '("\\(?:Entering\\|Leavin\\(g\\)\\) directory [`']\\(.+\\)'$" (2 . 1)))