unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: David Kastrup <dak@gnu.org>
To: Artur Malabarba <bruce.connor.am@gmail.com>
Cc: 20307@debbugs.gnu.org
Subject: bug#20307: 25.0.50; (regexp-opt nil ...) returns ""
Date: Mon, 13 Apr 2015 17:34:34 +0200	[thread overview]
Message-ID: <87iod0xcs5.fsf@fencepost.gnu.org> (raw)
In-Reply-To: <CAAdUY-J9Tc-4rb8dsNfLejAuOfF0_NofenEVFTpotew26hc0Lw@mail.gmail.com> (Artur Malabarba's message of "Mon, 13 Apr 2015 15:08:25 +0100")

Artur Malabarba <bruce.connor.am@gmail.com> writes:

> 2015-04-12 10:50 GMT+01:00 David Kastrup
>> Both
>>
>> M-: (regexp-opt nil) RET
>>
>> and
>>
>> M-: (regexp-opt nil t) RET
>>
>> return "".  However, they should return a regexp matching nothing
>> rather than everything, and the second invocation should also count as
>> one () pairing.
>
> I agree there should be () on the second one, but I strongly disagree
> they should match nothing.
>
> regexp-opt is NOT meant to match only the given strings. It is meant
> to match anything containing the given strings.

Well, and no string to match has been given.  This is not
(regexp-opt '(""))
but rather
(regexp-opt '())

> There is a very fundamental difference in that. The less strings you
> pass to regexp-opt, the MORE things the regexp will match.

Come again?

> Why would we suddently flip that on its head when going from 1 to 0
> strings?

(regexp-opt '("a" "b" "c")) -> "[abc]"
(regexp-opt '("a" "b")) -> "[ab]"

Quite literally (execute C-x C-e after the expressions above if you
don't believe me).  So how does "[ab]" match more than "[abc]" ?

-- 
David Kastrup





  parent reply	other threads:[~2015-04-13 15:34 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-12  9:50 bug#20307: 25.0.50; (regexp-opt nil ...) returns "" David Kastrup
2015-04-12 12:09 ` Stefan Monnier
2015-04-13 14:08 ` Artur Malabarba
2015-04-13 15:19   ` Stefan Monnier
2015-04-13 15:34   ` David Kastrup [this message]
2015-04-13 15:59     ` Artur Malabarba
2019-02-25 14:57 ` bug#20307: [PATCH] make regexp-opt return a no-match return value with empty input Mattias Engdegård
2019-03-02 12:37   ` Eli Zaretskii
2019-03-02 14:21     ` Mattias Engdegård
2019-03-02 14:41       ` Eli Zaretskii
2019-03-02 14:49         ` Mattias Engdegård
2019-03-02 14:57           ` Eli Zaretskii
2019-03-02 15:24             ` Mattias Engdegård

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87iod0xcs5.fsf@fencepost.gnu.org \
    --to=dak@gnu.org \
    --cc=20307@debbugs.gnu.org \
    --cc=bruce.connor.am@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).