[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#35119: 26.1; narrow-to-region loses word-start/symbol-start informat
From: |
Lars Ingebrigtsen |
Subject: |
bug#35119: 26.1; narrow-to-region loses word-start/symbol-start information at end |
Date: |
Wed, 01 Sep 2021 11:08:41 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Sam Halliday <sam.halliday@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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- bug#35119: 26.1; narrow-to-region loses word-start/symbol-start information at end,
Lars Ingebrigtsen <=