unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Bad value to a defcustom makes choices unavailable
@ 2005-08-01 15:45 Lennart Borgman
  2005-08-01 17:41 ` Luc Teirlinck
  0 siblings, 1 reply; 10+ messages in thread
From: Lennart Borgman @ 2005-08-01 15:45 UTC (permalink / raw)


If the value of a defcustom with ":type '(choices ...)" has a bad value 
then the choice menu is unavailable. Try the following for example:

(defcustom xhtml-help-refurl "ttp://www.site1.com/"
  "Web url to get references from."
  :type '(choice (const "http://www.site1.com/")
                 (const "http://www.site2.com//")
                 ))

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

* Re: Bad value to a defcustom makes choices unavailable
  2005-08-01 15:45 Bad value to a defcustom makes choices unavailable Lennart Borgman
@ 2005-08-01 17:41 ` Luc Teirlinck
  2005-08-01 17:50   ` Lennart Borgman
  0 siblings, 1 reply; 10+ messages in thread
From: Luc Teirlinck @ 2005-08-01 17:41 UTC (permalink / raw)
  Cc: emacs-devel

Lennart Borgman wrote:

   If the value of a defcustom with ":type '(choices ...)" has a bad value 
   then the choice menu is unavailable.

Just end your choice menu with the `other' type, then this will not happen.
Of course, you must make `other' have a sensible value.

Sincerely,

Luc.

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

* Re: Bad value to a defcustom makes choices unavailable
  2005-08-01 17:41 ` Luc Teirlinck
@ 2005-08-01 17:50   ` Lennart Borgman
  2005-08-01 17:58     ` Luc Teirlinck
  0 siblings, 1 reply; 10+ messages in thread
From: Lennart Borgman @ 2005-08-01 17:50 UTC (permalink / raw)
  Cc: emacs-devel

Luc Teirlinck wrote:

>Lennart Borgman wrote:
>
>   If the value of a defcustom with ":type '(choices ...)" has a bad value 
>   then the choice menu is unavailable.
>
>Just end your choice menu with the `other' type, then this will not happen.
>Of course, you must make `other' have a sensible value.
>  
>
Thanks Luc, but would it not be good if the choice menu were still 
available without adding this?

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

* Re: Bad value to a defcustom makes choices unavailable
  2005-08-01 17:50   ` Lennart Borgman
@ 2005-08-01 17:58     ` Luc Teirlinck
       [not found]       ` <42EE665A.3060208@student.lu.se>
  0 siblings, 1 reply; 10+ messages in thread
From: Luc Teirlinck @ 2005-08-01 17:58 UTC (permalink / raw)
  Cc: emacs-devel

Lennart Borgman wrote:

   Thanks Luc, but would it not be good if the choice menu were still 
   available without adding this?

What value would it have to display?  The point of the `other' type is
to tell Custom what it needs to do if the actual value is not in its
list of choices.

Sincerely,

Luc.

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

* Re: Bad value to a defcustom makes choices unavailable
       [not found]         ` <200508011820.j71IKNr05302@raven.dms.auburn.edu>
@ 2005-08-01 18:29           ` Lennart Borgman
  2005-08-01 20:17             ` Luc Teirlinck
  2005-08-02 16:09             ` Per Abrahamsen
  0 siblings, 2 replies; 10+ messages in thread
From: Lennart Borgman @ 2005-08-01 18:29 UTC (permalink / raw)
  Cc: emacs-devel

Luc Teirlinck wrote:

>Lennart Borgman wrote:
>
>   Maybe I am misunderstanding you, but in my case I want another value 
>   than the available choices to be an error. I want the user to be able to 
>   correct this by choosing one of the available alternatives (ie if they 
>   were available).
>
>The illegal value could only have been obtained by the user setting it
>outside Custom, for instance with a setq in his .emacs.  The user can
>not reliably correct the problem through Custom, he has to correct the
>problem where the problem originated (probably .emacs).
>  
>
Let us say that someone writes a defcustom in a package he distributes. 
Later she/he for some reason changes the list of choices. If a user has 
saved a value through custom that now no longer exists he can not 
correct it through custom. Perhaps the user does not know elisp at all.

I think it would be good then if the list of choices were available.

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

* Re: Bad value to a defcustom makes choices unavailable
  2005-08-01 18:29           ` Lennart Borgman
@ 2005-08-01 20:17             ` Luc Teirlinck
  2005-08-01 20:38               ` Lennart Borgman
  2005-08-02 16:09             ` Per Abrahamsen
  1 sibling, 1 reply; 10+ messages in thread
From: Luc Teirlinck @ 2005-08-01 20:17 UTC (permalink / raw)
  Cc: emacs-devel

Lennart Borgman wrote:

   Let us say that someone writes a defcustom in a package he distributes. 
   Later she/he for some reason changes the list of choices. If a user has 
   saved a value through custom that now no longer exists he can not 
   correct it through custom.

Actually, I would guess that Custom will not allow you to set it to an
illegal value in your custom-set-variables form.  Did you actually try
it?

Sincerely,

Luc.

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

* Re: Bad value to a defcustom makes choices unavailable
  2005-08-01 20:17             ` Luc Teirlinck
@ 2005-08-01 20:38               ` Lennart Borgman
  0 siblings, 0 replies; 10+ messages in thread
