emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

question about markers, replace-match, and undo


From: Drew Adams
Subject: question about markers, replace-match, and undo
Date: Fri, 27 Apr 2007 09:44:10 -0700

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.






reply via email to

[Prev in Thread] Current Thread [Next in Thread]