unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Eli Zaretskii <eliz@gnu.org>, Drew Adams <drew.adams@oracle.com>
Cc: 23926@debbugs.gnu.org, npostavs@users.sourceforge.net
Subject: bug#23926: defcustom with STANDARD=<non-pure-expression> gives confusing results
Date: Sun, 10 Jul 2016 10:18:29 -0700 (PDT)	[thread overview]
Message-ID: <ff33c2cc-337a-433b-a87a-0ea1814311d2@default> (raw)
In-Reply-To: <<83zipqg3e3.fsf@gnu.org>>

> > > > 2. Is it not a bug that Customize tells you that the value
> > > >    was changed outside Customize?  In what way was it
> > > >    changed outside Customize?  In fact, it was not even
> > > >    changed.
> > >
> > > It was changed,
> >
> > The option value was changed?  I don't think so.
> 
> Yes, it was changed, because the value returned by the function
> changes each time it's called.

What function?  And what occurrence of calling it do you think
is responsible for this characterization of the value having
been changed outside Customize?

The fact is that the user did NOT change the value outside
customize.  And in fact, the value has NOT been changed.
It is what it was when the defcustom was evaluated.

The responsible code is `custom-variable-state', specifically
this part:

(setq tmp (get symbol 'standard-value))
(if (condition-case nil
        (and (equal value (eval (car tmp))) (equal comment nil))
      (error nil))
    'standard
  'changed)

That tests whether the current value (var VALUE here), which
in this case came from (default-value 'time), is equal to
the result of RE-evaluating the defining defcustom sexp,
(current-time).  And of course it is not equal, because
time passes...

The reason it is not unequal is NOT because something has
changed the option value outside Customize.  The option
value has not been changed at all.  What "changes" here is
the result of evaluating the initial sexp.

IOW, the "changed-outside-Customize" test used is too simplistic.  

Note that the code does try to correct its own logic in some
cases - for example, in this case:

;; The value was originally set outside
;; custom, but it was set to the standard
;; value (probably an autoloaded defcustom).

This but shows another case where its too-simplistic logic
trips it up, but this case is not being handled (compensated
for).

Nothing, including anything the user has done, has changed
the value outside Customize.  But the customize code is, so
far, unable to recognize that.

The code blithely assumes that evaluating what `custom-get'
returns represents the original value, whereas what it returns
is the result of RE-evaluating the original sexp.  That is
precisely the point of this bug.

The code correctly compensates in the case mentioned in
the comment cited above.  But it does not compensate in
the case demonstrated by the simple recipe Noam provided:

