Thursday, December 13, 2006 16:17:10 EST
Quicksilver Meets Emacs

Merlin Mann over at 43 Folders regularly sings the praises of Quicksilver, especially for quickly adding lines of text to text files. I've tried it, and never really incorporated it into my workday, because I already have "one app to rule them all": emacs.

But it's still not quite as easy to append to a text file in emacs as it could be: you have to actually switch buffers, then go to the end, then type your addition. So I wrote a little elisp to handle the chore:

 (setq char-to-buffer-alist
       '((?t . "todo")
         (?p . "todo_personal")
         (?b . "Blotter")
         (?a . "agendas")
 (defun char-to-buffer-name (c)
   (let ((entry (assoc c char-to-buffer-alist)))
     (if (null entry)
       (cdr entry))))
 (defun tobuffer (bufc msg) (interactive "cChar: \nsAppend line: ")
   (if (> (length msg) 0)
         (let ((bname (char-to-buffer-name bufc)))
           (set-buffer bname)
           (insert-string "\n__ ")
           (insert-string msg)
           (insert-string "\n")
           (message "Appended to %s" bname)))
     (switch-to-buffer (char-to-buffer-name bufc))))

 (global-set-key 'f8 'tobuffer)

Now I can just hit f8, then a sensible mnemonic for the buffers/files I use frequently (or RETURN for *scratch*), and throw a line of text in at the end, without losing my current context (though it does change where point is in the target buffer).

Or, if I just want to go to that buffer, I enter a blank line of text (i.e. just hit RETURN).

It's been a month or so, and I don't use this all that much, and most of my use is to go to the target buffer. But maybe I just haven't marketed it very well to myself.