[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master e3b70e6 1/3: Add :local specifier to defcustom
From: |
Lars Ingebrigtsen |
Subject: |
[Emacs-diffs] master e3b70e6 1/3: Add :local specifier to defcustom |
Date: |
Thu, 27 Jun 2019 07:56:07 -0400 (EDT) |
branch: master
commit e3b70e6b2dc5805fa92c9ddbf42fed81ed835f1b
Author: Juanma Barranquero <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>
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 29b74ee..10882e4 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 29bf9e5..736460f 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.