(defcustom time (current-time-string) "the time" :type 'string)

A _single_ evaluation of that defcustom should not throw
Customize off into thinking that the value has been changed
outside Customize.  And that is what is happening, because
its determination of "changed outside Customize" is too
simplistic.

> > See above.  Do you still think this is not a bug?
> 
> Of course, I do.  Maybe you don't realize how many times
> Emacs evaluates the value of a defcustom, but I do.

Please don't patronize us.  Everyone respects your understanding
of Emacs and Customize, but in this case I think you are wrong.

It is not a question of "how many times Emacs evaluates the
value of a defcustom".  It is about Emacs interpreting a
difference in the value returned by evaluating the defcustom
defining sexp from the current value as always representing a
change in the value of the variable (and outside Customize, to
boot).

I think we understand what is happening.  For us, telling the
user that the value has CHANGED from its original setting is
clearly wrong, since the VALUE has not changed.

And saying that it was changed outside Customize is doubly
wrong, since no user code or user action has done anything
to the value anywhere, including outside Customize.  This is
Customize stepping stepping on its own feet, and as a result
misleading users.

As for _fixing_ this part of the bug (the misleading state):

I don't see a solution other than doing either of these, but
other ideas are welcome:

1. Save also the original _value_ and compare the current
   value with that, instead of with the result of reevaluating
   the standard-value sexp.

2. Try to better characterize the state to users.  Instead
   of calling it changed-outside-customize, somehow indicate
   what it really means: the current value is not the same
   as what you get by reevaluating the defining sexp.

And then there is the other part of this bug: what to do for
`C-h v'.  I'll speak to that in a separate reply.





  parent reply	other threads:[~2016-07-10 17:18 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <<CAM-tV-8cG3gLgf-A+wBYPZWNy2WPGFV3uEdNE7=ad3oq4rXmnw@mail.gmail.com>
     [not found] ` <<83vb0fgu83.fsf@gnu.org>
2016-07-09 14:09   ` bug#23926: defcustom with STANDARD=<non-pure-expression> gives confusing results Drew Adams
2016-07-09 14:12     ` Eli Zaretskii
     [not found]       ` <<c0dd88c2-51ef-4f4f-964c-f0254db970f7@default>
     [not found]         ` <<83zipqg3e3.fsf@gnu.org>
2016-07-10 17:18           ` Drew Adams [this message]
2016-07-11 18:52             ` Eli Zaretskii
     [not found] <<<<<CAM-tV-8cG3gLgf-A+wBYPZWNy2WPGFV3uEdNE7=ad3oq4rXmnw@mail.gmail.com>
     [not found] ` <<<<<83vb0fgu83.fsf@gnu.org>
     [not found]   ` <<<<443f2e44-5167-48e7-abc6-cce1e243461e@default>
     [not found]     ` <<<<8337nihpdw.fsf@gnu.org>
     [not found]       ` <<<c0dd88c2-51ef-4f4f-964c-f0254db970f7@default>
     [not found]         ` <<<83zipqg3e3.fsf@gnu.org>
     [not found]           ` <<ff33c2cc-337a-433b-a87a-0ea1814311d2@default>
     [not found]             ` <<83bn24c8io.fsf@gnu.org>
2016-07-12  0:53               ` Drew Adams
     [not found] <<<CAM-tV-8cG3gLgf-A+wBYPZWNy2WPGFV3uEdNE7=ad3oq4rXmnw@mail.gmail.com>
     [not found] ` <<<83vb0fgu83.fsf@gnu.org>
     [not found]   ` <<443f2e44-5167-48e7-abc6-cce1e243461e@default>
     [not found]     ` <<8337nihpdw.fsf@gnu.org>
2016-07-09 14:59       ` Drew Adams
2016-07-09 16:52         ` Eli Zaretskii
2016-07-09 20:48           ` npostavs
2016-07-10 14:19             ` Eli Zaretskii
     [not found]           ` <<871t32ilm0.fsf@users.sourceforge.net>
     [not found]             ` <<83k2gtfue4.fsf@gnu.org>
2016-07-10 17:18               ` Drew Adams
2016-07-11 18:40                 ` Eli Zaretskii
2016-07-09  3:11 Noam Postavsky
2016-07-09  6:31 ` Drew Adams
2016-07-09  7:13 ` Eli Zaretskii
2016-07-09 11:54   ` npostavs
2016-07-09 12:31     ` Eli Zaretskii
2016-07-09 12:55       ` Noam Postavsky
2016-07-09 13:14         ` Eli Zaretskii
2016-07-09 13:48           ` Noam Postavsky
2016-07-09 14:03             ` Eli Zaretskii
2016-07-12  3:26               ` npostavs
2016-07-12  5:20                 ` Eli Zaretskii
2016-07-09 14:34             ` Drew Adams
     [not found]             ` <<8360sehps4.fsf@gnu.org>
2016-07-09 14:54               ` Drew Adams
2016-07-09 15:09                 ` Drew Adams
2016-07-10 17:23                 ` Drew Adams
2023-10-17 14:19 ` bug#23926: defcustom with STANDARD=<non-constant-expression> " Mauro Aranda
2023-10-17 14:29   ` Mauro Aranda
     [not found] <<<<CAM-tV-8cG3gLgf-A+wBYPZWNy2WPGFV3uEdNE7=ad3oq4rXmnw@mail.gmail.com>
     [not found] ` <<<<83vb0fgu83.fsf@gnu.org>
     [not found]   ` <<<443f2e44-5167-48e7-abc6-cce1e243461e@default>

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=ff33c2cc-337a-433b-a87a-0ea1814311d2@default \
    --to=drew.adams@oracle.com \
    --cc=23926@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=npostavs@users.sourceforge.net \
    /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).