unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Lars Ingebrigtsen <larsi@gnus.org>
To: Ren Victor <victorhge@gmail.com>
Cc: 42424@debbugs.gnu.org
Subject: bug#42424: 27.0.90; replace-match: point is NOT left at the end of replacement
Date: Sat, 17 Oct 2020 11:49:42 +0200	[thread overview]
Message-ID: <87zh4ltc5l.fsf@gnus.org> (raw)
In-Reply-To: <CAMks0JH0N=BAEjBnGrU-jfT=aryrC4jEZDOuJMxAd5N3UpSVbg@mail.gmail.com> (Ren Victor's message of "Sun, 19 Jul 2020 13:50:51 +0800")

Ren Victor <victorhge@gmail.com> writes:

> In `replace_range', the point is also relocated.  I am not sure why it has
> to be moved again just before returning from `replace-match'.

I can reproduce this error on Emacs 28.

The problem seems to be this in Freplace_match?  

  /* Put point back where it was in the text, if possible.  */
  TEMP_SET_PT (clip_to_bounds (BEGV, opoint + (opoint <= 0 ? ZV : 0), ZV));
  /* Now move point "officially" to the start of the inserted replacement.  */
  move_if_not_intangible (newpoint);

Uhm...  is that comment wrong?  Aren't we moving point to the end of the
inserted replacement?

Anyway, removing that move makes the suggested test not fail, but it
leads to a bunch of other tests failing, so it's doing something right,
at least.

However, just before that, there's this:

  /* The replace_range etc. functions can trigger modification hooks
     (see signal_before_change and signal_after_change).  Try to error
     out if these hooks clobber the match data since clobbering can
     result in confusing bugs.  Although this sanity check does not
     catch all possible clobberings, it should catch many of them.  */
  if (! (search_regs.num_regs == num_regs
	 && search_regs.start[sub] == newstart
	 && search_regs.end[sub] == newpoint))
    error ("Match data clobbered by buffer modification hooks");

So replace_match is already signalling some errors on buffer
modification hooks, but not here.  So is this a bug or just something
that should be documented better?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





  reply	other threads:[~2020-10-17  9:49 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-19  5:50 bug#42424: 27.0.90; replace-match: point is NOT left at the end of replacement Ren Victor
2020-10-17  9:49 ` Lars Ingebrigtsen [this message]
2020-10-17 17:25   ` Eli Zaretskii
2020-10-18  8:24     ` Lars Ingebrigtsen
2021-07-31 14:03       ` Lars Ingebrigtsen
2021-07-31 14:20         ` Eli Zaretskii
2021-07-31 14:28           ` Lars Ingebrigtsen
2021-07-31 14:49             ` Lars Ingebrigtsen
2021-07-31 15:10               ` Eli Zaretskii
2021-07-31 15:45                 ` Lars Ingebrigtsen
2024-04-09 15:14 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors

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=87zh4ltc5l.fsf@gnus.org \
    --to=larsi@gnus.org \
    --cc=42424@debbugs.gnu.org \
    --cc=victorhge@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).