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

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

Re: point moved despite save-excursion, after deleting/reinserting regio


From: Garreau, Alexandre
Subject: Re: point moved despite save-excursion, after deleting/reinserting region
Date: Thu, 18 Oct 2018 11:50:40 +0200
User-agent: Gnus (5.13), GNU Emacs 25.1.1 (i686-pc-linux-gnu)

On 2018-10-18 at 05:38, Eli Zaretskii wrote:
>> Is there something such as `restore-markers'/`save-markers' that would
>> allow me to restore point after doing this operation?  Or better some
>> `save-buffer-content' like `save-excursion' but restoring the buffer
>> afterwards?
>
> When you delete text, markers pointing into that text cannot follow,
> they get relocated to the beginning/end of the deletion/insertion.
> What else can Emacs do, given that it doesn't know your future
> intentions?

I thought something such as `save-excursion' would do that, or that it
would be saved with the string, or something alike.

> If that's what you want, why not record the position of point before
> the delete/insert operation and restore it afterwards?

So is that the canonical way of doing? that feels like defeating the
purpose of `save-excursion' a little bit (I only wanted to produce a
result for this src-block), and as this is more complex behavior than
just “undoing backward” or anything part of core elisp, I feared
side-effects I wouldn’t be aware of: for instance tho, it means my
function will have the side-effects of moving all the markers (and maybe
other similar things) that were inside that portion of text: it feels
somewhat hardly like “restoring as before”.



reply via email to

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