On Sun, Aug 21, 2016 at 3:47 PM, Noam Postavsky wrote: > On Sat, Jul 30, 2016 at 9:28 AM, wrote: >> >> >> >> 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? Sorry about that, other things took priority. I liked your ideas, attached is a patch that borrows quite heavily from them. What do you think?