From e3b70e6b2dc5805fa92c9ddbf42fed81ed835f1b Mon Sep 17 00:00:00 2001 From: Juanma Barranquero Date: Thu, 27 Jun 2019 13:26:45 +0200 Subject: [PATCH] Add :local specifier to defcustom * lisp/custom.el (custom-declare-variable): Allow the new :local parameter (bug#14591). (defcustom): Document it. --- etc/NEWS | 5 +++++ lisp/custom.el | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/etc/NEWS b/etc/NEWS index 29b74ee682b..10882e4ec45 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1790,6 +1790,11 @@ valid event type. * Lisp Changes in Emacs 27.1 +** defcustom now takes a :local keyword that can be either t or +`permanent', which mean that the variable should be automatically +buffer-local. `permanent' also sets the variable's +`permanent-local' property. + +++ ** The new macro `with-suppressed-warnings' can be used to suppress specific byte-compile warnings. diff --git a/lisp/custom.el b/lisp/custom.el index 29bf9e570a8..736460fec7b 100644 --- a/lisp/custom.el +++ b/lisp/custom.el @@ -181,6 +181,11 @@ set to nil, as the value is no longer rogue." (put symbol 'risky-local-variable value)) ((eq keyword :safe) (put symbol 'safe-local-variable value)) + ((eq keyword :local) + (when (memq value '(t permanent)) + (make-variable-buffer-local symbol)) + (when (eq value 'permanent) + (put symbol 'permanent-local t))) ((eq keyword :type) (put symbol 'custom-type (purecopy value))) ((eq keyword :options) @@ -251,6 +256,9 @@ The following keywords are meaningful: :risky Set SYMBOL's `risky-local-variable' property to VALUE. :safe Set SYMBOL's `safe-local-variable' property to VALUE. See Info node `(elisp) File Local Variables'. +:local If VALUE is t, mark SYMBOL as automatically buffer-local. + If VALUE is `permanent', also set SYMBOL's `permanent-local' + property to t. The following common keywords are also meaningful. -- 2.39.2