From cd73c8585d5d5154464ba6da270c4790d22e5ad2 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 12 Aug 2015 15:06:20 +0200 Subject: [PATCH] Refactor C++11 highlights --- modules/lib/defuns-cc.el | 16 ++++++++++++++++ modules/module-cc.el | 17 +---------------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/modules/lib/defuns-cc.el b/modules/lib/defuns-cc.el index 94701809d..fe5be372b 100644 --- a/modules/lib/defuns-cc.el +++ b/modules/lib/defuns-cc.el @@ -23,8 +23,24 @@ ;; DEL mapping interferes with smartparens and my custom DEL binding (define-key c-mode-map (kbd "DEL") nil)) +(defun narf--copy-face (new-face face) + "Define NEW-FACE from existing FACE." + (copy-face face new-face) + (eval `(defvar ,new-face nil)) + (set new-face new-face)) + ;;;###autoload (defun narf|init-c++-C11-highlights () + ;; C++11 syntax support (until cc-mode is updated) + (require 'font-lock) + ;; labels, case, public, private, protected, namespace-tags + (narf--copy-face 'font-lock-label-face 'font-lock-keyword-face) + ;; comment markups such as Javadoc-tags + (narf--copy-face 'font-lock-doc-markup-face 'font-lock-doc-face) + ;; comment markups + (narf--copy-face 'font-lock-doc-string-face 'font-lock-comment-face) + (setq font-lock-maximum-decoration t) + ;; We could place some regexes into `c-mode-common-hook', but ;; note that their evaluation order matters. (font-lock-add-keywords diff --git a/modules/module-cc.el b/modules/module-cc.el index fade5dd40..a42da3719 100644 --- a/modules/module-cc.el +++ b/modules/module-cc.el @@ -44,25 +44,10 @@ (add-company-backend! objc-mode (c-headers xcode))) (add-hook! (c-mode c++-mode) 'narf|init-c/c++-settings) + (add-hook! c++-mode 'narf|init-c++-C11-highlights) (add-hook! c++-mode (setq flycheck-clang-language-standard "c++11" flycheck-clang-standard-library "libc++")) - ;; C++11 syntax support (until cc-mode is updated) - (require 'font-lock) - (defun --copy-face (new-face face) - "Define NEW-FACE from existing FACE." - (copy-face face new-face) - (eval `(defvar ,new-face nil)) - (set new-face new-face)) - ;; labels, case, public, private, protected, namespace-tags - (--copy-face 'font-lock-label-face 'font-lock-keyword-face) - ;; comment markups such as Javadoc-tags - (--copy-face 'font-lock-doc-markup-face 'font-lock-doc-face) - ;; comment markups - (--copy-face 'font-lock-doc-string-face 'font-lock-comment-face) - (setq font-lock-maximum-decoration t) - (add-hook! c++-mode 'narf|init-c++-C11-highlights) - ;; Fix enum and C++11 lambda indentation (defadvice c-lineup-arglist (around c-lineup-arglist-indent-fix activate) "Improve indentation of continued C++11 lambda function opened as argument."