* defcustom: order matters in `choice' with value-to-internal
@ 2008-03-21 20:27 Reiner Steib
2008-03-21 21:49 ` Andreas Schwab
0 siblings, 1 reply; 6+ messages in thread
From: Reiner Steib @ 2008-03-21 20:27 UTC (permalink / raw)
To: emacs-devel
Hi,
consider these two defcustoms, which only differ in the order of the
choice elements:
--8<---------------cut here---------------start------------->8---
(defcustom rs-test-1
"^From:\\|^Newsgroups:\\|^Subject:"
"doc string 1, list of regexps, regexp or nil"
:type '(choice
(const nil :tag "Use gnus-ignored-headers")
regexp
(repeat :value-to-internal (lambda (widget value)
(custom-split-regexp-maybe value))
:match (lambda (widget value)
(or (stringp value)
(widget-editable-list-match widget value)))
regexp)))
(defcustom rs-test-2
"^From:\\|^Newsgroups:\\|^Subject:"
"doc string 2, list of regexps, regexp or nil"
:type '(choice
(repeat :value-to-internal (lambda (widget value)
(custom-split-regexp-maybe value))
:match (lambda (widget value)
(or (stringp value)
(widget-editable-list-match widget value)))
regexp)
(const nil :tag "Use gnus-ignored-headers")
regexp))
--8<---------------cut here---------------end--------------->8---
In the customize buffer, I get (Emacs 22 branch):
,----[ M-x customize-apropos RET rs-test RET ]
| rs-test-1: [Hide Value] [Value Menu] Regexp: ^From:\|^Newsgroups:\|^Subject:
| [State]: STANDARD.
|
| doc string 1, list of regexps, regexp or nil
| Groups: [message-faces]
|
| rs-test-2: [Hide Value] [Value Menu] Repeat:
| [INS] [DEL] Regexp: ^From:
| [INS] [DEL] Regexp: ^Newsgroups:
| [INS] [DEL] Regexp: ^Subject:
| [INS]
| [State]: STANDARD.
|
| doc string 2, list of regexps, regexp or nil
| Groups: [message-faces]
`----
I would have expected the same, split result for both variables.
(BTW, I have now idea why "Groups: [message-faces]" is shown. Seems
like some random group?)
Bye, Reiner.
--
,,,
(o o)
---ooO-(_)-Ooo--- | PGP key available | http://rsteib.home.pages.de/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: defcustom: order matters in `choice' with value-to-internal
2008-03-21 20:27 defcustom: order matters in `choice' with value-to-internal Reiner Steib
@ 2008-03-21 21:49 ` Andreas Schwab
2008-03-22 9:22 ` Reiner Steib
2008-03-22 17:10 ` Stefan Monnier
0 siblings, 2 replies; 6+ messages in thread
From: Andreas Schwab @ 2008-03-21 21:49 UTC (permalink / raw)
To: emacs-devel
Reiner Steib <reinersteib+gmane@imap.cc> writes:
> consider these two defcustoms, which only differ in the order of the
> choice elements:
>
> (defcustom rs-test-1
> "^From:\\|^Newsgroups:\\|^Subject:"
> "doc string 1, list of regexps, regexp or nil"
> :type '(choice
> (const nil :tag "Use gnus-ignored-headers")
> regexp
> (repeat :value-to-internal (lambda (widget value)
> (custom-split-regexp-maybe value))
> :match (lambda (widget value)
> (or (stringp value)
> (widget-editable-list-match widget value)))
> regexp)))
>
> (defcustom rs-test-2
> "^From:\\|^Newsgroups:\\|^Subject:"
> "doc string 2, list of regexps, regexp or nil"
> :type '(choice
> (repeat :value-to-internal (lambda (widget value)
> (custom-split-regexp-maybe value))
> :match (lambda (widget value)
> (or (stringp value)
> (widget-editable-list-match widget value)))
> regexp)
> (const nil :tag "Use gnus-ignored-headers")
> regexp))
Order generally matters, the first matching choice is used. There is
nothing else that favors the repeat over regexp.
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: defcustom: order matters in `choice' with value-to-internal
2008-03-21 21:49 ` Andreas Schwab
@ 2008-03-22 9:22 ` Reiner Steib
2008-03-22 17:10 ` Stefan Monnier
1 sibling, 0 replies; 6+ messages in thread
From: Reiner Steib @ 2008-03-22 9:22 UTC (permalink / raw)
To: Andreas Schwab; +Cc: emacs-devel
On Fri, Mar 21 2008, Andreas Schwab wrote:
> Order generally matters, the first matching choice is used. There is
> nothing else that favors the repeat over regexp.
D'oh, of course. I must have been confused. Thanks.
Bye, Reiner.
--
,,,
(o o)
---ooO-(_)-Ooo--- | PGP key available | http://rsteib.home.pages.de/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: defcustom: order matters in `choice' with value-to-internal
2008-03-21 21:49 ` Andreas Schwab
2008-03-22 9:22 ` Reiner Steib
@ 2008-03-22 17:10 ` Stefan Monnier
2008-03-23 21:41 ` Reiner Steib
1 sibling, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2008-03-22 17:10 UTC (permalink / raw)
To: Andreas Schwab; +Cc: emacs-devel
> Order generally matters, the first matching choice is used. There is
> nothing else that favors the repeat over regexp.
But AFAICT the only difference between the two is the order between
(const nil ..) and (repeat ...): the ordering between `repeat' and
`regexp' is the same in both cases, so it still looks odd.
Stefan
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: defcustom: order matters in `choice' with value-to-internal
2008-03-22 17:10 ` Stefan Monnier
@ 2008-03-23 21:41 ` Reiner Steib
2008-03-24 1:23 ` Stefan Monnier
0 siblings, 1 reply; 6+ messages in thread
From: Reiner Steib @ 2008-03-23 21:41 UTC (permalink / raw)
To: Stefan Monnier; +Cc: Andreas Schwab, emacs-devel
On Sat, Mar 22 2008, Stefan Monnier wrote:
>> Order generally matters, the first matching choice is used. There is
>> nothing else that favors the repeat over regexp.
>
> But AFAICT the only difference between the two is the order between
> (const nil ..) and (repeat ...): the ordering between `repeat' and
> `regexp' is the same in both cases, so it still looks odd.
No, the order of `repeat regexp' and `regexp' is different:
(defcustom rs-test-1
[...]
:type '(choice
(const nil)
regexp
(repeat [...] regexp)))
(defcustom rs-test-2
[...]
:type '(choice
(repeat [...] regexp)
(const nil)
regexp))
Bye, Reiner.
--
,,,
(o o)
---ooO-(_)-Ooo--- | PGP key available | http://rsteib.home.pages.de/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: defcustom: order matters in `choice' with value-to-internal
2008-03-23 21:41 ` Reiner Steib
@ 2008-03-24 1:23 ` Stefan Monnier
0 siblings, 0 replies; 6+ messages in thread
From: Stefan Monnier @ 2008-03-24 1:23 UTC (permalink / raw)
To: Andreas Schwab; +Cc: emacs-devel
>>> Order generally matters, the first matching choice is used. There is
>>> nothing else that favors the repeat over regexp.
>>
>> But AFAICT the only difference between the two is the order between
>> (const nil ..) and (repeat ...): the ordering between `repeat' and
>> `regexp' is the same in both cases, so it still looks odd.
> No, the order of `repeat regexp' and `regexp' is different:
Duh! Sorry! Victim of my auto-unwrap hack, which hid the `regexp'
entry at the end of the (const ...) lines
Stefan
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2008-03-24 1:23 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-21 20:27 defcustom: order matters in `choice' with value-to-internal Reiner Steib
2008-03-21 21:49 ` Andreas Schwab
2008-03-22 9:22 ` Reiner Steib
2008-03-22 17:10 ` Stefan Monnier
2008-03-23 21:41 ` Reiner Steib
2008-03-24 1:23 ` Stefan Monnier
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.