From: "Basil L. Contovounesios" <contovob@tcd.ie>
To: Glenn Morris <rgm@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: master 45a1653: ; Fix last change to bibtex.el
Date: Wed, 18 Nov 2020 16:18:10 +0000 [thread overview]
Message-ID: <87k0uizlj1.fsf@tcd.ie> (raw)
In-Reply-To: <87d00a28f3.fsf@tcd.ie> (Basil L. Contovounesios's message of "Wed, 18 Nov 2020 11:47:44 +0000")
[-- Attachment #1: Type: text/plain, Size: 1133 bytes --]
"Basil L. Contovounesios" <contovob@tcd.ie> writes:
> Glenn Morris <rgm@gnu.org> writes:
>
>>> commit 45a1653afa8eb0032908bc94b5466604f84805d5
>>
>>> diff --git a/lisp/textmodes/bibtex.el b/lisp/textmodes/bibtex.el
>>> index b69d715..d53cfa0 100644
>>> --- a/lisp/textmodes/bibtex.el
>>> +++ b/lisp/textmodes/bibtex.el
>>
>> [...]
>>
>>> - (function :tag "Conversion function")))
>>> -(make-variable-buffer-local 'bibtex-unify-case-convert)
>>> + (function :tag "Conversion function"))
>>> + :local t)
>>
>> After this change:
>>
>> bibtex-unify-case-convert:
>> Its value is nil
>> Original value was ‘identity’
>>
>> The "nil" value causes a test failure: https://hydra.nixos.org/build/130666989
>>
>> (Perhaps defcustom's recently added :local feature, of which this is the
>> only user, is broken.)
>
> Right. I'll remove the :local for now, as per Roland's suggestion, and
> see if I can get the tag working as intended later.
How's the attached fix?
Eli, Lars: since :local is new in Emacs 27, can this patch be applied to
emacs-27?
Thanks,
--
Basil
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-handling-of-defcustom-local-tag.patch --]
[-- Type: text/x-diff, Size: 4252 bytes --]
From b7dc7517bdef46a080b3ca9b7ac8c2f34065da3d Mon Sep 17 00:00:00 2001
From: "Basil L. Contovounesios" <contovob@tcd.ie>
Date: Wed, 18 Nov 2020 12:53:03 +0000
Subject: [PATCH] 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.
---
lisp/custom.el | 10 +++++++---
test/lisp/custom-tests.el | 38 ++++++++++++++++++++++++++++++++++++++
2 files changed, 45 insertions(+), 3 deletions(-)
diff --git a/lisp/custom.el b/lisp/custom.el
index 885c486c5e..cdfd221216 100644
--- a/lisp/custom.el
+++ b/lisp/custom.el
@@ -157,7 +157,9 @@ custom-declare-variable
(if (keywordp doc)
(error "Doc string is missing"))
(let ((initialize #'custom-initialize-reset)
- (requests nil))
+ (requests nil)
+ ;; Whether automatically buffer-local.
+ buffer-local)
(unless (memq :group args)
(custom-add-to-group (custom-current-group) symbol 'custom-variable))
(while args
@@ -183,7 +185,7 @@ custom-declare-variable
(put symbol 'safe-local-variable value))
((eq keyword :local)
(when (memq value '(t permanent))
- (make-variable-buffer-local symbol))
+ (setq buffer-local t))
(when (eq value 'permanent)
(put symbol 'permanent-local t)))
((eq keyword :type)
@@ -205,7 +207,9 @@ custom-declare-variable
(put symbol 'custom-requests requests)
;; Do the actual initialization.
(unless custom-dont-initialize
- (funcall initialize symbol default)))
+ (funcall initialize symbol default))
+ (when buffer-local
+ (make-variable-buffer-local symbol)))
(run-hooks 'custom-define-hook)
symbol)
diff --git a/test/lisp/custom-tests.el b/test/lisp/custom-tests.el
index 766e484498..e71b7913f0 100644
--- a/test/lisp/custom-tests.el
+++ b/test/lisp/custom-tests.el
@@ -151,4 +151,42 @@ custom-test-show-comment-preserves-changes
(widget-apply field :value-to-internal origvalue)
"bar"))))))
+(defcustom custom--test-local-option 'initial
+ "Buffer-local user option for testing."
+ :group 'emacs
+ :type '(choice (const initial) (const changed))
+ :local t)
+
+(defcustom custom--test-permanent-option 'initial
+ "Permanently local user option for testing."
+ :group 'emacs
+ :type '(choice (const initial) (const changed))
+ :local 'permanent)
+
+(ert-deftest custom-test-local-option ()
+ "Test :local user options."
+ ;; Initial default values.
+ (should (eq custom--test-local-option 'initial))
+ (should (eq custom--test-permanent-option 'initial))
+ (should (eq (default-value 'custom--test-local-option) 'initial))
+ (should (eq (default-value 'custom--test-permanent-option) 'initial))
+ (let ((obuf (current-buffer)))
+ (with-temp-buffer
+ ;; Changed buffer-local values.
+ (setq custom--test-local-option 'changed)
+ (setq custom--test-permanent-option 'changed)
+ (should (eq custom--test-local-option 'changed))
+ (should (eq custom--test-permanent-option 'changed))
+ (should (eq (default-value 'custom--test-local-option) 'initial))
+ (should (eq (default-value 'custom--test-permanent-option) 'initial))
+ (with-current-buffer obuf
+ (should (eq custom--test-local-option 'initial))
+ (should (eq custom--test-permanent-option 'initial)))
+ ;; Permanent variable remains unchanged.
+ (kill-all-local-variables)
+ (should (eq custom--test-local-option 'initial))
+ (should (eq custom--test-permanent-option 'changed))
+ (should (eq (default-value 'custom--test-local-option) 'initial))
+ (should (eq (default-value 'custom--test-permanent-option) 'initial)))))
+
;;; custom-tests.el ends here
--
2.29.2
next prev parent reply other threads:[~2020-11-18 16:18 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20201116233108.21940.22514@vcs0.savannah.gnu.org>
[not found] ` <20201116233110.4E83E209DE@vcs0.savannah.gnu.org>
2020-11-18 1:42 ` master 45a1653: ; Fix last change to bibtex.el Glenn Morris
2020-11-18 4:19 ` Roland Winkler
2020-11-18 12:30 ` Basil L. Contovounesios
2020-11-18 14:13 ` Roland Winkler
2020-11-18 14:36 ` Roland Winkler
2020-11-18 16:35 ` Basil L. Contovounesios
2020-11-18 17:11 ` Roland Winkler
2020-11-18 21:31 ` Stefan Monnier
2020-11-18 21:56 ` Roland Winkler
2020-11-28 22:32 ` Roland Winkler
2020-11-19 5:23 ` Richard Stallman
2020-11-19 8:25 ` Roland Winkler
2020-11-18 11:47 ` Basil L. Contovounesios
2020-11-18 16:18 ` Basil L. Contovounesios [this message]
2020-11-24 6:31 ` Lars Ingebrigtsen
2020-11-24 15:35 ` Eli Zaretskii
2020-11-24 19:26 ` Basil L. Contovounesios
2020-11-24 19:58 ` Eli Zaretskii
2020-11-24 20:25 ` Eli Zaretskii
2020-11-24 21:01 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87k0uizlj1.fsf@tcd.ie \
--to=contovob@tcd.ie \
--cc=emacs-devel@gnu.org \
--cc=rgm@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.