+;; .emacs
+
+(add-to-list 'load-path "~/.emacs.d/lisp/egg")
+
+;;; uncomment this line to disable loading of "default.el" at startup
+;; (setq inhibit-default-init t)
+
+;; enable visual feedback on selections
+;(setq transient-mark-mode t)
+
+;; default to better frame titles
+(setq frame-title-format
+ (concat "%b - emacs@" (system-name)))
+
+;; default to unified diffs
+(setq diff-switches "-u")
+
+;; always end a file with a newline
+;(setq require-final-newline 'query)
+
+;;; uncomment for CJK utf-8 support for non-Asian users
+;; (require 'un-define)
+
+(set-background-color "black")
+(set-foreground-color "grey")
+(set-cursor-color "white")
+(set-mouse-color "white")
+
+(setq delete-auto-save-files t)
+(setq inhibit-startup-message t)
+
+(menu-bar-mode 0)
+(tool-bar-mode 0)
+
+(electric-indent-mode 0)
+
+;; (require 'color-theme)
+;; (if window-system
+;; (color-theme-emacs-21)
+;; (color-theme-hober))
+;;(color-theme-arjen)
+
+(set-frame-font "7x14")
+
+;; Mousewheel
+(defun sd-mousewheel-scroll-up (event)
+ "Scroll window under mouse up by five lines."
+ (interactive "e")
+ (let ((current-window (selected-window)))
+ (unwind-protect
+ (progn
+ (select-window (posn-window (event-start event)))
+ (scroll-up 5))
+ (select-window current-window))))
+
+(defun sd-mousewheel-scroll-down (event)
+ "Scroll window under mouse down by five lines."
+ (interactive "e")
+ (let ((current-window (selected-window)))
+ (unwind-protect
+ (progn
+ (select-window (posn-window (event-start event)))
+ (scroll-down 5))
+ (select-window current-window))))
+
+(global-set-key (kbd "<mouse-5>") 'sd-mousewheel-scroll-up)
+(global-set-key (kbd "<mouse-4>") 'sd-mousewheel-scroll-down)
+
+; Montrer la correspondance des parenthèses
+; (systématiquement et non seulement après la frappe)
+(require 'paren)
+(show-paren-mode t)
+(setq blink-matching-paren t)
+(setq blink-matching-paren-on-screen t)
+(setq blink-matching-paren-dont-ignore-comments t)
+
+; 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
+(setq european-calendar-style t)
+(setq calendar-week-start-day 1)
+(defvar calendar-day-name-array
+ ["dimanche" "lundi" "mardi" "mercredi" "jeudi" "vendredi" "samedi"])
+(defvar calendar-month-name-array
+ ["janvier" "février" "mars" "avril" "mai" "juin"
+ "juillet" "août" "septembre" "octobre" "novembre" "décembre"])
+
+; 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)
+
+;; Raccourcis clavier
+(global-set-key [f2] 'egg-status)
+(global-set-key [f3] 'cvs-status)
+(global-set-key [f4] 'cvs-quickdir)
+(global-set-key [f5] 'toggle-read-only)
+(global-set-key [f6] 'goto-line)
+(global-set-key [f7] 'rgrep)
+(global-set-key [f8] 'revert-buffer)
+(global-set-key [f9] 'compile)
+(global-set-key [f10] 'next-error)
+(global-set-key [f11] 'toggle-fill-mode)
+(global-set-key [f12] 'toggle-whitespace-begin-space)
+
+(global-set-key "\M-?" 'tags-search)
+(global-set-key "\M-s" 'search-word)
+(global-set-key (kbd "C-x <down>") 'rotate-windows)
+
+
+;; page up, page down
+(fset 'page-down
+ [next])
+(fset 'page-up
+ [prior])
+
+(global-set-key "\M-p" 'page-up)
+(global-set-key "\M-n" 'page-down)
+
+;; Pour utiliser gnumake par defaut
+;; M-x customize !
+(custom-set-variables
+ ;; custom-set-variables was added by Custom.
+ ;; If you edit it by hand, you could mess it up, so be careful.
+ ;; Your init file should contain only one such instance.
+ ;; If there is more than one, they won't work right.
+ '(compile-command "make")
+ '(ediff-split-window-function (quote split-window-horizontally))
+ '(ediff-window-setup-function (quote ediff-setup-windows-plain))
+ '(egg-buffer-hide-section-type-on-start nil)
+ '(egg-mode-key-prefix "C-x !")
+ '(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))))
+ '(shell-file-name "/bin/bash")
+ '(vc-handled-backends (quote (RCS CVS SVN SCCS Bzr Hg Mtn Arch))))
+
+; Effacer tous les espaces en fin de ligne
+(defun delete-trailing-spaces ()
+ "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 <asc@bsiag.com>
+(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)
+)
+
+
+; Activation des fonctions « upcase-region » et « downcase-region »
+; Ces fonctions sont désactivées par défaut sous Emacs 21 ; pourquoi ?
+(put 'upcase-region 'disabled nil)
+(put 'downcase-region 'disabled nil)
+
+; taille de la fenetre de compil
+(setq compilation-window-height 15)
+
+; indentation
+(require 'cc-mode)
+(defun my-build-tab-stop-list (width)
+ (let ((num-tab-stops (/ 80 width))
+ (counter 1)
+ (ls nil))
+ (while (<= counter num-tab-stops)
+ (setq ls (cons (* width counter) ls))
+ (setq counter (1+ counter)))
+ (set (make-local-variable 'tab-stop-list) (nreverse ls))))
+
+; from linux/Documentation/CodingStyle
+;
+(defun c-lineup-arglist-tabs-only (ignored)
+ "Line up argument lists by tabs, not spaces"
+ (let* ((anchor (c-langelem-pos c-syntactic-element))
+ (column (c-langelem-2nd-pos c-syntactic-element))
+ (offset (- (1+ column) anchor))
+ (steps (floor offset c-basic-offset)))
+ (* (max steps 1)
+ c-basic-offset)))
+
+;; Add kernel style
+(c-add-style
+ "linux-tabs-only"
+ '("linux" (c-offsets-alist
+ (arglist-cont-nonempty
+ c-lineup-gcc-asm-reg
+ c-lineup-arglist-tabs-only))))
+
+(add-hook 'c-mode-hook
+ (lambda ()
+ (c-set-style "linux-tabs-only"))
+)
+
+(add-hook 'c-mode-common-hook
+ (lambda ()
+ (font-lock-add-keywords nil
+ '(("\\<\\(FIXME\\|TODO\\|HACK\\|fixme\\|todo\\|hack\\|XXX\\)" 1
+ font-lock-warning-face t)))))
+
+(defun set-indent-quagga ()
+ (interactive)
+ (setq c-basic-offset 2)
+ (setq tab-width 8 indent-tabs-mode nil)
+)
+
+(defun set-indent-xms ()
+ (interactive)
+ (setq c-basic-offset 4)
+ (setq tab-width 8 indent-tabs-mode nil)
+)
+
+(defun set-indent-std ()
+ (interactive)
+ (c-set-offset 'arglist-cont-nonempty 8)
+ (c-set-offset 'arglist-intro '+)
+ (c-set-offset 'arglist-close 0)
+ (setq c-basic-offset 8)
+ (setq tab-width 8 indent-tabs-mode 1)
+)
+
+;; marche pas...
+(defun set-indent-dpdk ()
+ (interactive)
+ (c-set-offset 'arglist-cont-nonempty 16)
+ (c-set-offset 'arglist-intro '+)
+ (c-set-offset 'arglist-close 0)
+ (setq c-basic-offset 8)
+ (setq tab-width 8 indent-tabs-mode 1)
+)
+
+(defun toggle-whitespace-begin-space ()
+ (interactive)
+ (whitespace-toggle-options '(indentation::tab indentation))
+)
+
+ '(sh-basic-offset 2)
+ '(sh-indent-after-function (quote -))
+ '(sh-indent-comment t)
+
+;; indentation of shell scripts
+(defun set-sh-indent-8 ()
+ "My own personal preferences for `sh-mode'.
+
+This is a custom function that sets up the parameters I usually
+prefer for `sh-mode'. It is automatically added to
+`sh-mode-hook', but is can also be called interactively."
+ (interactive)
+ (setq sh-basic-offset 8
+ sh-indentation 8
+ sh-indent-comment t))
+(add-hook 'sh-mode-hook 'set-sh-indent-8)
+
+;; packager
+(defun set-sh-indent-4 ()
+ (interactive)
+ (setq sh-basic-offset 4
+ sh-indentation 4
+ sh-indent-comment t
+ indent-tabs-mode nil))
+
+(custom-set-faces
+ ;; custom-set-faces was added by Custom.
+ ;; If you edit it by hand, you could mess it up, so be careful.
+ ;; Your init file should contain only one such instance.
+ ;; If there is more than one, they won't work right.
+ )
+
+;; (set-terminal-coding-system 'latin-9)
+;; (set-keyboard-coding-system 'latin-9)
+;; (set-language-environment 'latin-9)
+
+(add-to-list 'kill-emacs-query-functions
+ (lambda () (y-or-n-p "Should Emacs really close? ")))
+
+(require 'xcscope)
+
+(define-key global-map [(control f3)] 'cscope-set-initial-directory)
+(define-key global-map [(control f4)] 'cscope-unset-initial-directory)
+(define-key global-map [(control f5)] 'cscope-find-this-symbol)
+(define-key global-map [(control f6)] 'cscope-find-global-definition)
+(define-key global-map [(control f7)] 'cscope-find-global-definition-no-prompting)
+(define-key global-map [(control f8)] 'cscope-pop-mark)
+(define-key global-map [(control f9)] 'cscope-next-symbol)
+(define-key global-map [(control f10)] 'cscope-next-file)
+(define-key global-map [(control f11)] 'cscope-prev-symbol)
+(define-key global-map [(control f12)] 'cscope-prev-file)
+(define-key global-map [(meta f9)] 'cscope-display-buffer)
+(define-key global-map [(meta f10)] 'cscope-display-buffer-toggle)
+;(setq cscope-display-cscope-buffer nil)
+
+
+(defun vi-nolist ()
+ "Simulate a :set nolist in Vi."
+ (interactive)
+ (standard-display-ascii ?\t "\t")
+ (standard-display-ascii ?\ "\ ") )
+
+(defun sign ()
+ "Insert signature."
+ (interactive "*")
+ (insert "Signed-off-by: Olivier Matz <olivier.matz@6wind.com>")
+)
+
+(defun ack-choice ()
+ "Insert acked-by."
+ (interactive
+ (let ((string (read-string "Name: " nil 'my-history)))
+ (insert (shell-command-to-string (concat "acked-by.py " string))))
+ )
+)
+
+(defun sign-choice ()
+ "Insert acked-by."
+ (interactive
+ (let ((string (read-string "Name: " nil 'my-history)))
+ (insert (shell-command-to-string (concat "acked-by.py -s " string))))
+ )
+)
+
+(defun toggle-fill-mode ()
+ "toggle fill mode between 72 and 80"
+ (interactive "*")
+ (if (<= fill-column 72)
+ (setq-default fill-column 80)
+ (setq-default fill-column 72)))
+
+(defun rotate-windows-helper(x d)
+ (if (equal (cdr x) nil) (set-window-buffer (car x) d)
+ (set-window-buffer (car x) (window-buffer (cadr x))) (rotate-windows-helper (cdr x) d)))
+
+(defun rotate-windows ()
+ (interactive)
+ (rotate-windows-helper (window-list) (window-buffer (car (window-list))))
+ (select-window (car (last (window-list)))))
+
+;; http://www.emacswiki.org/emacs/WhiteSpace
+(require 'whitespace)
+(global-whitespace-mode 1)
+(setq whitespace-style '(face trailing lines-tail indentation::tab indentation
+ space-after-tab::tab space-after-tab::space
+ space-after-tab space-before-tab::tab
+ space-before-tab::space space-before-tab))
+;; for xms, remove indentation::tab and indentation
+;; (setq whitespace-style '(face trailing lines-tail
+;; space-after-tab::tab space-after-tab::space
+;; space-after-tab space-before-tab::tab
+;; space-before-tab::space space-before-tab))
+
+
+(defun bf-pretty-print-xml-region (begin end)
+ "Pretty format XML markup in region. You need to have nxml-mode
+http://www.emacswiki.org/cgi-bin/wiki/NxmlMode installed to do
+this. The function inserts linebreaks to separate tags that have
+nothing but whitespace between them. It then indents the markup
+by using nxml's indentation rules."
+ (interactive "r")
+ (save-excursion
+ (nxml-mode)
+ (goto-char begin)
+ (while (search-forward-regexp "\>[ \\t]*\<" nil t)
+ (backward-char) (insert "\n"))
+ (indent-region begin end))
+ (message "Ah, much better!"))
+
+; git
+(require 'egg)
+
+; fill column to 80 when we use M-q
+(setq-default fill-column 80)
+
+; to remove once fixed (make 4.0 compat)
+(setq-default compilation-directory-matcher '("\\(?:Entering\\|Leavin\\(g\\)\\) directory [`']\\(.+\\)'$" (2 . 1)))