Simple window configuration management

Most of the time, I run Emacs in a single, maximized frame (and, sometimes, just inside a urxvt terminal). Inside that frame i create and destroy windows as needed to contain my buffers [0]. After a while working with Emacs one gets used to a fluid window setup, where windows come and go as need arises.

But I remember that in the early days I felt a bit confused: I started by creating a windows setup (split horizontally, then vertically, open files in each of the windows… that kind of thing) and was non-plussed when any operation (going to a Gnus buffer and reading messages, for instance) destroyed my carefully prepared layout. Over the years i’ve seen many a newbie feeling that way. My advice is usually to let go, and learn how to move around your windows, creating them as needed.

That said, i must admit that, sometimes, i want to recover a certain window configuration in a quick way. A particularly simple one is provided by winner-mode, a package which is part of Emacs. Winner keeps track of your window configurations, and provides functions to navigate your window configuration history.

As advertised, activating winner-mode (which is a global minor mode) is as easy as one can get: just type M-x winner-mode or put this line:

    (winner-mode 1)

in your .emacs. Use Emacs normally, and whenever one cherished window layout gets destroyed, press C-c <left> (where <left> refers to the left cursor key) to recover it–actually, this calls winner-undo, and you can invoke it as many times as you want to visit previous window configurations. As one would expect, C-c <right> (the default binding for winner-redo) navigates configurations in the opposite direction [1]. Simple and very useful, as it should be.

But maybe you want to be automatically tele-transported to a previous configuration without traversing the intermediate ones. No problem: Emacs provides functions to store and retrieve window configurations (which, in fact, are the ones winner-mode is using under the covers). You can store the current window configuration in register ‘a’ (registers are named using single letters or numbers) pressing C-x r w a, and restore it later by means of C-x r j a. Again, it’s that easy.

Although there exist several packages providing more sophisticated window management (named configs, save and restore, etc.), in my experience, the simple tricks described above are more than enough (and work out of the box in any Emacs). As always, YMMV.


[0] For those of you not familiar with Emacs lingo, an Emacs frame is what most window managers would call a window, while an Emacs window is any of the regions displaying a buffer inside a frame. Usual ways of creating windows in Emacs are C-x 2, C-x 3, C-x 4 f, and so on. See Windows and WindowsAndFrames for more.

[1] In Emacs 21, the default keybindings start with C-x instead of C-c.

Advertisements

Type faster with Predictive

I had Predictive in my list of Emacs packages to try out and review, but Mathias Dahl has saved me the trouble by writing a nice tutorial on using Predictive, complete with screenshots and all. In a nutshell,

Predictive is a package for the GNU Emacs Editor that helps you write text faster. It does this by trying to predict what you are going to write by looking at the first few characters of each word you type, looking into a dictionary for matching words, and suggesting words from this dictionary.

Mathias goes on providing all the details you need to get stated with Predictive. Although i have not yet used it, looks pretty interesting.

predictive-02.png

Oh, as an aside, i recommend taking a look at Tony ‘Qubit’ Cubitt’s site for more Emacs (and non-Emacs) goodies, or just to enjoy a beautiful website.

Oh my gawd, it’s full of links!

I’ve been using emacs-muse during several years now to keep a personal knowledge base in the form a local wiki. To me, the killer feature of emacs-muse is its ability to create links to other documents, mails, URLs or any other resource accessible via Emacs (which is to say, virtually any resource). Combined with planner mode, one has a pretty good PIM system that, among many other virtues, is based on plain text files (and, therefore, is easily indexable) and is as portable as Emacs itself.

Emacs-muse is pretty neat, but not perfect. My main quibble with it is that it’s a major mode. That means that, in order to create a link to other resource, you must be in a ‘muse’ document (a sort of wiki page). But wouldn’t if be nice if you could create links in any document. Say you’re writing source code an want to reference another file in the project, or an HTML page detailing an API you’re using, or a PDF with your projects requirements. Or you’re writing an essay in LaTeX and want to link to a text file of related notes, or an email, or… you get the idea. What I’m asking for is, in emacs parlance, a minor mode providing the linking functionality.

As it often happens in the Emacs universe, my prayers have been heard. Linkd is exactly the package i wanted. In the words of its author, David O’Toole, “linkd-mode is a hypertext system for organizing and interlinking all resources available to GNU Emacs. It can be used to make a “personal web” out of all your text files—regardless of file format or major mode.” In addition, linkd trims off some of the features I rarely use in emacs-muse, namely, the publishing functionality.

Although still in alpha, linkd looks already pretty good, with such niceties as proxy icons in links, as shown in this picture:

Linkd in action

Other interesting features of linkd include its ability to mark blocks inside any file that can be link targets, and its tagging functionality. In addition, the list of planned features (searching and indexing, summarize, synthesize links a la remember-mode) makes linkd a package definitely worth exploring and keeping an eye on.