unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Richard Stallman <rms@gnu.org>
To: "Drew Adams" <drew.adams@oracle.com>
Cc: emacs-devel@gnu.org
Subject: Re: question about markers, replace-match, and undo
Date: Sat, 28 Apr 2007 00:07:18 -0400	[thread overview]
Message-ID: <E1HheDO-00014C-Np@fencepost.gnu.org> (raw)
In-Reply-To: <BDEIJAFNGDOAGCJIPKPBEECGCEAA.drew.adams@oracle.com>

    I have some text, with a marker before it and a marker after it. For
    instance, the first marker is at position 41, just before `m', and the
    second is at position 48, just after `s':

      41     48
	mnopqrs

    I match this text, and then call (replace-match "ABC"), with the result that
    the first marker is still at position 41 and the second marker is now at
    position 44, just after `C', which is what I would expect and what I want:

      41 44
	ABC

    I use `undo', and the result is that both markers are now at position 41:

      41
      41
	mnopqrs

That is definitely a bug.  Does this fix it?

*** insdel.c	02 Mar 2007 03:28:13 -0500	1.190
--- insdel.c	27 Apr 2007 23:55:23 -0400	
***************
*** 1603,1610 ****
  
    if (! EQ (current_buffer->undo_list, Qt))
      {
        record_delete (from, deletion);
-       record_insert (from, inschars);
      }
  
    GAP_SIZE -= outgoing_insbytes;
--- 1603,1614 ----
  
    if (! EQ (current_buffer->undo_list, Qt))
      {
+       /* Record the insertion first, so that when we undo,
+ 	 the deletion will be undone first.  Thus, undo
+ 	 will insert before deleting, and thus will keep
+ 	 the markers before and after this text separate.  */
+       record_insert (from + SCHARS (deletion), inschars);
        record_delete (from, deletion);
      }
  
    GAP_SIZE -= outgoing_insbytes;

  parent reply	other threads:[~2007-04-28  4:07 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-27 16:44 question about markers, replace-match, and undo Drew Adams
2007-04-27 17:43 ` Johan Bockgård
2007-04-27 18:13   ` Drew Adams
2007-04-28  4:07 ` Richard Stallman [this message]
2007-04-28  4:13   ` Drew Adams
2007-04-29 14:27     ` Richard Stallman
2007-04-29 15:19       ` Johan Bockgård
2007-04-29 16:08         ` Drew Adams
2007-04-30 22:09         ` Richard Stallman

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=E1HheDO-00014C-Np@fencepost.gnu.org \
    --to=rms@gnu.org \
    --cc=drew.adams@oracle.com \
    --cc=emacs-devel@gnu.org \
    /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).