help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: regex-opt does not accept 'symbol as second arg?


From: Tim X
Subject: Re: regex-opt does not accept 'symbol as second arg?
Date: Sun, 12 Oct 2008 12:45:32 +1100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]