From: Stefan Monnier <monnier@iro.umontreal.ca>
To: RSridhar <rsridar50@dataone.in>
Cc: 4312@emacsbugs.donarmstrong.com, bug-gnu-emacs@gnu.org
Subject: bug#4312: 23.1; save-excursion and goto-char fail
Date: Thu, 03 Sep 2009 09:51:04 -0400 [thread overview]
Message-ID: <jwvk50gw3aa.fsf-monnier+emacsbugreports@gnu.org> (raw)
In-Reply-To: <1251885785.3373.3.camel@www.x-shriman.com> (RSridhar's message of "Wed, 02 Sep 2009 15:33:05 +0530")
> 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
next prev parent reply other threads:[~2009-09-03 13:51 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <87ws43boia.fsf@cyd.mit.edu>
2009-09-02 10:03 ` bug#4312: 23.1; save-excursion and goto-char fail RSridhar
2009-09-03 13:51 ` Stefan Monnier [this message]
2009-09-03 16:33 ` Andreas Schwab
2009-09-04 17:38 ` bug#4313: " RSridhar
[not found] ` <handler.4314.C.12528066171101.notifdonectrl.2@emacsbugs.donarmstrong.com>
2009-09-22 16:28 ` bug#4314: acknowledged by developer (close 4312) RSridhar
2009-09-22 16:30 ` Chong Yidong
2009-09-13 1:55 ` Processed: close 4312 Emacs bug Tracking System
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwvk50gw3aa.fsf-monnier+emacsbugreports@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=4312@emacsbugs.donarmstrong.com \
--cc=bug-gnu-emacs@gnu.org \
--cc=rsridar50@dataone.in \
/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 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.