Contextual Context Switching For An Efficient Workflow
1 Executive Summary
Context switching in an Emacs workflow comes down to switching buffers — and Emacs provides a large number of built-ins and extensions packages for switching buffers. One can put together numerous workflows by picking among these to make context switching contextual — using the most appropriate workflow can lead to being able to focus much better on the core task of creating, editing, reviewing and publishing all forms of content ranging from research papers and presentations to Open Source Software.
This article summarizes my present workflow — it's entirely keyboard driven and optimized for an eyes-free workflow.
2 Where Does Context Come From?
Context as used in this article can be traced back to the current task at hand — here are some illustrative examples:
- Editing a set of related files. (.c, .h)
- Switching among a collection of chat buffers. (major-mode)
- Switching among a collection of mail folders. (major-mode)
- Switching among a collection of open Web pages. (major-mode)
- Switching among a small number of recently used buffers. (recency)
- Switching among buffers in the same project (project)
- Switching between project-specific shells and buffers. (project)
3 Building Blocks For Context Switching
Here are some of the building blocks I use to construct workflows that meet the use-cases enumerated in the previous section. Many of these are built into Emacs; some come from extra packages and a few are implemented in Emacspeak to fill the gaps. See the related article Search, Input, Filter, Target (SIFT) interaction described in a previous article for a more detailed explanation or properties that characterize effective eyes-free interaction.
- Built-in Command
next-buffer
andprevious-buffer
bound tohyper-,
andhyper-.
. - Builtin Command ~
other-window
bound toC-x o
. - Emacspeak Commands
emacspeak-wizards-cycle-to-next-buffer
andemacspeak-wizards-cycle-to-previous-buffer
bound toAlt-n
andAlt-p
. - Emacspeak Command
emacspeak-wizards-shell-toggle
bound toSuper-,
. - Emacspeak Command
emacspeak-wizards-shell-by-key
bound toC-c [1-9]
.
3.1 Things To Note
- Notice that many of these commands come in pairs and use key-bindings that also pair-up with respect to muscle memory; over time I have found this type of pairing to be essential for them to become part of one's daily habit.
- And when these task-specific commands dont get you the buffer
you want with one or two keystrokes, one can always fallback to
switch-to-buffer
. - Built-in Command
switch-to-buffer
bound toC-x b
which in my environment maps toido-switch-buffer
with fuzzy completion.
3.2 Related Packages
There are of course many alternatives to the building blocks above, here is a non-exhaustive list:
- Package
helm
withivy
,counsel
and friends. - Package
selectrum
. Additionally organizing one's workspace using
Emacs Frames
with each frame dedicated to tasks like email — visual workspaces.In general, I've not found any of the above adding much in the context of eyes-free interaction.
4 Conclusion
Emacs has a large number of facilities that lend themselves to multiple workflows. Investing some time in putting together workflows that suit one's needs has a large pay-back over time.