[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Using `save-window-excursion' instead of `save-excursion' for `comme
From: |
martin rudalics |
Subject: |
Re: Using `save-window-excursion' instead of `save-excursion' for `comment-region'? |
Date: |
Thu, 05 Dec 2013 12:46:12 +0100 |
> In Org buffer, you can comment code within source blocks. This opens
> a new buffer, insert the code there, comment it, and insert the buffer
> contents back into Org's buffer.
>
> With the current `comment-region' function, point is lost when Org
> goes back to the org buffer. Using `save-window-excursion' instead
> of `save-excursion' fixes the problem.
>
> Are you aware of problems that this change may trigger?
>
> I cannot think of any, but I'm always a bit cautious when using
> `save-window-excursion'.
Please be. `save-window-excursion' should be used iff you really change
the window configuration as, for example, by resizing, deleting or
creating windows, or showing a different buffer in some window. WOW
everything covered by `window-configuration-change-hook'. In the case
you describe above you do not show the buffer used for inserting the
code, commenting it, ... in a window IIUC so that requirement is not
satisfied.
Can you explain why `save-excursion' fails?
martin