3 ;; Added by Package.el. This must come before configurations of
4 ;; installed packages. Don't delete this line. If you don't want it,
5 ;; just comment it out by adding a semicolon to the start of the line.
6 ;; You may delete these explanatory comments.
9 (add-to-list 'load-path "~/.emacs.d/lisp/yang")
12 (add-to-list 'load-path "~/.emacs.d/lisp/flatbuffers")
13 (load "flatbuffers-mode.el")
19 ;;; uncomment this line to disable loading of "default.el" at startup
20 ;; (setq inhibit-default-init t)
22 ;; enable visual feedback on selections
23 ;(setq transient-mark-mode t)
25 ;; default to better frame titles
26 (setq frame-title-format
27 (concat "%b - emacs@" (system-name)))
29 ;; default to unified diffs
30 (setq diff-switches "-u")
32 ;; always end a file with a newline
33 ;(setq require-final-newline 'query)
35 ;;; uncomment for CJK utf-8 support for non-Asian users
36 ;; (require 'un-define)
38 (set-background-color "black")
39 (set-foreground-color "grey")
40 (set-cursor-color "white")
41 (set-mouse-color "white")
43 (setq delete-auto-save-files t)
44 (setq inhibit-startup-message t)
49 (electric-indent-mode 0)
50 (setq column-number-mode t)
52 ;; (require 'color-theme)
54 ;; (color-theme-emacs-21)
55 ;; (color-theme-hober))
58 (set-frame-font "7x14")
61 (defun sd-mousewheel-scroll-up (event)
62 "Scroll window under mouse up by five lines."
64 (let ((current-window (selected-window)))
67 (select-window (posn-window (event-start event)))
69 (select-window current-window))))
71 (defun sd-mousewheel-scroll-down (event)
72 "Scroll window under mouse down by five lines."
74 (let ((current-window (selected-window)))
77 (select-window (posn-window (event-start event)))
79 (select-window current-window))))
81 ;; from https://unix.stackexchange.com/questions/26360/emacs-deleting-a-line-without-sending-it-to-the-kill-ring
82 ;; better than https://www.emacswiki.org/emacs/ElispCookbook#toc13
83 (defun delete-line (&optional arg)
84 "Delete the rest of the current line; if no nonblanks there, delete thru newline.
85 With prefix argument ARG, delete that many lines from point.
86 Negative arguments delete lines backward.
87 With zero argument, delete the text before point on the current line.
89 When calling from a program, nil means \"no arg\",
90 a number counts as a prefix arg.
92 If `show-trailing-whitespace' is non-nil, this command will just
93 delete the rest of the current line, even if there are no nonblanks
96 If option `kill-whole-line' is non-nil, then this command deletes the whole line
97 including its terminating newline, when used at the beginning of a line
100 If the buffer is read-only, Emacs will beep and refrain from deleting
107 (forward-visible-line (prefix-numeric-value arg))
109 (signal 'end-of-buffer nil))
112 (end-of-visible-line) (point))))
113 (if (or (save-excursion
114 ;; If trailing whitespace is visible,
115 ;; don't treat it as nothing.
116 (unless show-trailing-whitespace
117 (skip-chars-forward " \t" end))
119 (and kill-whole-line (bolp)))
120 (forward-visible-line 1)
124 (global-set-key (kbd "<mouse-5>") 'sd-mousewheel-scroll-up)
125 (global-set-key (kbd "<mouse-4>") 'sd-mousewheel-scroll-down)
127 ; Montrer la correspondance des parenthèses
128 ; (systématiquement et non seulement après la frappe)
131 (setq blink-matching-paren t)
132 (setq blink-matching-paren-on-screen t)
133 (setq blink-matching-paren-dont-ignore-comments t)
135 ; Afficher l'heure dans la barre d'état (format 24 heures)
136 (setq display-time-24hr-format t)
139 ; Nom en clair des jours et mois apparaissant dans le calendrier
140 (setq european-calendar-style t)
141 (setq calendar-week-start-day 1)
142 (defvar calendar-day-name-array
143 ["dimanche" "lundi" "mardi" "mercredi" "jeudi" "vendredi" "samedi"])
144 (defvar calendar-month-name-array
145 ["janvier" "février" "mars" "avril" "mai" "juin"
146 "juillet" "août" "septembre" "octobre" "novembre" "décembre"])
148 ; C'est fastidieux de taper « yes » pour confirmer, raccourcissons
149 ; cela à « y » (idem pour « no », désormais « n »).
150 (fset 'yes-or-no-p 'y-or-n-p)
152 ;; Raccourcis clavier
153 (global-set-key [f2] 'magit-status)
154 (global-set-key [f3] 'vc-git-grep)
155 (global-set-key [f4] 'magit-blame-addition)
156 (global-set-key [f5] 'toggle-read-only)
157 (global-set-key [f6] 'goto-line)
158 (global-set-key [f7] 'rgrep)
159 (global-set-key [f8] 'revert-buffer)
160 (global-set-key [f9] 'compile)
161 (global-set-key [f10] 'next-error)
162 (global-set-key [f11] 'toggle-fill-mode)
163 (global-set-key [f12] 'toggle-whitespace-begin-space)
165 (global-set-key "\M-?" 'tags-search)
166 (global-set-key "\M-s" 'search-word)
167 (global-set-key (kbd "C-x <down>") 'rotate-windows)
169 (global-set-key (kbd "M-k") 'delete-line)
170 (global-set-key (kbd "M-%") 'query-replace-regexp)
171 (global-set-key (kbd "C-s") 'isearch-forward-regexp)
172 (global-set-key (kbd "C-r") 'isearch-backward-regexp)
175 ;; page up, page down
181 (global-set-key "\M-p" 'page-up)
182 (global-set-key "\M-n" 'page-down)
184 ;; Pour utiliser gnumake par defaut
186 (custom-set-variables
187 ;; custom-set-variables was added by Custom.
188 ;; If you edit it by hand, you could mess it up, so be careful.
189 ;; Your init file should contain only one such instance.
190 ;; If there is more than one, they won't work right.
191 '(compile-command "make")
192 '(ediff-split-window-function (quote split-window-horizontally))
193 '(ediff-window-setup-function (quote ediff-setup-windows-plain))
194 '(magit-commit-arguments nil)
195 '(magit-log-arguments (quote ("--decorate" "-n256")))
196 '(rst-adornment-faces-alist
198 ((t . font-lock-keyword-face)
199 (nil . font-lock-keyword-face)
200 (nil . rst-level-1-face)
201 (nil . rst-level-2-face)
202 (nil . rst-level-3-face)
203 (nil . rst-level-4-face)
204 (nil . rst-level-5-face)
205 (nil . rst-level-6-face))))
206 '(safe-local-variable-values
208 ((c-indent-level . 4)
210 (quote arglist-close)
213 (quote arglist-intro)
219 (quote statement-case-open)
222 (quote substatement-open)
224 '(shell-file-name "/bin/bash")
225 '(split-height-threshold 120)
226 '(split-width-threshold 240)
227 '(vc-handled-backends (quote (RCS CVS SVN SCCS Bzr Git Hg Mtn Arch))))
229 ; Effacer tous les espaces en fin de ligne
230 (defun delete-trailing-spaces ()
231 "Effacer les espaces et tabulations en fin de chaque ligne du tampon"
236 (replace-regexp "[ \t]+$" "")
242 ; Conversion des fins de lignes du format MS-DOS au format Unix
245 (goto-char (point-min))
246 (while (search-forward "\r" nil t)
252 ; Conversion des fins de ligne du format Unix au format MS-DOS
255 (goto-char (point-min))
256 (while (search-forward "\n" nil t)
257 (replace-match "\r\n")
262 ; Montrer la table des caractères ASCII étendus
263 ; Fonction fournie par Alex Schroeder <asc@bsiag.com>
264 (defun ascii-table ()
265 "Afficher la table de caractères ASCII."
267 (switch-to-buffer "*ASCII*")
269 (insert (format "Caractères ASCII de code 1 à 254.\n"))
271 (while (< i 254) (setq i (+ i 1))
272 (insert (format "%4d %c\n" i i))
275 (beginning-of-buffer)
279 ; Activation des fonctions « upcase-region » et « downcase-region »
280 ; Ces fonctions sont désactivées par défaut sous Emacs 21 ; pourquoi ?
281 (put 'upcase-region 'disabled nil)
282 (put 'downcase-region 'disabled nil)
284 ; taille de la fenetre de compil
285 (setq compilation-window-height 15)
289 (defun my-build-tab-stop-list (width)
290 (let ((num-tab-stops (/ 80 width))
293 (while (<= counter num-tab-stops)
294 (setq ls (cons (* width counter) ls))
295 (setq counter (1+ counter)))
296 (set (make-local-variable 'tab-stop-list) (nreverse ls))))
300 (defun c-lineup-arglist-tabs-only (ignored)
301 "Line up argument lists by tabs, not spaces"
302 (let* ((anchor (c-langelem-pos c-syntactic-element))
303 (column (c-langelem-2nd-pos c-syntactic-element))
304 (offset (- (1+ column) anchor))
305 (steps (floor offset c-basic-offset)))
313 (c-label-minimum-indentation . 0)
316 ; (arglist-close . c-lineup-arglist-tabs-only)
317 ; (arglist-cont-nonempty .
318 ; (c-lineup-gcc-asm-reg c-lineup-arglist-tabs-only))
319 (arglist-close . c-lineup-arglist)
320 (arglist-cont-nonempty . c-lineup-arglist)
322 (brace-list-intro . +)
323 (c . c-lineup-C-comments)
325 (comment-intro . c-lineup-comment)
326 (cpp-define-intro . +)
329 (defun-block-intro . +)
333 (inher-cont . c-lineup-multi-inher)
334 (knr-argdecl-intro . 0)
337 (statement-block-intro . +)
338 (statement-case-intro . +)
343 (add-hook 'c-mode-hook
345 (c-set-style "linux-tabs-only"))
348 (add-hook 'c-mode-common-hook
350 (font-lock-add-keywords nil
351 '(("\\<\\(FIXME\\|TODO\\|HACK\\|fixme\\|todo\\|hack\\|XXX\\)" 1
352 font-lock-warning-face t)))))
354 (defun set-indent-2 ()
356 (setq c-basic-offset 2)
357 (setq tab-width 8 indent-tabs-mode nil)
360 (defun set-indent-4 ()
362 (setq c-basic-offset 4)
363 (setq tab-width 8 indent-tabs-mode nil)
366 (defun set-indent-8 ()
368 (setq c-basic-offset . 8)
369 (setq tab-width 8 indent-tabs-mode 1)
372 (defun toggle-whitespace-begin-space ()
374 (whitespace-toggle-options '(indentation::tab indentation))
377 ;; indentation of shell scripts
378 (defun set-sh-indent-8 ()
380 (setq sh-basic-offset 8
382 sh-indent-comment t))
384 (defun set-sh-indent-4 ()
386 (setq sh-basic-offset 4
389 indent-tabs-mode nil))
392 (defun set-sh-indent-4-spaces ()
394 (setq sh-basic-offset 4
396 sh-indent-comment t))
399 ;; custom-set-faces was added by Custom.
400 ;; If you edit it by hand, you could mess it up, so be careful.
401 ;; Your init file should contain only one such instance.
402 ;; If there is more than one, they won't work right.
403 '(magit-diff-added ((t (:foreground "#335533"))))
404 '(magit-diff-added-highlight ((t (:foreground "#336633"))))
405 '(magit-diff-base ((t (:foreground "#555522"))))
406 '(magit-diff-base-highlight ((t (:foreground "#666622"))))
407 '(magit-diff-removed ((t (:foreground "#553333"))))
408 '(magit-diff-removed-highlight ((t (:foreground "#663333"))))
409 '(magit-hash ((t (:foreground "white")))))
411 ;; (set-terminal-coding-system 'latin-9)
412 ;; (set-keyboard-coding-system 'latin-9)
413 ;; (set-language-environment 'latin-9)
415 (add-to-list 'kill-emacs-query-functions
416 (lambda () (y-or-n-p "Should Emacs really close? ")))
418 (define-key global-map [(control f3)] 'cscope-set-initial-directory)
419 (define-key global-map [(control f4)] 'cscope-unset-initial-directory)
420 (define-key global-map [(control f5)] 'cscope-find-this-symbol)
421 (define-key global-map [(control f6)] 'cscope-find-global-definition)
422 (define-key global-map [(control f7)] 'cscope-find-global-definition-no-prompting)
423 (define-key global-map [(control f8)] 'cscope-pop-mark)
424 (define-key global-map [(control f9)] 'cscope-next-symbol)
425 (define-key global-map [(control f10)] 'cscope-next-file)
426 (define-key global-map [(control f11)] 'cscope-prev-symbol)
427 (define-key global-map [(control f12)] 'cscope-prev-file)
428 (define-key global-map [(meta f9)] 'cscope-display-buffer)
429 (define-key global-map [(meta f10)] 'cscope-display-buffer-toggle)
430 ;(setq cscope-display-cscope-buffer nil)
432 (global-set-key (kbd "C-<up>") 'windmove-up)
433 (global-set-key (kbd "C-<down>") 'windmove-down)
434 (global-set-key (kbd "C-<left>") 'windmove-left)
435 (global-set-key (kbd "C-<right>") 'windmove-right)
436 (global-set-key (kbd "M-RET") 'other-window)
437 (global-set-key (kbd "C-<next>") 'next-buffer)
438 (global-set-key (kbd "C-<prior>") 'previous-buffer)
440 (setq-default gdb-display-io-nopopup t)
443 "Simulate a :set nolist in Vi."
445 (standard-display-ascii ?\t "\t")
446 (standard-display-ascii ?\ "\ ") )
451 (insert "Signed-off-by: Olivier Matz <olivier.matz@6wind.com>")
457 (let ((string (read-string "Name: " nil 'my-history)))
458 (insert (shell-command-to-string (concat "acked-by.py " string))))
462 (defun sign-choice ()
465 (let ((string (read-string "Name: " nil 'my-history)))
466 (insert (shell-command-to-string (concat "acked-by.py -s " string))))
470 (defun toggle-fill-mode ()
471 "toggle fill mode between 72 and 80"
473 (if (<= fill-column 72)
474 (setq-default fill-column 80)
475 (setq-default fill-column 72)))
477 (defun rotate-windows-helper(x d)
478 (if (equal (cdr x) nil) (set-window-buffer (car x) d)
479 (set-window-buffer (car x) (window-buffer (cadr x))) (rotate-windows-helper (cdr x) d)))
481 (defun rotate-windows ()
483 (rotate-windows-helper (window-list) (window-buffer (car (window-list))))
484 (select-window (car (last (window-list)))))
486 ;; http://www.emacswiki.org/emacs/WhiteSpace
487 (require 'whitespace)
488 (global-whitespace-mode 1)
489 (setq whitespace-style '(face trailing lines-tail indentation::tab indentation
490 space-after-tab::tab space-after-tab::space
491 space-after-tab space-before-tab::tab
492 space-before-tab::space space-before-tab))
493 ;; for xms, remove indentation::tab and indentation
494 ;; (setq whitespace-style '(face trailing lines-tail
495 ;; space-after-tab::tab space-after-tab::space
496 ;; space-after-tab space-before-tab::tab
497 ;; space-before-tab::space space-before-tab))
500 (defun bf-pretty-print-xml-region (begin end)
501 "Pretty format XML markup in region. You need to have nxml-mode
502 http://www.emacswiki.org/cgi-bin/wiki/NxmlMode installed to do
503 this. The function inserts linebreaks to separate tags that have
504 nothing but whitespace between them. It then indents the markup
505 by using nxml's indentation rules."
510 (while (search-forward-regexp "\>[ \\t]*\<" nil t)
511 (backward-char) (insert "\n"))
512 (indent-region begin end))
513 (message "Ah, much better!"))
515 ; fill column to 80 when we use M-q
516 (setq-default fill-column 80)
518 ; to remove once fixed (make 4.0 compat)
519 (setq-default compilation-directory-matcher '("\\(?:Entering\\|Leavin\\(g\\)\\) directory [`']\\(.+\\)'$" (2 . 1)))
521 ;; epylint start.py --rcfile=~/.pylintrc