unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Mauro Aranda <maurooaranda@gmail.com>,
	Michael Albinus <michael.albinus@gmx.de>
Cc: Eli Zaretskii <eliz@gnu.org>,
	"wyuenho@gmail.com" <wyuenho@gmail.com>,
	"63891@debbugs.gnu.org" <63891@debbugs.gnu.org>
Subject: bug#63891: 29.0.91; customize-save-variable should not save all variables if a custom file exists
Date: Sat, 28 Oct 2023 18:22:41 +0000	[thread overview]
Message-ID: <SJ0PR10MB54885280BAC73ECDBFEC241CF3A3A@SJ0PR10MB5488.namprd10.prod.outlook.com> (raw)
In-Reply-To: <0ec5d535-c4e5-401f-8db7-fc4eb54f8517@gmail.com>

> if packages are going to be changing this 2 options
> without asking the user about it, why do the packages
> need to lie to Custom saying that the user asked for
> that?  Why don't just setq, add-to-list or modify it
> some other way? At least that way Custom would know
> the truth, the setting was changed outside of Customize.
> 
> That's why I don't understand what is the expectation
> about Custom here (apart from being less naive when
> saving the custom-file).  The code is modifying a user
> option and tells Custom that it was upon the user
> request, when in fact it hasn't.
> 
> Finally, have you considered the approach of having
> the user option plus another variable which packages
> should modify when desired? Then the code could merge
> the user settings with the package settings.

Hi Mauro,

My 2 cents about such things -

1. Libraries can usefully modify user options.  They
just need to make users aware of this happening, so
that taking advantage of this is a user choice.

In particular, libraries can define commands whose
purpose includes changing option values - sometimes
even saving such changes immediately.  To me, this
isn't a no-no.  What is a no-no is changing an
option value behind a user's back, and a fortiori
saving such a change - big NO-NO.

Wrt your last paragraph above: That's the approach
that Emacs generally takes.  It's OK, though it's a
bit of a kludge.  More importantly, users can _want_
to modify an option value on the fly, as opposed to
modifying its non-option shadow/stand-in variable.

2. Emacs should make available features I noted in
previous posts, such as a function to consider a
change to an option value (by program) to not be a
change.  This lets code change a value but not
have Customize consider that a change has been
made - so the change won't be saved automatically
or reported as having occurred.

This is a _convenience_ for users, not an obstacle:
be able to change behavior that's usually governed
by an option, without having Customize barf or save
the changes.  In effect, it's being able to use an
option temporarily as if it were not an option.

3. Emacs should also make available the ability for
`defvar' (or a new macro) to use the features of
`defcustom'.  In particular, this includes :set and
:type, and it includes the ability to persist the
value.

The difference between this and `defcustom' is that
uch variables aren't recognized by Emacs as user
options.  Users can't use the Customize UI or
`set-variable' with such vars.  `C-h v' provides no
`customize' link, etc.
___

#3 is maybe the most relevant to the points you
raised, but I also wanted to mention #1 and #2.

I proposed #3 to emacs-devel@gnu.org back in 2009:

https://lists.gnu.org/archive/html/emacs-devel/2009-10/msg00668.html

I sent a patch for #3 as bug #27348 (closed by Lars,
saying that no one would want such a feature):

https://debbugs.gnu.org/cgi/bugreport.cgi?bug=27348

That patch, with a couple trivial tweaks, is still
valid against Emacs 29, I believe.

It adds keyword `:not-custom-var' to `defcustom'.
If its value is non-`nil' then the variable doesn't
satisfy `custom-variable-p', which means it's _not
available for interactive use_ (completion,
`set-variable', `apropos-user-option' output, etc.).
IOW, such a variable is for code more than for user
configuration.

The patch also defines macro `defvarc', which is
just `defmacro' with `:not-custom-var' set to `t'.

The `defcustom' keywords etc. could have just been
added to `defvar' for optional use.  I defined a
separate macro just to not interfere with any
existing uses of `defvar'.

In sum, this uncouples interactive customization
from the other features that Customize offers, in
particular, type-checking and persistence, and it
provides those features for non-option variables.

The ability to type-check, provide `:set' and
`:initialize' trigger functions, automatically
`:require' libraries, add links to doc, associate
with one or more `:groups', etc.  These are useful
things to be able to do with at least some defvars,
not just with defcustoms.

Similarly, the ability to persist non-option vars
in a user's custom file can be useful.  This alone
is a frequent question, to which the answer has
been `savehist-additional-variables', `desktop.el',
or Bookmark+ variable-list bookmarks.

The patch also includes a macro `with-user-vars',
which temporarily lets a set of variables be
customizable.  That is, it lets you treat a
`defvarc' variable as if it were a `defcustom'
option.  So if you want, you can use the Customize
UI to change a defvarc's value, or define commands
that use (e.g. complete) `defvarc' variable names.

  reply	other threads:[~2023-10-28 18:22 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <ae449be5-9a4c-4e7e-b624-deae8a27fbbb@gmail.com>
2023-10-27 10:57 ` bug#63891: 29.0.91; customize-save-variable should not save all variables if a custom file exists Mauro Aranda
2023-10-27 11:51   ` Michael Albinus
2023-10-27 15:44     ` Mauro Aranda
2023-10-28  9:58     ` Mauro Aranda
2023-10-28 18:22       ` Drew Adams [this message]
2023-10-28 22:32         ` Mauro Aranda
2023-10-29  2:20           ` Drew Adams
2023-10-29 10:33             ` Mauro Aranda
2023-10-29 11:07               ` Michael Albinus
2023-10-29 11:50                 ` Mauro Aranda
2023-06-04 12:36 Jimmy Yuen Ho Wong
2023-06-04 12:56 ` Eli Zaretskii
2023-06-04 13:02   ` Jimmy Wong
2023-06-04 13:23     ` Eli Zaretskii
2023-06-04 14:00       ` Jimmy Wong
2023-06-04 14:26         ` Eli Zaretskii
2023-06-04 16:49           ` Jimmy Wong
2023-06-06 12:01           ` Michael Albinus
2023-06-06 12:20             ` Eli Zaretskii
2023-06-06 12:36               ` Michael Albinus

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=SJ0PR10MB54885280BAC73ECDBFEC241CF3A3A@SJ0PR10MB5488.namprd10.prod.outlook.com \
    --to=drew.adams@oracle.com \
    --cc=63891@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=maurooaranda@gmail.com \
    --cc=michael.albinus@gmx.de \
    --cc=wyuenho@gmail.com \
    /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 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).