@defun c-make-macro-with-semi-re
@findex make-macro-with-semi-re (c-)
Call this (non-interactive) function, which sets internal variables,
-each time you change the value of
-@code{c-macro-names-with-semicolon}. It takes no arguments, and its
+each time you change the value of @code{c-macro-names-with-semicolon}
+after the major mode function has run. It takes no arguments, and its
return value has no meaning. This function is called by @ccmode{}'s
-initialization code.
+initialization code, after the mode hooks have run.
@end defun
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@defun c-make-noise-macro-regexps
@findex make-noise-macro-regexps (c-)
Call this (non-interactive) function, which sets internal variables,
-after changing the value of @code{c-noise-macro-names} or
-@code{c-noise-macro-with-parens-names} (e.g. in a hook (@pxref{CC
-Hooks})). This function is called by @ccmode{}'s initialization code.
+on changing the value of @code{c-noise-macro-names} or
+@code{c-noise-macro-with-parens-names} after the major mode's function
+has run. This function is called by @ccmode{}'s initialization code,
+after the mode hooks have run.
@end defun
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
(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.
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))
\f
;; Support for C++
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))
\f
;; Support for Objective-C
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))
\f
;; Support for Java
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))
\f
;; Support for CORBA's IDL language
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))
\f
;; Support for Pike
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))
\f
;; Support for AWK
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))
\f
;; bug reporting
(setq offset (cdr offset)))
(null offset)))))
-
+(defun c-string-list-p (val)
+ "Return non-nil if VAL is a list of strings."
+ (and
+ (listp val)
+ (catch 'string
+ (dolist (elt val)
+ (if (not (stringp elt))
+ (throw 'string nil)))
+ t)))
+
+(defun c-string-or-string-list-p (val)
+ "Return non-nil if VAL is a string or a list of strings."
+ (or (stringp val)
+ (c-string-list-p val)))
\f
;;; User variables
this implicitly by reinitializing C/C++/Objc Mode on any buffer)."
:type '(repeat :tag "List of names" string)
:group 'c)
+(put 'c-noise-macro-names 'safe-local-variable #'c-string-list-p)
(defcustom c-noise-macro-with-parens-names nil
"A list of names of macros \(or compiler extensions like \"__attribute__\")
These are recognized by CC Mode only in declarations."
:type '(regexp :tag "List of names (possibly empty)" string)
:group 'c)
+(put 'c-noise-macro-with-parens-names 'safe-local-variable #'c-string-list-p)
(defun c-make-noise-macro-regexps ()
;; Convert `c-noise-macro-names' and `c-noise-macro-with-parens-names' into
Note that currently \(2008-11-04) this variable is a prototype,
and is likely to disappear or change its form soon.")
(make-variable-buffer-local 'c-macro-names-with-semicolon)
+(put 'c-macro-names-with-semicolon 'safe-local-variable
+ #'c-string-or-string-list-p)
(defun c-make-macro-with-semi-re ()
;; Convert `c-macro-names-with-semicolon' into the regexp