bmag/emacs-purpose

Retaining window purpose even after last associated buffer has been closed?

Opened this issue · 0 comments

anlsh commented

Is it possible to retain a window's purpose even after the last buffer of that purpose has been closed?

Let's say that I have three windows: 1, 2, and 3. My aim is to set up the first to display rustic-mode buffers, have the second as miscellaneous, and have the third display rustic-compilation buffers.

So let's say I set up those three windows without purpose-mode enabled. Then, running rustic-cargo-build will build my project and display its output in some new/fourth popup buffer that I don't really like. So I'm trying to set up a window layout to avoid that.

So, suppose I redo my window layout to have three windows again, but this time with the following configuration.

(add-to-list 'purpose-user-mode-purposes '(rustic-mode . rust-1))
(add-to-list 'purpose-user-mode-purposes '(rustic-compilation-mode . rust-3))
(require 'window-purpose-x)
(purpose-compile-user-configuration)
(purpose-mode)

And set the following purposes for those three windows (via purpose-set-window-purpose)

  1. rust-1
  2. misc
  3. rust-3

Now, a rustic-cargo-build will open the *rustic-compilation* buffer in window 3. So far so good.

Let's say that I switch to window 3, read the output, decide I'm done with it, and close the buffer. Since I generally only have one rustic-compilation buffer at a time, there are no remaining buffers with the purpose rust-3: emacs seems to put some random other buffer there. Whatever, that's fine.

Unfortunately issuing another rustic-cargo-build will display another fourth/popup window again, presumably because closing the last buffer with purpose rust-3 earlier removed the rust-3 purpose from window 3. Is it possible to prevent this from happening?