GNU bug report logs -
#35119
Zero-length regexp matches at point when doing re-search-backward
Previous Next
Full log
Message #20 received at 35119 <at> debbugs.gnu.org (full text, mbox):
Sam Halliday <sam.halliday <at> gmail.com> writes:
> This impacts me in `looking-back'. Here's an interactive snippet to
> demonstrate the problem (not minimised to`narrow-to-region'):
>
> (defun look-for-35119 ()
> (interactive)
> (if (looking-back
> (rx (: word-end ":" word-start))
> ;;(rx (: word-end ":"))
> (- (point) 1) 't)
> (message "hit")
> (message "miss")))
>
> in emacs-lisp-mode, which defines : as non-word, interactively
> evaluate look-for-35119 when the point is just after the colon in this
> example text
>
> wibble:wobble
Here's a simpler test case:
(with-temp-buffer
(emacs-lisp-mode)
(insert "wibble:wobble")
(goto-char (point-min))
(search-forward ":")
(if (looking-back "\\>:\\<" nil t)
(message "hit")
(message "miss")))
And, indeed, that fails because
(re-search-backward "\\(?:\\>:\\<\\)\\=" nil t)
fails. There seems to be a general problem with re-search-backward and
these zero-length matches (as you said in a later message).
Here's the test case:
(with-temp-buffer
(emacs-lisp-mode)
(insert "wibble:wobble")
(goto-char (point-min))
(search-forward ":")
(if (re-search-backward ":\\<" nil t)
(message "hit")
(message "miss")))
That is, if we're at the point where this zero-length match should
match, it doesn't. This succeeds:
(with-temp-buffer
(emacs-lisp-mode)
(insert "wibble:wobble")
(goto-char (point-min))
(search-forward ":")
(forward-char 1)
(if (re-search-backward ":\\<" nil t)
(message "hit")
(message "miss")))
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
This bug report was last modified 3 years and 311 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.