From: Peng Li Date: Thu, 21 Sep 2017 09:26:43 +0000 (+0800) Subject: Emacs - font lock X-Git-Url: http://47.100.26.94:8080/?a=commitdiff_plain;h=20549996811d8734ad35f5c0d473a070c3579db1;hp=5ee171d03a78afb93b3ade7b8b490aaa35333e25;p=dotfiles.git Emacs - font lock --- diff --git a/emacs.d/config.org b/emacs.d/config.org index 4b7e6f4..73dfe4b 100644 --- a/emacs.d/config.org +++ b/emacs.d/config.org @@ -2139,42 +2139,35 @@ Refer, [[http://emacs.stackexchange.com/questions/7908/how-to-make-yasnippet-and ** Color identiifiers mode #+BEGIN_SRC emacs-lisp :tangle yes :results silent (use-package color-identifiers-mode - :ensure t) + :ensure t + :init + (dolist (mode '(emacs-lisp-mode-hook + c-mode-hook + c++-mode-hook)) + (add-hook mode #'color-identifiers-mode)) + :diminish color-identifiers-mode) + + (global-prettify-symbols-mode t) #+END_SRC ** Font lock face + #+BEGIN_SRC emacs-lisp :tangle yes :results silent - (set-face-attribute 'font-lock-keyword-face nil :weight 'bold) + (set-face-attribute 'font-lock-keyword-face nil :foreground "#F92672" :weight 'bold) (set-face-attribute 'font-lock-builtin-face nil :weight 'bold) -#+END_SRC + (set-face-attribute 'font-lock-function-name-face nil :foreground "#A6E22E" :weight 'normal :slant 'normal) + (set-face-attribute 'font-lock-variable-name-face nil :foreground "#00FF00") -#+BEGIN_SRC emacs-lisp :tangle yes :results silent (font-lock-add-keywords 'c-mode ;; highlight %s \n '(("\\([%\\][a-zA-Z]\\)" (1 font-lock-keyword-face prepend)) - ("[^[:alpha:]]\\([[:digit:]]*\\)[^[:alpha:]]" (1 font-lock-constant-face append)))) - - - ;; Also make function calls highlighted - (font-lock-add-keywords 'c-mode - '(("\\s\"?\\(\\(\\sw\\|\\s_\\)+\\(<-\\)?\\)\\s\"?*\\s-*(" - (1 font-lock-function-name-face))) t) - - - + ("[^[:alpha:]]\\([[:digit:]]*\\)[^[:alpha:]]" (1 font-lock-constant-face append)) + ;; hex number + ("[^[:alpha:]]\\(0[x\\|X][0-9a-fA-F]*\\)[^[:alpha:]]" (1 font-lock-constant-face append)) + ;; hightlight the function call + ("\\s\"?\\(\\(\\sw\\|\\s_\\)+\\(<-\\)?\\)\\s\"?*\\s-*(" (1 font-lock-function-name-face))) t) #+END_SRC ** Emacs Lisp -#+BEGIN_SRC emacs-lisp :tangle yes :results silent - (use-package color-identifiers-mode - :ensure t - :init - (add-hook 'emacs-lisp-mode-hook 'color-identifiers-mode) - - :diminish color-identifiers-mode) - - (global-prettify-symbols-mode t) -#+END_SRC - In Lisp Mode, =M-o= is defined, but I use this for global hydra window. So here disable this key bindings in =lispy-mode-map= after loaded. see [[http://stackoverflow.com/questions/298048/how-to-handle-conflicting-keybindings][here]] #+BEGIN_SRC emacs-lisp :tangle yes :results silent