aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/custom.el
diff options
context:
space:
mode:
authorBasil L. Contovounesios2020-11-18 12:53:03 +0000
committerBasil L. Contovounesios2020-11-24 16:50:37 +0000
commitdea3d6aa18e54f0d8d75cd219b511bac5b3c87b1 (patch)
treef88602aab719cf200a3c265c3a893c415aa23c14 /lisp/custom.el
parentb2ee6650243ed2777f3a6c400f194f770f00da6f (diff)
downloademacs-dea3d6aa18e54f0d8d75cd219b511bac5b3c87b1.tar.gz
emacs-dea3d6aa18e54f0d8d75cd219b511bac5b3c87b1.zip
Fix handling of defcustom :local tag
For discussion, see the following emacs-devel thread: https://lists.gnu.org/r/emacs-devel/2020-11/msg00734.html * lisp/custom.el (custom-declare-variable): Delay call to make-variable-buffer-local until after user option has been initialized with a value. Otherwise the user option may be initialized to nil. * test/lisp/custom-tests.el (custom--test-local-option) (custom--test-permanent-option): New :local user options. (custom-test-local-option): New test for defcustom :local keyword.
Diffstat (limited to 'lisp/custom.el')
-rw-r--r--lisp/custom.el10
1 files changed, 7 insertions, 3 deletions
diff --git a/lisp/custom.el b/lisp/custom.el
index 885c486c5e4..cdfd2212169 100644
--- a/lisp/custom.el
+++ b/lisp/custom.el
@@ -157,7 +157,9 @@ set to nil, as the value is no longer rogue."
157 (if (keywordp doc) 157 (if (keywordp doc)
158 (error "Doc string is missing")) 158 (error "Doc string is missing"))
159 (let ((initialize #'custom-initialize-reset) 159 (let ((initialize #'custom-initialize-reset)
160 (requests nil)) 160 (requests nil)
161 ;; Whether automatically buffer-local.
162 buffer-local)
161 (unless (memq :group args) 163 (unless (memq :group args)
162 (custom-add-to-group (custom-current-group) symbol 'custom-variable)) 164 (custom-add-to-group (custom-current-group) symbol 'custom-variable))
163 (while args 165 (while args
@@ -183,7 +185,7 @@ set to nil, as the value is no longer rogue."
183 (put symbol 'safe-local-variable value)) 185 (put symbol 'safe-local-variable value))
184 ((eq keyword :local) 186 ((eq keyword :local)
185 (when (memq value '(t permanent)) 187 (when (memq value '(t permanent))
186 (make-variable-buffer-local symbol)) 188 (setq buffer-local t))
187 (when (eq value 'permanent) 189 (when (eq value 'permanent)
188 (put symbol 'permanent-local t))) 190 (put symbol 'permanent-local t)))
189 ((eq keyword :type) 191 ((eq keyword :type)
@@ -205,7 +207,9 @@ set to nil, as the value is no longer rogue."
205 (put symbol 'custom-requests requests) 207 (put symbol 'custom-requests requests)
206 ;; Do the actual initialization. 208 ;; Do the actual initialization.
207 (unless custom-dont-initialize 209 (unless custom-dont-initialize
208 (funcall initialize symbol default))) 210 (funcall initialize symbol default))
211 (when buffer-local
212 (make-variable-buffer-local symbol)))
209 (run-hooks 'custom-define-hook) 213 (run-hooks 'custom-define-hook)
210 symbol) 214 symbol)
211 215