]> code.delx.au - gnu-emacs-elpa/blob - packages/wconf/README.org
Merge commit '0cda39255827f283e7578cd469ae42daad9556a2' from js2-mode
[gnu-emacs-elpa] / packages / wconf / README.org
1 * wconf
2 ** About
3 =wconf= is a minimal window configuration manager for [[http://www.gnu.org/software/emacs/][GNU Emacs]]. Its
4 goal is to have several window configurations easily available, to
5 switch between them, and to save them to disk and later restore them.
6
7 For example, I might have a default "workspace" for miscellaneous stuff,
8 and then I might have workspaces "UI", "MT", "DB" for a classic 3-tier
9 application.
10
11 Can double as a "boss" key; not that you would ever use something like
12 that yourself.
13 ** Using the Package
14 Make sure the files are in your =load-path=, and either =(require
15 'wconf)= or make sure its autoloads are known to Emacs --- if you have
16 installed from a package archive, that should take care of both.
17
18 Here is an example from my configuration to show you the intended use of
19 =wconf=.
20 #+begin_src emacs-lisp
21 (add-hook 'desktop-after-read-hook ;so we have all buffers again
22 (lambda ()
23 (wconf-load)
24 (wconf-switch-to-config 0)
25 (add-hook 'kill-emacs-hook
26 (lambda ()
27 (wconf-store-all)
28 (wconf-save))))
29 'append)
30
31 (global-set-key (kbd "C-c w s") #'wconf-store)
32 (global-set-key (kbd "C-c w S") #'wconf-store-all)
33 (global-set-key (kbd "C-c w r") #'wconf-restore)
34 (global-set-key (kbd "C-c w R") #'wconf-restore-all)
35 (global-set-key (kbd "C-c w w") #'wconf-switch-to-config)
36 (global-set-key (kbd "C-<prior>") #'wconf-use-previous)
37 (global-set-key (kbd "C-<next>") #'wconf-use-next)
38 #+end_src
39 After =desktop= has restored all file buffers from my last session,
40 =wconf-load= will get its stored configs from =wconf-file= (defaults to
41 =<YOUREMACSDIR>/wconf-window-configs.el=), and I want it to immediately
42 switch to the first configuration. Then we hook into killing emacs to
43 store and save all our configurations in that same file. The global key
44 bindings expose those commands that I consider useful in day-to-day
45 work.
46 ** Concepts
47 The main idea is +stolen from+ inspired by =workgroups=. We keep a list
48 of configuration pairs. Each such pair consists of an /active/
49 configuration (what you see when you switch to this slot of the list),
50 and a /stored/ one (what you have in the back, and maybe save to disk at
51 some point). In =workgroups= parlance, these are the working and base
52 configs.
53
54 At each point in time there is (at most) one configuration current. You
55 can explictly store and restore the current active configuration to/from
56 the stored one, or do likewise for all configurations. For example, you
57 might decide that you have a carefully hand-crafted set of
58 configurations that you always want to start from, but that you do not
59 wish to change this setup, except when doing so explicitly. That's
60 easy: just remove the =(wconf-store-all)= call from the above hook
61 function.
62
63 A nice feature of =wconf= is that it does not alter any hooks or
64 settings outside its own small world, and I intend to keep it that way.
65 This implies that the currently active configuration is only updated
66 explicitly, via one the functions/commands in the package.
67 ** Rationale, and Other Packages
68 I used https://github.com/tlh/workgroups.el for several years. It is a
69 great package, which offers a lot of additional features besides the
70 core business of managing window configs. It also has some
71 shortcomings, is somewhat complex (at 79k), and I occasionally
72 experienced minor glitches. Most importantly, it has been unmaintained
73 for roughly 4 years now.
74
75 https://github.com/pashinin/workgroups2 promises to pick up where
76 workgroups left, and is actively maintained. The main difference, as I
77 understand it, is the desire to restore "special" buffers as well (help,
78 info, org-mode agendas, notmuch mail, you name it). Finally trying it,
79 it did not provide a lot of benefit for my personal needs, but added
80 still more complexity. The functionality that I want should not require
81 179k of elisp.
82
83 Nowadays (at least since the GNU Emacs 24.4 release), there are proper
84 lisp-reader (de)serializations for both frame and window configurations,
85 and =window.el= and =frameset.el= provide functions to deal with them
86 (relatively) comfortably. Desktop already (re)stores a single
87 configuration. That's when I decided that it's time to roll my own:
88 build something light on top of what's already there, in order to
89 provide persistent switchable configurations.
90 ** Notes, TODO
91 I only use a single fullscreen frame all the time. An earlier version
92 of this package stored configurations as whole framesets, without any
93 effort to deal with the multiple-frames case. It has now changed to
94 deal with window configurations in a single frame only. This is much
95 better defined, simpler, and no longer suffers from annoying flickering
96 effects.
97
98 Calling the package commands from different frames inside a single
99 session may or may not result in the behavior you want. In the latter
100 case, feel free to open an issue and describe what happens and what you
101 expected/wanted to happen. I explicitly do /not/ guarantee that the
102 code will change to suit your wishes --- but if minor changes could
103 render it more generally useful, I am all ears.
104
105 I am thinking about some rescaling options to deal with restoring on
106 frames of different sizes (possible due to a different screen size).
107 Filtering options for what is generally (re)stored (and how) might be a
108 pleasant side effect. Don't hold your breath.