unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Lars Ingebrigtsen <larsi@gnus.org>
To: Sam Halliday <sam.halliday@gmail.com>
Cc: 35119@debbugs.gnu.org
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	[thread overview]
Message-ID: <87o89cfysm.fsf@gnus.org> (raw)
In-Reply-To: <CALR_T9CAsUvSkAeMKzTf694g+=-xMqmZEV0_JOFB8RkA1rhH2A@mail.gmail.com> (Sam Halliday's message of "Wed, 3 Apr 2019 13:30:40 +0100")

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





      parent reply	other threads:[~2021-09-01  9:08 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-03 11:19 bug#35119: 26.1; narrow-to-region loses word-start/symbol-start information at end Sam Halliday
2019-04-03 11:25 ` Eli Zaretskii
2019-04-03 12:30   ` Sam Halliday
2019-04-03 13:01     ` Sam Halliday
2019-04-03 13:05       ` Sam Halliday
2021-09-01  9:08     ` Lars Ingebrigtsen [this message]

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=87o89cfysm.fsf@gnus.org \
    --to=larsi@gnus.org \
    --cc=35119@debbugs.gnu.org \
    --cc=sam.halliday@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).