git clone 'git://github.com/bmag/emacs-purpose.git'
Note: a full explanation can be found in the GitHub wiki.
Purpose (“window-purpose” on MELPA) provides a new window management system for Emacs, which gives you a better control over where Emacs displays buffers.
With Purpose, each buffer has a configurable “purpose” and each window
can interactivaly be dedicated to a certain “purpose”. When you dedicate
a window (C-c , d), Purpose makes sure that this window will be used
only for buffers which have the same purpose as the buffer that is
currently displayed in that window. The purpose of a buffer can be
customized via the variables
purpose-use-default-configuration (see the
Purpose is tested with Emacs versions 24.3, 24.4 and 24.5. Backward-compatibility for earlier versions might be added in the future - if you want such support, contact me.
Manually: M-x purpose-mode
In your init file:
Manually: M-x customize-group purpose. Look at: - “Purpose User Mode Purposes”: recognize purpose according to major mode - “Purpose User Name Purposes”: recognize purpose according to buffer name (for exact names) - “Purpose User Regexp Purposes”: recognize purpose according to buffer name (for name patterns) - “Purpose Use Default Configuration”: toggle default configuration on/off
In init file:
(add-to-list 'purpose-user-mode-purposes '(<major-mode> . <purpose>))
(add-to-list 'purpose-user-name-purposes '(<name> . <purpose>))
(add-to-list 'purpose-user-regexp-purposes '(<pattern> . <purpose>))
(setq purpose-use-default-configuration t) ; not really necessary, default is t
(purpose-compile-user-configuration) ; activates your changes
| Key | Command |
| :———- | :———————————————————————————————————————— |
| C-c , b |
purpose-switch-buffer-with-purpose: switch to a buffer with the same purpose as the current one |
| C-u C-x b |
switch-buffer-without-purpose: switch to a buffer, but don't use Purpose for it. Handy for changing the current layout. |
| C-c , d |
| C-c , D |
| C-c , 1 |
purpose-save-window-layout: save current layout to file |
purpose-load-window-layout: load layout from file |
purpose-reset-window-layout: reload previously loaded layout |
How to get a simple and persistent layout for coding in Python that looks like this:
(add-to-list 'purpose-user-mode-purposes '(python-mode . py)) (add-to-list 'purpose-user-mode-purposes '(inferior-python-mode . py-repl)) (purpose-compile-user-configuration)
If you have a previously saved layout, you can load it with
purpose-load-window-layout and skip step 2 and step 3.
purpose-toggle-window-purpose-dedicated) so window is dedicated (“[py]” in the status bar will change to “[py!]”)
other-window) to select the python file's window
enlarge-window) until you like the sizes of the windows
Dedicating a window limits which buffers will be displayed in it. There are two types of window dedication: buffer-dedication and purpose-dedication.
purpose-toggle-window-buffer-dedicated to dedicate a window to its buffer.
This window will not display any other buffer while it is buffer-dedicated. A
“#” in the mode-line next to the window's purpose indicates that the window is
purpose-toggle-window-purpose-dedicated to dedicate a window to its
purpose. This window will only display buffers with the same purpose. A “!” in
the mode-line next to the window's purpose indicates that the window is
When switching buffers, Purpose will display the new buffer in the correct window, according to the current configuration.
switch-to-buffer to switch to any buffer. The buffer will be displayed
according to the current purpose-configuration.
purpose-switch-buffer-with-purpose to switch to another buffer with the
same purpose as the current buffer.
purpose-switch-buffer-with-some-purpose to select a purpose and then
switch to a buffer with that purpose.
switch-buffer-without-purpose to switch to any buffer. The buffer will be
displayed using Emacs' original behavior. This is useful when you want to change
the window layout.
purpose-set-window-purpose to switch the purpose of the current window. If
there is a buffer with the chosen purpose, that buffer will be displayed in the
current window. Otherwise, a dummy buffer will be created and used.
Purpose lets you save, load and reset the window layout.
purpose-save-window-layout to save the current window layout to a file.
purpose-load-window-layout to load a window layout from a file.
purpose-reset-window-layout to reset the window layout to the latest
layout that you loaded.
You may want to store all your layouts in a directory, and change the value of
purpose-default-layout-file to point to that directory.
You can delete all non-dedicated windows by using
purpose-preferred-prompt, you can choose whether you want Purpose to use
IDO or Helm when it needs information from the user. By default, when both IDO
and Helm are enabled, Purpose prefers IDO.
Purpose lets you define your own purposes. You can do so by using the variables
purpose-user-regexp-purposes. You can also deactivate the default purpose
configuration if it bothers you, by setting
If you want, you can the rules of how certain buffers are displayed. To do so,
use the variable
purpose-special-action-sequences. Let's explain this with an
example. The following code makes all help buffers appear in a separate
frame. This means you will get a “popup” frame for help buffers.
(setq pop-up-frames t) ; allows emacs to popup new frames ;; give help buffers the 'popup-frame purpose (add-to-list 'purpose-user-mode-purposes '(help-mode . popup-frame)) (purpose-compile-user-configuration) ;; new rules for buffers with the 'popup-frame purpose (add-to-list 'purpose-special-action-sequences '(popup-frame purpose-display-reuse-window-buffer purpose-display-reuse-window-purpose purpose-display-pop-up-frame))
See Integration With Other Packages for information about how some packages relate to Purpose.