From: Lennart Borgman @ 2005-08-01 20:38 UTC (permalink / raw)
  Cc: emacs-devel

Luc Teirlinck wrote:

>Lennart Borgman wrote:
>
>   Let us say that someone writes a defcustom in a package he distributes. 
>   Later she/he for some reason changes the list of choices. If a user has 
>   saved a value through custom that now no longer exists he can not 
>   correct it through custom.
>
>Actually, I would guess that Custom will not allow you to set it to an
>illegal value in your custom-set-variables form.  Did you actually try
>it?
>  
>
Of course I did not try...  ;-)

Sorry, no I did not try, but yes, custom-set-variables of course no 
nothing about the choices if the package is not loaded. And when I 
tested now I found that even in the case where the package is loaded 
custom will set the bad value.

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

* Re: Bad value to a defcustom makes choices unavailable
  2005-08-01 18:29           ` Lennart Borgman
  2005-08-01 20:17             ` Luc Teirlinck
@ 2005-08-02 16:09             ` Per Abrahamsen
  2005-08-02 17:26               ` Lennart Borgman
  1 sibling, 1 reply; 10+ messages in thread
From: Per Abrahamsen @ 2005-08-02 16:09 UTC (permalink / raw)


Lennart Borgman <lennart.borgman.073@student.lu.se> writes:

> Let us say that someone writes a defcustom in a package he distributes. 
> Later she/he for some reason changes the list of choices. If a user has 
> saved a value through custom that now no longer exists he can not 
> correct it through custom.

He can, unless that functionality has been changed.  Customize will
present the invalid value in an sexp widget.  Which seems the most
reasonable thing to in the general case.

If he don't know what to do with an sexp, he can do a "Reset to
standard value", and then use the structured editor.

> I think it would be good then if the list of choices were available.

You could special case the "choice" widget (most widget can have
"invalid value", so the problem is general).  But I don't think the
code complexity would outweigh the minor convenience of not having to
do a "Reset to standard" first.

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

* Re: Bad value to a defcustom makes choices unavailable
  2005-08-02 16:09             ` Per Abrahamsen
@ 2005-08-02 17:26               ` Lennart Borgman
  2005-08-03 10:24                 ` Per Abrahamsen
  0 siblings, 1 reply; 10+ messages in thread
From: Lennart Borgman @ 2005-08-02 17:26 UTC (permalink / raw)
  Cc: emacs-devel

Per Abrahamsen wrote:

>>Let us say that someone writes a defcustom in a package he distributes. 
>>Later she/he for some reason changes the list of choices. If a user has 
>>saved a value through custom that now no longer exists he can not 
>>correct it through custom.
>>    
>>
>
>He can, unless that functionality has been changed.  Customize will
>present the invalid value in an sexp widget.  Which seems the most
>reasonable thing to in the general case.
>
>If he don't know what to do with an sexp, he can do a "Reset to
>standard value", and then use the structured editor.
>
>  
>
>>I think it would be good then if the list of choices were available.
>>    
>>
>
>You could special case the "choice" widget (most widget can have
>"invalid value", so the problem is general).  But I don't think the
>code complexity would outweigh the minor convenience of not having to
>do a "Reset to standard" first.
>  
>
I believe "Reset to standard value" has changed name to "Erase 
Customization". Yes, you can use that, but the list of choices does not 
appear until next time you run customize. Is not that quite a bit 
confusing? Are you saying that it would be hard to redraw the widget in 
those cases?

Here is some new test code for those who want to see what is going on:

(custom-set-variables '(test-choice "Bad choice"))
(setq test-choice "A very bad choice!")
(customize-option-other-window 'test-choice)

(defcustom test-choice "AAA"
 "Testing of bad choices."
 :type '(choice (const "AAA")
                (const "BBB")))

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

* Re: Bad value to a defcustom makes choices unavailable
  2005-08-02 17:26               ` Lennart Borgman
@ 2005-08-03 10:24                 ` Per Abrahamsen
  0 siblings, 0 replies; 10+ messages in thread
From: Per Abrahamsen @ 2005-08-03 10:24 UTC (permalink / raw)


Lennart Borgman <lennart.borgman.073@student.lu.se> writes:

> Yes, you can use that, but the list of choices does not 
> appear until next time you run customize. Is not that quite a bit 
> confusing? Are you saying that it would be hard to redraw the widget in 
> those cases?

No, doing that would be a good idea.

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

end of thread, other threads:[~2005-08-03 10:24 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-08-01 15:45 Bad value to a defcustom makes choices unavailable Lennart Borgman
2005-08-01 17:41 ` Luc Teirlinck
2005-08-01 17:50   ` Lennart Borgman
2005-08-01 17:58     ` Luc Teirlinck
     [not found]       ` <42EE665A.3060208@student.lu.se>
     [not found]         ` <200508011820.j71IKNr05302@raven.dms.auburn.edu>
2005-08-01 18:29           ` Lennart Borgman
2005-08-01 20:17             ` Luc Teirlinck
2005-08-01 20:38               ` Lennart Borgman
2005-08-02 16:09             ` Per Abrahamsen
2005-08-02 17:26               ` Lennart Borgman
2005-08-03 10:24                 ` Per Abrahamsen

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).