emacs
authorOlivier Matz <zer0@droids-corp.org>
Wed, 2 Jun 2021 13:28:31 +0000 (15:28 +0200)
committerOlivier Matz <zer0@droids-corp.org>
Wed, 2 Jun 2021 13:28:31 +0000 (15:28 +0200)
.emacs

diff --git a/.emacs b/.emacs
index 04ba873..0cd101c 100644 (file)
--- a/.emacs
+++ b/.emacs
@@ -1,6 +1,20 @@
 ;; .emacs
 
-(add-to-list 'load-path "~/.emacs.d/lisp/egg")
+;; 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/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)
@@ -33,6 +47,7 @@
 (tool-bar-mode 0)
 
 (electric-indent-mode 0)
+(setq column-number-mode t)
 
 ;; (require 'color-theme)
 ;; (if window-system
@@ -48,9 +63,9 @@
   (interactive "e")
   (let ((current-window (selected-window)))
     (unwind-protect
-       (progn
-         (select-window (posn-window (event-start event)))
-         (scroll-up 5))
+        (progn
+          (select-window (posn-window (event-start event)))
+          (scroll-up 5))
       (select-window current-window))))
 
 (defun sd-mousewheel-scroll-down (event)
   (interactive "e")
   (let ((current-window (selected-window)))
     (unwind-protect
-       (progn
-         (select-window (posn-window (event-start event)))
-         (scroll-down 5))
+        (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 "<mouse-5>") 'sd-mousewheel-scroll-up)
 (global-set-key (kbd "<mouse-4>") 'sd-mousewheel-scroll-down)
 
 (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 [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 "\M-s"         'search-word)
 (global-set-key (kbd "C-x <down>") '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
  '(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))))
+ '(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")
- '(vc-handled-backends (quote (RCS CVS SVN SCCS Bzr Hg Mtn Arch))))
+ '(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 ()
       (setq counter (1+ counter)))
     (set (make-local-variable 'tab-stop-list) (nreverse ls))))
 
-; from linux/Documentation/CodingStyle
-;
+;; 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)))
+         (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))))
+ '("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 ()
+          (lambda ()
            (c-set-style "linux-tabs-only"))
 )
 
     '(("\\<\\(FIXME\\|TODO\\|HACK\\|fixme\\|todo\\|hack\\|XXX\\)" 1
         font-lock-warning-face t)))))
 
-(defun set-indent-quagga ()
+(defun set-indent-2 ()
   (interactive)
   (setq c-basic-offset 2)
   (setq tab-width 8 indent-tabs-mode nil)
 )
 
-(defun set-indent-xms ()
+(defun set-indent-4 ()
   (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 ()
+(defun set-indent-8 ()
   (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 c-basic-offset . 8)
   (setq tab-width 8 indent-tabs-mode 1)
 )
 
   (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
@@ -294,21 +388,32 @@ prefer for `sh-mode'.  It is automatically added to
        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? ")))
-
-(require 'xcscope)
+             (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)
@@ -324,6 +429,15 @@ prefer for `sh-mode'.  It is automatically added to
 (define-key global-map [(meta f10)] 'cscope-display-buffer-toggle)
 ;(setq cscope-display-cscope-buffer nil)
 
+(global-set-key (kbd "C-<up>") 'windmove-up)
+(global-set-key (kbd "C-<down>") 'windmove-down)
+(global-set-key (kbd "C-<left>") 'windmove-left)
+(global-set-key (kbd "C-<right>") 'windmove-right)
+(global-set-key (kbd "M-RET") 'other-window)
+(global-set-key (kbd "C-<next>") 'next-buffer)
+(global-set-key (kbd "C-<prior>") 'previous-buffer)
+
+(setq-default gdb-display-io-nopopup t)
 
 (defun vi-nolist ()
   "Simulate a :set nolist in Vi."
@@ -398,11 +512,10 @@ by using nxml's indentation rules."
       (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)))
+
+;; epylint start.py --rcfile=~/.pylintrc