From: Drew Adams <drew.adams@oracle.com>
To: Michael Albinus <michael.albinus@gmx.de>,
Michael Heerdegen <michael_heerdegen@web.de>
Cc: "62106-done@debbugs.gnu.org" <62106-done@debbugs.gnu.org>
Subject: bug#62106: 29.0.60; Emacs 29 changing user option values (?)
Date: Sat, 11 Mar 2023 17:09:42 +0000 [thread overview]
Message-ID: <SJ0PR10MB54882A96BE8EDA84CDC14883F3BB9@SJ0PR10MB5488.namprd10.prod.outlook.com> (raw)
In-Reply-To: <87mt4jfdry.fsf@gmx.de>
> > Dunno what the intention was - could we use `setopt' here?
>
> `setopt' does not really help. Using `customize-save-variable' instead
> of `customize-set-variable' does the trick.
>
> Pushed to the emacs-29 branch, closing the bug. Pls reply if it doesn't
> work as expected.
Thanks for working on this. Without studying this at all, I'm guessing that `customize-save-variable' is the wrong thing to do. Doesn't that mean that you're not only changing a user-option value, but you're also doing so permanently (persistently)? If so, isn't that even _worse_?
Wouldn't this be better - pseudo-saving, i.e., making Customize treat a changed option as if it were unchanged, _without_ saving it?
(put SYMBOL 'saved-value
(list (custom-quote (default-value SYMBOL)))))
_________
FWIW, I define these functions (commands), based on that.
;; Use this one anywhere.
;;
(defun customize-consider-all-vars-unchanged ()
"Consider all customizable variables as saved, without saving them."
(interactive)
(when (interactive-p) (message "Please wait..."))
(mapatoms
(lambda (symbol)
(when (and (or (custom-variable-p symbol)
(user-variable-p symbol))
(default-boundp symbol) ; Value neither saved nor standard.
(not (member (list (custom-quote (default-value symbol)))
(list (get symbol 'saved-value)
(get symbol 'standard-value)))))
;; Pretend the current value has been saved.
(put symbol 'saved-value (list (custom-quote (default-value symbol)))))
(put symbol 'customized-value nil)
(when (get symbol 'customized-variable-comment)
(put symbol 'saved-variable-comment
(get symbol 'customized-variable-comment)))
(put symbol 'customized-variable-comment nil)))
(message "All variables are now considered unchanged (\"saved\"),\
but they were not saved."))
________________
;; Use this in the Customize UI.
;;
(defun Custom-consider-unchanged (&rest _IGNORED)
"Consider all preferences here as being unchanged now.
This does not save the current values; it just considers them to be
unchanged values. If no further changes are made to any of these
preferences, then after doing this, `customize-customize' will not
display any of these preferences, since they were considered
unchanged."
(interactive)
(if (not (y-or-n-p "All of these values will be considered \
unchanged now, without being saved. Continue? "))
(message nil)
(message "Please wait...")
(let ((children custom-options))
(dolist (child children)
(let ((symbol (widget-get-tag-or-value child)))
(cond ((custom-facep symbol)
(custom-consider-face-unchanged child))
((custom-variable-p symbol)
(custom-consider-variable-unchanged child))))))
(message "Current values here are now considered unchanged.\
They were not saved.")))
;; Inspired from `custom-variable-save'.
;; Due to a `cus-edit.el' bug (hidden widgets are not saved), we need to temporarily
;; show hidden widgets.
;;
;; Should we (put symbol 'saved-value...) only if not
;; (eq (widget-get widget :custom-state) 'standard), as in `custom-face-save'?
;;
(defun custom-consider-variable-unchanged (widget)
"Consider this variable as being unchanged now.
This does not save the current value; it just considers the value to
be unchanged. If no further changes are made to this variable, then
after doing this, `customize-customize' will not display this
variable, since it was considered unchanged."
(message "Please wait...")
(let ((form (widget-get widget :custom-form))
(hidden-p (eq (widget-get widget :custom-state) 'hidden)))
(when hidden-p ; Show it.
(widget-put widget :custom-state 'unknown)
(custom-redraw widget)
(setq form (widget-get widget :custom-form)))
(let ((child (car (widget-get widget :children)))
(symbol (widget-value widget)))
(cond ((memq form '(lisp mismatch))
(put symbol 'saved-value (list (widget-value child))))
(t (put symbol 'saved-value
(list (custom-quote (widget-value child))))))
(put symbol 'customized-value nil)
(put symbol 'customized-variable-comment nil))
(widget-put widget :custom-state 'saved)
(when hidden-p ; Hide it again.
(widget-put widget :documentation-shown nil)
(widget-put widget :custom-state 'hidden)
(custom-redraw widget)))
(custom-redraw-magic widget)
(message "Current variable value is now considered unchanged.\
It was not saved."))
_______
https://www.emacswiki.org/emacs/download/cus-edit%2b.el
next prev parent reply other threads:[~2023-03-11 17:09 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-10 22:16 bug#62106: 29.0.60; Emacs 29 changing user option values (?) Drew Adams
2023-03-11 2:32 ` Corwin Brust
2023-03-11 3:29 ` Michael Heerdegen
2023-03-11 16:34 ` Michael Albinus
2023-03-11 17:09 ` Drew Adams [this message]
2023-03-12 10:09 ` Michael Albinus
2023-03-12 15:16 ` Drew Adams
2023-03-12 16:37 ` Michael Albinus
2023-03-12 6:19 ` Augusto Stoffel
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=SJ0PR10MB54882A96BE8EDA84CDC14883F3BB9@SJ0PR10MB5488.namprd10.prod.outlook.com \
--to=drew.adams@oracle.com \
--cc=62106-done@debbugs.gnu.org \
--cc=michael.albinus@gmx.de \
--cc=michael_heerdegen@web.de \
/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.