;; .emacs ;; Added by Package.el. This must come before configurations of ;; installed packages. Don't delete this line. If you don't want it, ;; just comment it out by adding a semicolon to the start of the line. ;; You may delete these explanatory comments. (package-initialize) (add-to-list 'load-path "~/.emacs.d/lisp/yang") (load "yang-mode.el") (add-to-list 'load-path "~/.emacs.d/lisp/flatbuffers") (load "flatbuffers-mode.el") (editorconfig-mode 1) (require 'xcscope) ;;; 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) (setq column-number-mode t) ;; (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)))) ;; from https://unix.stackexchange.com/questions/26360/emacs-deleting-a-line-without-sending-it-to-the-kill-ring ;; better than https://www.emacswiki.org/emacs/ElispCookbook#toc13 (defun delete-line (&optional arg) "Delete the rest of the current line; if no nonblanks there, delete thru newline. With prefix argument ARG, delete that many lines from point. Negative arguments delete lines backward. With zero argument, delete the text before point on the current line. When calling from a program, nil means \"no arg\", a number counts as a prefix arg. If `show-trailing-whitespace' is non-nil, this command will just delete the rest of the current line, even if there are no nonblanks there. If option `kill-whole-line' is non-nil, then this command deletes the whole line including its terminating newline, when used at the beginning of a line with no argument. If the buffer is read-only, Emacs will beep and refrain from deleting the line." (interactive "P") (delete-region (point) (progn (if arg (forward-visible-line (prefix-numeric-value arg)) (if (eobp) (signal 'end-of-buffer nil)) (let ((end (save-excursion (end-of-visible-line) (point)))) (if (or (save-excursion ;; If trailing whitespace is visible, ;; don't treat it as nothing. (unless show-trailing-whitespace (skip-chars-forward " \t" end)) (= (point) end)) (and kill-whole-line (bolp))) (forward-visible-line 1) (goto-char end)))) (point)))) (global-set-key (kbd "") 'sd-mousewheel-scroll-up) (global-set-key (kbd "") '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] 'magit-status) (global-set-key [f3] 'vc-git-grep) (global-set-key [f4] 'magit-blame-addition) (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 ") 'rotate-windows) (global-set-key (kbd "M-k") 'delete-line) (global-set-key (kbd "M-%") 'query-replace-regexp) (global-set-key (kbd "C-s") 'isearch-forward-regexp) (global-set-key (kbd "C-r") 'isearch-backward-regexp) ;; 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)) '(magit-commit-arguments nil) '(magit-log-arguments (quote ("--decorate" "-n256"))) '(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)))) '(safe-local-variable-values (quote ((c-indent-level . 4) (eval c-set-offset (quote arglist-close) 0) (eval c-set-offset (quote arglist-intro) (quote ++)) (eval c-set-offset (quote case-label) 0) (eval c-set-offset (quote statement-case-open) 0) (eval c-set-offset (quote substatement-open) 0)))) '(shell-file-name "/bin/bash") '(split-height-threshold 120) '(split-width-threshold 240) '(vc-handled-backends (quote (RCS CVS SVN SCCS Bzr Git 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 (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)))) ;; Add kernel style (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))) (c-add-style "linux-tabs-only" '("linux" (c-basic-offset . 8) (c-label-minimum-indentation . 0) (c-offsets-alist . ( ; before: ; (arglist-close . c-lineup-arglist-tabs-only) ; (arglist-cont-nonempty . ; (c-lineup-gcc-asm-reg c-lineup-arglist-tabs-only)) (arglist-close . c-lineup-arglist) (arglist-cont-nonempty . c-lineup-arglist) (arglist-intro . +) (brace-list-intro . +) (c . c-lineup-C-comments) (case-label . 0) (comment-intro . c-lineup-comment) (cpp-define-intro . +) (cpp-macro . -1000) (cpp-macro-cont . +) (defun-block-intro . +) (else-clause . 0) (func-decl-cont . +) (inclass . +) (inher-cont . c-lineup-multi-inher) (knr-argdecl-intro . 0) (label . -1000) (statement . 0) (statement-block-intro . +) (statement-case-intro . +) (statement-cont . +) (substatement . +) )))) (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-2 () (interactive) (setq c-basic-offset 2) (setq tab-width 8 indent-tabs-mode nil) ) (defun set-indent-4 () (interactive) (setq c-basic-offset 4) (setq tab-width 8 indent-tabs-mode nil) ) (defun set-indent-8 () (interactive) (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)) ) ;; indentation of shell scripts (defun set-sh-indent-8 () (interactive) (setq sh-basic-offset 8 sh-indentation 8 sh-indent-comment t)) (defun set-sh-indent-4 () (interactive) (setq sh-basic-offset 4 sh-indentation 4 sh-indent-comment t indent-tabs-mode nil)) ;; with spaces (defun set-sh-indent-4-spaces () (interactive) (setq sh-basic-offset 4 sh-indentation 4 sh-indent-comment t)) (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. '(magit-diff-added ((t (:foreground "#335533")))) '(magit-diff-added-highlight ((t (:foreground "#336633")))) '(magit-diff-base ((t (:foreground "#555522")))) '(magit-diff-base-highlight ((t (:foreground "#666622")))) '(magit-diff-removed ((t (:foreground "#553333")))) '(magit-diff-removed-highlight ((t (:foreground "#663333")))) '(magit-hash ((t (:foreground "white"))))) ;; (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? "))) (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) (global-set-key (kbd "C-") 'windmove-up) (global-set-key (kbd "C-") 'windmove-down) (global-set-key (kbd "C-") 'windmove-left) (global-set-key (kbd "C-") 'windmove-right) (global-set-key (kbd "M-RET") 'other-window) (global-set-key (kbd "C-") 'next-buffer) (global-set-key (kbd "C-") 'previous-buffer) (setq-default gdb-display-io-nopopup t) (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 ") ) (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!")) ; 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))) ;; epylint start.py --rcfile=~/.pylintrc