bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#4312: 23.1; save-excursion and goto-char fail


From: Stefan Monnier
Subject: bug#4312: 23.1; save-excursion and goto-char fail
Date: Thu, 03 Sep 2009 09:51:04 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux)

> 1. I have a lisp code which saves file buffer and does some
> manipulation on the file in shell.  subsequently it is reverted.
> However I have tried save-excursion before saving file which did not
> restore the file position on reverting.

save-excursion uses markers to remember the position.  But markers only
keep track of positions by keeping track of insertions/deletions and
adjusting the position accordingly.  When the changes happen outside
Emacs, this doesn't work too well, because Emacs sees your revert-buffer
as just one big delete&insert.

> So I tried setq point to some var and after reverting restore point
> with goto-char. Thi s also did not ork in restoring previous position
> although (point) function did return the correct  value from the
> goto-char function in lisp. 

This should "work" in the sense that it will keep point at the same
numerical position (same distance from the beginning of the file, when
counted in chars).  But it may very well not be pointing at the same
conceptual place in the file if you've added/removed content.

Maybe you should use bookmarks for that: bookmarks remember the position
together with the context (the text immediately before and after point),
so as to be able to find the "same spot" again, even if it moved in
the file.

> 3. re-search-forward function fails regular expression with octal code

IIRC, we already have a bug report about that (bug#3822).  But no
I haven't had time to look at it yet.
   

        Stefan






reply via email to

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