emacs-devel
[Top][All Lists]
Advanced

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

Re: Using `save-window-excursion' instead of `save-excursion' for `comme


From: Stefan Monnier
Subject: Re: Using `save-window-excursion' instead of `save-excursion' for `comment-region'?
Date: Thu, 05 Dec 2013 14:45:29 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

> I think the problem is that org-babel-do-in-edit-buffer deletes the
> whole contents of the source code block, and re-inserts it.  This means
> that the marker that save-excursion uses (pointing to somewhere in the
> deleted and re-inserted span) no longer points to the desired position,
> but rather to just before the span.

> Org babel has its own point-restoration functionality (which works by
> counting lines and columns), but this is executed inside of the scope of
> comment-region’s save-excursion, so exiting the latter restores the
> point to a bogus position (from the POV of the user).

I think your analysis is exactly right, and the reason why
save-window-excursion doesn't exhibit the problem is because
save-window-excursion does not save-excursion in the current buffer.
I.e. paradoxically it's because it "preserves less" rather than because
it "preserves more".  Replacing the save-excursion with
save-current-buffer would probably work as well.


        Stefan



reply via email to

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