bmag / emacs-purpose

Manage Windows and Buffers According to Purposes
GNU General Public License v3.0
496 stars 23 forks source link

Question: Two split windows open buffer behavior #142

Closed sebastianpech closed 5 years ago

sebastianpech commented 5 years ago

I haven't found anything concerning the following behavior:

When in window with purpose A, switching buffer to one that also has purpose B, instead of the emacs default behavior the buffer is viewed in the window with purpose B (though not dedicated) instead of in the window that is currently selected.

Is this intended and if yes, is it possible to disable it?

bmag commented 5 years ago

Yes and yes. It is intended and can be changed. Put the following elisp code in your configuration (to run after window-purpose was loaded):

(setcdr (assq 'switch-to-buffer purpose-action-sequences)
        '(purpose-display-maybe-same-window
          purpose-display-reuse-window-buffer
          purpose-display-reuse-window-purpose
          purpose-display-maybe-other-window
          purpose-display-maybe-other-frame
          purpose-display-maybe-pop-up-window
          purpose-display-maybe-pop-up-frame))

The variable purpose-action-sequences controls how Purpose tries to display a buffer in different common scenarios, and in what order. By default, purpose-display-maybe-same-window is lower on the list, but this code puts it higher. Specifically, what you experienced is caused by *-reuse-window-purpose which by default has a higher priority than *-maybe-same-window.

sebastianpech commented 5 years ago

Thanks, that solved it!