unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#44852: [PATCH] Fix modification check when custom-form is 'lisp
@ 2020-11-24 18:51 Dario Gjorgjevski
  2020-11-26 10:59 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 2+ messages in thread
From: Dario Gjorgjevski @ 2020-11-24 18:51 UTC (permalink / raw)
  To: 44852

[-- Attachment #1: Type: text/plain, Size: 658 bytes --]

When a variable’s custom-form is 'lisp (or 'mismatch),
`custom-variable-value-create' will quote its value prior to storing it
inside the widget.  Afterwards, `custom-variable-modified-p' will try to
compare this quoted form to the (unquoted) value and think that the
variable has been modified.

To reproduce, fire up emacs -Q and do:

  1. (setq custom-variable-default-form 'lisp)
  2. M-x customize-variable RET auto-save-file-name-transforms RET

You will notice that Customize thinks that the variable has been
modified even though that is not true.  If step 1. is omitted,
everything is fine.

The patch attached below fixes that.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Fix modification check when custom-form is 'lisp --]
[-- Type: text/x-diff, Size: 1749 bytes --]

From 1e2b5ce115d67d350e27d7d3bd33ef5131cc59fa Mon Sep 17 00:00:00 2001
From: Dario Gjorgjevski <dario.gjorgjevski@gmail.com>
Date: Tue, 24 Nov 2020 17:34:08 +0100
Subject: [PATCH] Fix modification check when custom-form is 'lisp

* lisp/cus-edit.el (custom-variable-modified-p): Quote the value when
custom form is 'lisp (or 'mismatch) prior to comparing in order to
accommodate `custom-variable-value-create'.
---
 lisp/cus-edit.el | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el
index eceba8fa4d..27c0147f58 100644
--- a/lisp/cus-edit.el
+++ b/lisp/cus-edit.el
@@ -2900,14 +2900,19 @@ custom-variable-modified-p
 in a customize buffer.
 To check for other states, call `custom-variable-state'."
   (catch 'get-error
-    (let* ((symbol (widget-get widget :value))
+    (let* ((form (widget-get widget :custom-form))
+           (symbol (widget-get widget :value))
            (get (or (get symbol 'custom-get) 'default-value))
            (value (if (default-boundp symbol)
                       (condition-case nil
                           (funcall get symbol)
                         (error (throw 'get-error t)))
-                    (symbol-value symbol))))
-      (not (equal value (widget-value (car (widget-get widget :children))))))))
+                    (symbol-value symbol)))
+           (orig-value (widget-value (car (widget-get widget :children)))))
+      (not (equal (if (memq form '(lisp mismatch))
+                      (custom-quote value) ; Mimic `custom-variable-value-create'.
+                    value)
+                  orig-value)))))
 
 (defun custom-variable-state-set (widget &optional state)
   "Set the state of WIDGET to STATE.
-- 
2.28.0


[-- Attachment #3: Type: text/plain, Size: 149 bytes --]


Best regards,
Dario

-- 
$ keyserver=hkps://hkps.pool.sks-keyservers.net
$ keyid=744A4F0B4F1C9371
$ gpg --keyserver $keyserver --search-keys $keyid

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* bug#44852: [PATCH] Fix modification check when custom-form is 'lisp
  2020-11-24 18:51 bug#44852: [PATCH] Fix modification check when custom-form is 'lisp Dario Gjorgjevski
@ 2020-11-26 10:59 ` Lars Ingebrigtsen
  0 siblings, 0 replies; 2+ messages in thread
From: Lars Ingebrigtsen @ 2020-11-26 10:59 UTC (permalink / raw)
  To: Dario Gjorgjevski; +Cc: 44852

Dario Gjorgjevski <dario.gjorgjevski@gmail.com> writes:

> You will notice that Customize thinks that the variable has been
> modified even though that is not true.  If step 1. is omitted,
> everything is fine.
>
> The patch attached below fixes that.

Thanks; applied to Emacs 28.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-11-26 10:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-24 18:51 bug#44852: [PATCH] Fix modification check when custom-form is 'lisp Dario Gjorgjevski
2020-11-26 10:59 ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).