From e58f900e6d7e9118c8fd4783d87a4f122c0bccc1 Mon Sep 17 00:00:00 2001 From: Alan Mackenzie Date: Mon, 9 May 2016 18:12:52 +0000 Subject: [PATCH] Add some "safe-local-variable" declarations for compatibility with master. These enable C files from the master repository to be visited in Emacs 25 without generating irritating questions about configuration variable safety. * 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 safe-local-variable property c-string-list-p. (c-macro-names-with-semicolon): give the safe-local-variable property c-string-or-string-list-p. --- lisp/progmodes/cc-vars.el | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/lisp/progmodes/cc-vars.el b/lisp/progmodes/cc-vars.el index 8cee733ec8e..b46b9b82704 100644 --- a/lisp/progmodes/cc-vars.el +++ b/lisp/progmodes/cc-vars.el @@ -229,7 +229,20 @@ See `c-offsets-alist'." (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))) ;;; User variables @@ -1621,6 +1634,10 @@ names).")) ;; Non-customizable variables, still part of the interface to CC Mode +;; The following two are preparations for Emacs 25.2 (2016-05-09): +(put 'c-noise-macro-names 'safe-local-variable #'c-string-list-p) +(put 'c-noise-macro-with-parens-names 'safe-local-variable #'c-string-list-p) + (defvar c-macro-with-semi-re nil ;; Regular expression which matches a (#define'd) symbol whose expansion ;; ends with a semicolon. @@ -1647,6 +1664,8 @@ variables. 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 -- 2.39.2