[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#20806: 25.0.50; `string-match' is confused???
From: |
Stefan Monnier |
Subject: |
bug#20806: 25.0.50; `string-match' is confused??? |
Date: |
Sun, 14 Jun 2015 09:40:33 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) |
tags 20806 notabug
thanks
> Is an empty string a prefix of all strings or not?
Yes, but that's unrelated to the uncaught signal you show, nor to the
two string-match calls you show.
> Welcome to the Emacs shell
> /tmp $ (string-match "\\(.*\\)" "")
> 0
Yup, we can find a trivial match for "\\(.*\\)" in the empty string.
> /tmp $ (string-match "foo" "")
And "foo" can't be found in the empty string.
> Here is how I ended up with this bug.
> Debugger entered--Lisp error: (error "Regexp cannot match an empty string")
[...]
> command-execute(highlight-regexp)
And this is "not a bug but a feature". This could arguably
be improved. E.g. it should probably call `user-error'.
But highlight-regexp is simply telling you that it's not a good idea to
try to highlight all the empty strings in your buffer: not only there
are many (e.g. as many as point-max), but you wouldn't notice that
they're highlighted anyway.
Stefan