summaryrefslogtreecommitdiff
path: root/lisp/progmodes/cc-mode.el
diff options
context:
space:
mode:
authorAlan Mackenzie <acm@muc.de>2016-05-09 17:49:45 +0000
committerAlan Mackenzie <acm@muc.de>2016-05-09 17:49:45 +0000
commita8231e00cbad60652ff7ab6ae51a758f1d939971 (patch)
treeabbdd240734fb41710e542335fea763e12601596 /lisp/progmodes/cc-mode.el
parent608f2bd0ac9d950a04ad73bf36d96d25b469b9be (diff)
downloademacs-a8231e00cbad60652ff7ab6ae51a758f1d939971.tar.gz
emacs-a8231e00cbad60652ff7ab6ae51a758f1d939971.tar.bz2
emacs-a8231e00cbad60652ff7ab6ae51a758f1d939971.zip
CC Mode now uses the new :after-hook feature of define-derived-mode
It now runs internal variable setting functions after the mode hooks, no longer runs the mode hooks twice, and declares the configuration variables for noise macros and macros with semicolons as safe variables (when given suitable arguments). Fixes bug #16759 and bug #23476. * .dir-locals: Put the c-noise-macros-with-paren-names setting back into the C Mode value. * lisp/progmodes/cc-mode.el: (c-basic-common-init): Remove the call to c-make-macro-with-semi-re. (c-mode, c++-mode, objc-mode, java-mode, idl-mode, pike-mode, awk-mode): Move c-make-noise-macro-regexps and c-make-macro-with-semi-re (where appropriate) and c-update-modeline into the :after-hook form. Remove the explicit settings of the syntax table, the abbreviation table and the local key map, since they duplicate forms generated by define-derived-mode. Remove the explicit invocation of each mode's mode hook, since they duplicate ones generated by define-derived-mode. * lisp/progmodes/cc-vars.el: (c-string-list-p, c-string-or-string-list-p): New functions. (c-noise-macro-names, c-noise-macro-with-parens-names): give the save-local-variable property c-string-list-p. (c-macro-names-with-semicolon): give the save-local-variable property c-string-or-string-list-p. * doc/misc/cc-mode.texi: (Macros with ;, Noise Macros): Note that it's not necessary to call the regexp generating functions after setting the pertinent configuration values in a mode hook.
Diffstat (limited to 'lisp/progmodes/cc-mode.el')
-rw-r--r--lisp/progmodes/cc-mode.el72
1 files changed, 26 insertions, 46 deletions
diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el
index 2ab1d6b0d70..6a78992756b 100644
--- a/lisp/progmodes/cc-mode.el
+++ b/lisp/progmodes/cc-mode.el
@@ -596,7 +596,6 @@ that requires a literal mode spec at compile time."
(not (string-equal c-indentation-style
style)))))))
(c-setup-paragraph-variables)
- (c-make-noise-macro-regexps)
;; we have to do something special for c-offsets-alist so that the
;; buffer local value has its own alist structure.
@@ -1487,18 +1486,16 @@ initialization, then `c-mode-hook'.
Key bindings:
\\{c-mode-map}"
+ :after-hook (progn (c-make-noise-macro-regexps)
+ (c-make-macro-with-semi-re)
+ (c-update-modeline))
(c-initialize-cc-mode t)
- (set-syntax-table c-mode-syntax-table)
- (setq local-abbrev-table c-mode-abbrev-table
- abbrev-mode t)
- (use-local-map c-mode-map)
+ (setq abbrev-mode t)
(c-init-language-vars-for 'c-mode)
- (c-make-macro-with-semi-re) ; matches macro names whose expansion ends with ;
(c-common-init 'c-mode)
(easy-menu-add c-c-menu)
(cc-imenu-init cc-imenu-c-generic-expression)
- (c-run-mode-hooks 'c-mode-common-hook 'c-mode-hook)
- (c-update-modeline))
+ (c-run-mode-hooks 'c-mode-common-hook))
;; Support for C++
@@ -1542,18 +1539,16 @@ initialization, then `c++-mode-hook'.
Key bindings:
\\{c++-mode-map}"
+ :after-hook (progn (c-make-noise-macro-regexps)
+ (c-make-macro-with-semi-re)
+ (c-update-modeline))
(c-initialize-cc-mode t)
- (set-syntax-table c++-mode-syntax-table)
- (setq local-abbrev-table c++-mode-abbrev-table
- abbrev-mode t)
- (use-local-map c++-mode-map)
+ (setq abbrev-mode t)
(c-init-language-vars-for 'c++-mode)
- (c-make-macro-with-semi-re) ; matches macro names whose expansion ends with ;
(c-common-init 'c++-mode)
(easy-menu-add c-c++-menu)
(cc-imenu-init cc-imenu-c++-generic-expression)
- (c-run-mode-hooks 'c-mode-common-hook 'c++-mode-hook)
- (c-update-modeline))
+ (c-run-mode-hooks 'c-mode-common-hook))
;; Support for Objective-C
@@ -1595,18 +1590,16 @@ initialization, then `objc-mode-hook'.
Key bindings:
\\{objc-mode-map}"
+ :after-hook (progn (c-make-noise-macro-regexps)
+ (c-make-macro-with-semi-re)
+ (c-update-modeline))
(c-initialize-cc-mode t)
- (set-syntax-table objc-mode-syntax-table)
- (setq local-abbrev-table objc-mode-abbrev-table
- abbrev-mode t)
- (use-local-map objc-mode-map)
+ (setq abbrev-mode t)
(c-init-language-vars-for 'objc-mode)
- (c-make-macro-with-semi-re) ; matches macro names whose expansion ends with ;
(c-common-init 'objc-mode)
(easy-menu-add c-objc-menu)
(cc-imenu-init nil 'cc-imenu-objc-function)
- (c-run-mode-hooks 'c-mode-common-hook 'objc-mode-hook)
- (c-update-modeline))
+ (c-run-mode-hooks 'c-mode-common-hook))
;; Support for Java
@@ -1656,17 +1649,14 @@ initialization, then `java-mode-hook'.
Key bindings:
\\{java-mode-map}"
+ :after-hook (c-update-modeline)
(c-initialize-cc-mode t)
- (set-syntax-table java-mode-syntax-table)
- (setq local-abbrev-table java-mode-abbrev-table
- abbrev-mode t)
- (use-local-map java-mode-map)
+ (setq abbrev-mode t)
(c-init-language-vars-for 'java-mode)
(c-common-init 'java-mode)
(easy-menu-add c-java-menu)
(cc-imenu-init cc-imenu-java-generic-expression)
- (c-run-mode-hooks 'c-mode-common-hook 'java-mode-hook)
- (c-update-modeline))
+ (c-run-mode-hooks 'c-mode-common-hook))
;; Support for CORBA's IDL language
@@ -1705,16 +1695,13 @@ initialization, then `idl-mode-hook'.
Key bindings:
\\{idl-mode-map}"
+ :after-hook (c-update-modeline)
(c-initialize-cc-mode t)
- (set-syntax-table idl-mode-syntax-table)
- (setq local-abbrev-table idl-mode-abbrev-table)
- (use-local-map idl-mode-map)
(c-init-language-vars-for 'idl-mode)
(c-common-init 'idl-mode)
(easy-menu-add c-idl-menu)
;;(cc-imenu-init cc-imenu-idl-generic-expression) ;TODO
- (c-run-mode-hooks 'c-mode-common-hook 'idl-mode-hook)
- (c-update-modeline))
+ (c-run-mode-hooks 'c-mode-common-hook))
;; Support for Pike
@@ -1757,17 +1744,14 @@ initialization, then `pike-mode-hook'.
Key bindings:
\\{pike-mode-map}"
+ :after-hook (c-update-modeline)
(c-initialize-cc-mode t)
- (set-syntax-table pike-mode-syntax-table)
- (setq local-abbrev-table pike-mode-abbrev-table
- abbrev-mode t)
- (use-local-map pike-mode-map)
+ (setq abbrev-mode t)
(c-init-language-vars-for 'pike-mode)
(c-common-init 'pike-mode)
(easy-menu-add c-pike-menu)
;;(cc-imenu-init cc-imenu-pike-generic-expression) ;TODO
- (c-run-mode-hooks 'c-mode-common-hook 'pike-mode-hook)
- (c-update-modeline))
+ (c-run-mode-hooks 'c-mode-common-hook))
;; Support for AWK
@@ -1821,22 +1805,18 @@ initialization, then `awk-mode-hook'.
Key bindings:
\\{awk-mode-map}"
+ :after-hook (c-update-modeline)
;; We need the next line to stop the macro defining
;; `awk-mode-syntax-table'. This would mask the real table which is
;; declared in cc-awk.el and hasn't yet been loaded.
:syntax-table nil
(require 'cc-awk) ; Added 2003/6/10.
(c-initialize-cc-mode t)
- (set-syntax-table awk-mode-syntax-table)
- (setq local-abbrev-table awk-mode-abbrev-table
- abbrev-mode t)
- (use-local-map awk-mode-map)
+ (setq abbrev-mode t)
(c-init-language-vars-for 'awk-mode)
(c-common-init 'awk-mode)
(c-awk-unstick-NL-prop)
-
- (c-run-mode-hooks 'c-mode-common-hook 'awk-mode-hook)
- (c-update-modeline))
+ (c-run-mode-hooks 'c-mode-common-hook))
;; bug reporting