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

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

bug#17862: 24.3; regexp-opt docstring is incorrect


From: Noam Postavsky
Subject: bug#17862: 24.3; regexp-opt docstring is incorrect
Date: Sun, 21 Aug 2016 08:47:40 -0400

On Sat, Jul 30, 2016 at 9:28 AM,  <npostavs@users.sourceforge.net> wrote:
> immerrr again <immerrr@gmail.com> writes:
>> I agree that adding "impenetrable definitions" might be unclear, but I'd 
>> argue
>> that it's still an improvement because the equivalence statement is
>> plain false now:
>>
>> - "words" and "symbol" keywords add special backslash characters
>> around the result
>>
>> - if PAREN is nil, the result is still grouped (unless the strings can be
>>   represented as a character set, but that's not handled in the
>> simplified version)
>>
>> I doubt we can put all the logic behind PAREN into the simplified version.
>
> Hah, sounds like a challenge :) How about
>
>     (defun simplified-regexp-opt (strings &optional paren)
>       (let ((parens (cond ((eq paren 'words)    '("\\<\\(" . "\\)\\>"))
>                           ((eq paren 'symbols) '("\\_<\\(" . "\\)\\_>"))
>                           ((null paren)          '("\\(?:" . "\\)"))
>                           (t                       '("\\(" . "\\)")))))
>         (concat (car paren)
>                 (mapconcat 'regexp-quote strings "\\|")
>                 (cdr paren))))
>
>> +@code{nil}
>> +    if all @var{strings} are single-character, the resulting regexp is
>> +    not surrounded, otherwise it is surrounded by @samp{\(?:} and
>> +    @samp{\)}.
>
> Zero character strings also:
>
>     (regexp-opt '("a" "")) ;=> "a?"
>
> How about saying "the regexp may be surrounded with \?(: ) to ensure that
> it constitutes a single expression (such that appending a postfix
> operator like '+' will apply to the whole expression)."
>

ping?





reply via email to

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