all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* question about markers, replace-match, and undo
@ 2007-04-27 16:44 Drew Adams
  2007-04-27 17:43 ` Johan Bockgård
  2007-04-28  4:07 ` Richard Stallman
  0 siblings, 2 replies; 9+ messages in thread
From: Drew Adams @ 2007-04-27 16:44 UTC (permalink / raw)
  To: Emacs-Devel

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

I get the same behavior if I use various additional args to `replace-match'.
I've also tried (progn (undo-boundary) (replace-match "ABC")), with no
change.

I'm not saying there is necessarily a bug here; I don't know. I'm asking how
I can get `undo' to restore not only the text but the marker positions. If I
use, for instance, `delete-region' and `insert', there is no problem, but I
need to be able to use `replace-match' here.

What also seems odd is that (buffer-has-markers-at 48) returns t, but
`mark-ring' shows only two markers, both at position 41, and the mark itself
is somewhere else altogether (e.g. 18). I also used a library `mark.el' from
Emacs Wiki that lets you access the markers in a buffer, and it does not
show any marker at 48. So perhaps `buffer-has-markers-at' is reporting
erroneously here?

[BTW, I also wonder why we have `buffer-has-markers-at', but we apparently
have no function that returns the list of markers at a given position.]

Can anyone help with my question of how to get `undo' to act as an inverse
of `replace-match' wrt the markers? Thx.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2007-04-30 22:09 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.