[Top][All Lists]

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

[RFC PATCH] Changes to pop-up source buffers

From: Jack Kamm
Subject: [RFC PATCH] Changes to pop-up source buffers
Date: Sat, 18 Jan 2020 09:33:07 -0800

This patch changes some implementation details of
org-src-switch-to-buffer and org-edit-src-exit, to more consistently use
pop-to-buffer to open the source buffer, and quit-restore-window to
close it. It also adds a new default option to org-src-window-setup.

I'll explain some details and motivation for this now.

First, on killing the source buffer. Currently, we kill it with
kill-buffer, then restore the previous saved window configuration with
set-window-configuration. The downside is that, if changes to the
windows were made while editing the source buffer, for example if a new
window is opened to refer to some other file, then these changes will be
lost after the original window configuration is restored.

By contrast, this patch uses quit-restore-window to close the source
window, which won't affect other windows that may have been
changed. quit-restore-window is also smart enough to decide whether the
source window should be deleted (if the source buffer was popped up in a
new window), or whether the window should be kept and switched to some
previous buffer (if the source buffer was popped up on an existing

Next, I changed org-src-window-setup to consistently use pop-to-buffer
to create the source window. This is needed for quit-restore-window to
figure out whether to delete the source window. Otherwise, if we
separately create the window and switch to it, then quit-restore-window
won't know whether the window was previously used for something else.

Finally, I added a new default option to org-src-window-setup, to use
the user's default configuration of display-buffer. Personally, I have
configured my own display-buffer-base-action and would like org-babel to
use it. Also, if a user is not satisfied with any of the options in
org-src-window-setup, this allows them to use their own configuration.

In most cases, the new default for org-src-window-setup will behave
similarly to the previous default (reorganize-frame). It will only
behave differently when 3 or more windows are currently open.

A final advantage I'd like to note for pop-to-buffer and
quit-restore-window, is that these are the mechanisms used by many
built-in Emacs functions to pop up and close windows, such as *Help*

There was one previous option for org-src-window-setup,
reorganize-frame, that I couldn't reimplement using pop-to-buffer. That
option required keeping around some logic for deleting windows and
restoring the configuration.

I tested the new implementation for org-src-switch-to-buffer, for all
options of org-src-window-setup, and it appears to work correctly. I
tested this on Emacs 26.3.

Attachment: 0001-org-src-use-display-buffer-quit-restore-window-for-s.patch
Description: Text Data

reply via email to

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