* regex-opt does not accept 'symbol as second arg?
@ 2008-10-11 10:02 Xah
2008-10-11 11:41 ` Lennart Borgman
0 siblings, 1 reply; 9+ messages in thread
From: Xah @ 2008-10-11 10:02 UTC (permalink / raw)
To: help-gnu-emacs
the regexp-opt accept a second argument of “'word”, but it doesn't
accept “'symbol”?
Shouldn't it?
Xah
∑ http://xahlee.org/
☄
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: regex-opt does not accept 'symbol as second arg?
2008-10-11 10:02 regex-opt does not accept 'symbol as second arg? Xah
@ 2008-10-11 11:41 ` Lennart Borgman
2008-10-11 12:10 ` Nikolaj Schumacher
[not found] ` <mailman.850.1223727025.25473.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 9+ messages in thread
From: Lennart Borgman @ 2008-10-11 11:41 UTC (permalink / raw)
To: Xah; +Cc: help-gnu-emacs
On Sat, Oct 11, 2008 at 12:02 PM, Xah <xahlee@gmail.com> wrote:
> the regexp-opt accept a second argument of "'word", but it doesn't
> accept "'symbol"?
>
> Shouldn't it?
Would not the semantics be exactly the same?
But one thing I think would be useful is to be able to use numbers for
the PAREN argument to get an explicitly numbered regexp group back.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: regex-opt does not accept 'symbol as second arg?
2008-10-11 11:41 ` Lennart Borgman
@ 2008-10-11 12:10 ` Nikolaj Schumacher
2008-10-11 12:20 ` Lennart Borgman
[not found] ` <mailman.850.1223727025.25473.help-gnu-emacs@gnu.org>
1 sibling, 1 reply; 9+ messages in thread
From: Nikolaj Schumacher @ 2008-10-11 12:10 UTC (permalink / raw)
To: Lennart Borgman; +Cc: help-gnu-emacs, Xah
"Lennart Borgman" <lennart.borgman@gmail.com> wrote:
> On Sat, Oct 11, 2008 at 12:02 PM, Xah <xahlee@gmail.com> wrote:
>> the regexp-opt accept a second argument of "'word", but it doesn't
>> accept "'symbol"?
>>
>> Shouldn't it?
Sure, why not.
> Would not the semantics be exactly the same?
No, "\\<\\(\\w\\|\\s_+\\)+" (word delimiters) doesn't match the entire
lisp symbol `-test'.
> But one thing I think would be useful is to be able to use numbers for
> the PAREN argument to get an explicitly numbered regexp group back.
Is it possible to modify the numbering at all? If so, how?
regards,
Nikolaj Schumacher
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: regex-opt does not accept 'symbol as second arg?
2008-10-11 12:10 ` Nikolaj Schumacher
@ 2008-10-11 12:20 ` Lennart Borgman
2008-10-11 13:01 ` Nikolaj Schumacher
0 siblings, 1 reply; 9+ messages in thread
From: Lennart Borgman @ 2008-10-11 12:20 UTC (permalink / raw)
To: Nikolaj Schumacher; +Cc: help-gnu-emacs, Xah
On Sat, Oct 11, 2008 at 2:10 PM, Nikolaj Schumacher <me@nschum.de> wrote:
> "Lennart Borgman" <lennart.borgman@gmail.com> wrote:
>
>> On Sat, Oct 11, 2008 at 12:02 PM, Xah <xahlee@gmail.com> wrote:
>>> the regexp-opt accept a second argument of "'word", but it doesn't
>>> accept "'symbol"?
>>>
>>> Shouldn't it?
>
> Sure, why not.
>
>> Would not the semantics be exactly the same?
>
> No, "\\<\\(\\w\\|\\s_+\\)+" (word delimiters) doesn't match the entire
> lisp symbol `-test'.
Ok, I see. There is \\_< for symbols, I never noticed that (I thought
that must be handled in the syntax table).
Then I think Xah is right.
>> But one thing I think would be useful is to be able to use numbers for
>> the PAREN argument to get an explicitly numbered regexp group back.
>
> Is it possible to modify the numbering at all? If so, how?
See (info "(elisp) Regexp Backslash")
`\(?NUM: ... \)'
is the "explicitly numbered group" construct.
> regards,
> Nikolaj Schumacher
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: regex-opt does not accept 'symbol as second arg?
2008-10-11 12:20 ` Lennart Borgman
@ 2008-10-11 13:01 ` Nikolaj Schumacher
2008-10-11 14:03 ` Lennart Borgman
0 siblings, 1 reply; 9+ messages in thread
From: Nikolaj Schumacher @ 2008-10-11 13:01 UTC (permalink / raw)
To: Lennart Borgman; +Cc: help-gnu-emacs, Xah
"Lennart Borgman" <lennart.borgman@gmail.com> wrote:
>>> But one thing I think would be useful is to be able to use numbers for
>>> the PAREN argument to get an explicitly numbered regexp group back.
>>
>> Is it possible to modify the numbering at all? If so, how?
>
> See (info "(elisp) Regexp Backslash")
>
> `\(?NUM: ... \)'
> is the "explicitly numbered group" construct.
I was actually looking at the same info page when writing. I assume
this an Emacs 23 feature, then.
regards,
Nikolaj Schumacher
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: regex-opt does not accept 'symbol as second arg?
2008-10-11 13:01 ` Nikolaj Schumacher
@ 2008-10-11 14:03 ` Lennart Borgman
0 siblings, 0 replies; 9+ messages in thread
From: Lennart Borgman @ 2008-10-11 14:03 UTC (permalink / raw)
To: Nikolaj Schumacher; +Cc: help-gnu-emacs, Xah
On Sat, Oct 11, 2008 at 3:01 PM, Nikolaj Schumacher <me@nschum.de> wrote:
> "Lennart Borgman" <lennart.borgman@gmail.com> wrote:
>
>>>> But one thing I think would be useful is to be able to use numbers for
>>>> the PAREN argument to get an explicitly numbered regexp group back.
>>>
>>> Is it possible to modify the numbering at all? If so, how?
>>
>> See (info "(elisp) Regexp Backslash")
>>
>> `\(?NUM: ... \)'
>> is the "explicitly numbered group" construct.
>
> I was actually looking at the same info page when writing. I assume
> this an Emacs 23 feature, then.
Yes, forgot to say that.
^ permalink raw reply [flat|nested] 9+ messages in thread
[parent not found: <mailman.850.1223727025.25473.help-gnu-emacs@gnu.org>]
* Re: regex-opt does not accept 'symbol as second arg?
[not found] ` <mailman.850.1223727025.25473.help-gnu-emacs@gnu.org>
@ 2008-10-12 1:45 ` Tim X
2008-10-12 10:17 ` Nikolaj Schumacher
[not found] ` <mailman.880.1223806646.25473.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 9+ messages in thread
From: Tim X @ 2008-10-12 1:45 UTC (permalink / raw)
To: help-gnu-emacs
Nikolaj Schumacher <me@nschum.de> writes:
> "Lennart Borgman" <lennart.borgman@gmail.com> wrote:
>
>> On Sat, Oct 11, 2008 at 12:02 PM, Xah <xahlee@gmail.com> wrote:
>>> the regexp-opt accept a second argument of "'word", but it doesn't
>>> accept "'symbol"?
>>>
>>> Shouldn't it?
>
> Sure, why not.
>
>> Would not the semantics be exactly the same?
>
> No, "\\<\\(\\w\\|\\s_+\\)+" (word delimiters) doesn't match the entire
> lisp symbol `-test'.
In emacs 23, it appears to be working as it is supposed to. It does take
an arbitrary symbol, but the symbol "'words" has special meaning over just a
non-nil value e.g.
ELISP> (regexp-opt '("This" "That" "Those"))
"\\(?:Th\\(?:at\\|is\\|ose\\)\\)"
ELISP> (regexp-opt '("This" "That" "Those") t)
"\\(Th\\(?:at\\|is\\|ose\\)\\)"
ELISP> (regexp-opt '("This" "That" "Those") 'words)
"\\<\\(Th\\(?:at\\|is\\|ose\\)\\)\\>"
ELISP> (regexp-opt '("This" "That" "Those") 'test)
"\\(Th\\(?:at\\|is\\|ose\\)\\)"
ELISP> (regexp-opt '("This" "That" "Those") 'symbol)
"\\(Th\\(?:at\\|is\\|ose\\)\\)"
ELISP>
Note that the "special meaning" symbol is 'words and not 'word.
Tim
P.S. From memory, I think an older version of regexp-opt actually took
an additional two symbols, one added the regexp grouping construct and
the other added the word boundry \< and \>.
--
tcross (at) rapttech dot com dot au
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: regex-opt does not accept 'symbol as second arg?
2008-10-12 1:45 ` Tim X
@ 2008-10-12 10:17 ` Nikolaj Schumacher
[not found] ` <mailman.880.1223806646.25473.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 9+ messages in thread
From: Nikolaj Schumacher @ 2008-10-12 10:17 UTC (permalink / raw)
To: Tim X; +Cc: help-gnu-emacs
Tim X <timx@nospam.dev.null> wrote:
> In emacs 23, it appears to be working as it is supposed to. It does take
> an arbitrary symbol, but the symbol "'words" has special meaning over just a
> non-nil value e.g.
The idea was that 'symbol or 'symbols should also have a special meaning.
> ELISP> (regexp-opt '("This" "That" "Those") 'symbol)
> "\\(Th\\(?:at\\|is\\|ose\\)\\)"
should return "\\_<\\(Th\\(?:at\\|is\\|ose\\)\\)\\_>" instead.
regards,
Nikolaj Schumacher
^ permalink raw reply [flat|nested] 9+ messages in thread
[parent not found: <mailman.880.1223806646.25473.help-gnu-emacs@gnu.org>]
* Re: regex-opt does not accept 'symbol as second arg?
[not found] ` <mailman.880.1223806646.25473.help-gnu-emacs@gnu.org>
@ 2008-10-13 7:48 ` Tim X
0 siblings, 0 replies; 9+ messages in thread
From: Tim X @ 2008-10-13 7:48 UTC (permalink / raw)
To: help-gnu-emacs
Nikolaj Schumacher <me@nschum.de> writes:
> Tim X <timx@nospam.dev.null> wrote:
>
>> In emacs 23, it appears to be working as it is supposed to. It does take
>> an arbitrary symbol, but the symbol "'words" has special meaning over just a
>> non-nil value e.g.
>
> The idea was that 'symbol or 'symbols should also have a special meaning.
>
>> ELISP> (regexp-opt '("This" "That" "Those") 'symbol)
>> "\\(Th\\(?:at\\|is\\|ose\\)\\)"
>
> should return "\\_<\\(Th\\(?:at\\|is\\|ose\\)\\)\\_>" instead.
>
OK, I see what your getting at now. In that case, it certanly could be
requested as an enhancement, but I wouldn't say that it is a bug because
it was never a feature of the utility i.e. it was developed for strings
rather than symbols. However, at what point do we draw the line. For
example, should the symbol 'buffer be added to put a \b at each end etc.
Personally, I can't see where I'd have a use for this feature. this
doesn't mean there isn't a use case, I have just never come across
one. On the other hand, I've used regexp-opt for matching against
strings a lot.
Tim
tim
--
tcross (at) rapttech dot com dot au
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2008-10-13 7:48 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-11 10:02 regex-opt does not accept 'symbol as second arg? Xah
2008-10-11 11:41 ` Lennart Borgman
2008-10-11 12:10 ` Nikolaj Schumacher
2008-10-11 12:20 ` Lennart Borgman
2008-10-11 13:01 ` Nikolaj Schumacher
2008-10-11 14:03 ` Lennart Borgman
[not found] ` <mailman.850.1223727025.25473.help-gnu-emacs@gnu.org>
2008-10-12 1:45 ` Tim X
2008-10-12 10:17 ` Nikolaj Schumacher
[not found] ` <mailman.880.1223806646.25473.help-gnu-emacs@gnu.org>
2008-10-13 7:48 ` Tim X
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).