[[http://melpa.org/#/frame-purpose][file:http://melpa.org/packages/frame-purpose-badge.svg]]
=frame-purpose= makes it easy to open purpose-specific frames that only show certain buffers, e.g. by buffers' major mode, their filename or directory, etc, with custom frame/X-window titles, icons, and other frame parameters.
Note that this does not lock buffers to certain frames, and it does not prevent frames from showing any buffer. It works by overriding the =buffer-list= function so that, within a purpose-specific frame, any code that uses =buffer-list= (e.g. =list-buffers=, =ibuffer=, Helm buffer-related commands) will only show buffers for that frame's purpose. You could say that, within a purpose-specific frame, you would have to "go out of your way" to show a buffer that's not related to that frame's purpose.
Note: You may also find the [[https://github.com/akirak/frame-workflow][frame-workflow]] package useful, which integrates with this one.
** Usage
First, enable =frame-purpose-mode=. This overrides =buffer-list= with a function that acts appropriately on purpose-specific frames. When the mode is disabled, =buffer-list= is returned to its original definition, and purpose-specific frames will no longer act specially.
There are some built-in interactive commands:
=frame-purpose-show-sidebar=: Show list of purpose-specific buffers on SIDE of this frame. When a buffer in the list is selected, the last-used window switches to that buffer. Makes a new buffer if necessary. SIDE is a symbol, one of left, right, top, or bottom.
For more fine-grained control, or for scripted use, the primary function is =frame-purpose-make-frame=.
*** Examples
Make a frame to show only Org-mode buffers, with a custom frame (X window) title and icon:
(frame-purpose-make-frame :modes 'org-mode :title "Org" :icon-type "~/src/emacs/org-mode/logo.png")
Make a frame to show only [[https://github.com/jgkamat/matrix-client-el][matrix-client]] buffers, with a custom frame (X window) title and icon, and showing a list of buffers in a sidebar window on the right side of the frame:
(frame-purpose-make-frame :modes 'matrix-client-mode :title "Matrix" :icon-type (expand-file-name "~/src/emacs/matrix-client-el/logo.png") :sidebar 'right)
Make a frame to show only Web-development-related buffers:
;; `:modes' can be one or a list of items, each of which may be either a major mode symbol, or a ;; string which is matched as a regexp against major mode names. (frame-purpose-make-frame :modes '("html-" "css-" js-mode) :title "Web development")
** Screenshots
[[images/screenshot.png]]
** Installation
If you installed from MELPA, you're done!
*** Manual
Install =dash.el=, put =frame-purpose.el= in your =load-path=, and =(require 'frame-purpose)= in your init file.
*** =use-package= and =general=
If you use [[https://github.com/jwiegley/use-package][use-package]] and [[https://github.com/noctuid/general.el#general-keyword][general]] (and you should), you could put this in your init file:
(use-package frame-purpose :general (:prefix "M-SPC" "Fd" #'frame-purpose-make-directory-frame "Fm" #'frame-purpose-make-mode-frame))
Then you could press =M-SPC F d= to open a new directory-specific frame, and =M-SPC F m= to open a new mode-specific frame.
** Changelog
*** 1.2-pre
Added
Fixed
*** 1.1
Added
Changed
Fixed
*** 1.0
First tagged version.
** Notes
For one reason or another, using a sidebar with buffers in some major modes may cause problems. For example, =elfeed-search-update= uses temporary buffers to download and process feeds, and every time it opens or closes a temp buffer, =buffer-list= is called, which updates the list of buffers in the sidebar, and this seems to significantly slow down the feed updating process. Until a fix or workaround can be found, it's best to simply avoid using a sidebar with these major modes. So, if =frame-purpose-show-sidebar= is called from a buffer in one of the major modes in the blacklist (or a major mode matching one of the strings in it), an error will be signaled (it's not a perfect solution, but it should help).
Suggestions to workaround this issue are welcome.
** Prior Art
There are a variety of powerful packages to help users manage buffers, like [[https://github.com/wasamasa/eyebrowse][eyebrowse]], [[https://github.com/nex3/perspective-el][perspective]], [[https://github.com/Bad-ptr/persp-mode.el][persp-mode]], [[https://github.com/tlh/workgroups.el][workgroups]], [[https://github.com/pashinin/workgroups2][workgroups2]], and others. I found them a bit confusing and complicated for my needs. I simply wanted to open frames to display certain sets of buffers, e.g. to have one frame for my Matrix/IRC chat-room buffers, one for my personal Org buffers, one for a certain Emacs package's files, etc. Some people use dedicated Emacs processes to separate tasks, but I prefer to use a single Emacs process. Also, while some of those packages provide handy persistence features, I don't want that complexity, and I don't necessarily want buffers or frames automatically opened when I start Emacs (and =desktop.el= provides that, when I need it).
So when I discovered the =buffer-predicate= frame parameter, and realized that I could (apparently!) safely override =buffer-list= with a version that uses frames' =buffer-predicate=, this package naturally fell into place as a simple way to make purpose-specific frames.
** Development
Contributions are welcome! Please report any problems or suggestions on the issue tracker.
** License
GPLv3