2014-12-27 Info dispatch

There has been some talk about ditching (tex)info in favor of some new shiny thingy called Asciidoc. Like many other people, I hope RMS won’t agree to this craziness: info is one of the best things since sliced bread. If you don’t know how to use the Emacs info viewer, please read the Info info manual (i.e., the info manual about Info).

All this does not mean, of course, that M-x info (or C-h i) is ideal. One thing that bothers me is that (by default) there is only one Info buffer; I’d like to have one Info buffer for Emacs Lisp reference manual, one for Org manual and one for Emacs manual or other things. Of course, it is possible to have more Info buffers, using a numeric prefix argument to C-h i, but remebering numbers is not what we, humans, are that very good at.

Long story short, this is what I did:

(defun my-info (topic bufname)
  "Read documentation for TOPIC in the info system.  Name the
buffer BUFNAME.  If that buffer is already present, just switch
to it."
  (if (get-buffer bufname)
      (switch-to-buffer bufname)
    (info topic bufname)))

(defun my-org-info ()
  "Jump to Org-mode info buffer, creating it if necessary.  This
is *not* the buffer \\[info] would jump to, it is a separate
entity."
  (interactive)
  (my-info "org" "*Org Info*"))

(global-set-key "\C-ho" 'my-org-info)

(defun my-elisp-info ()
  "Jump to Emacs Lisp info buffer, creating it if necessary.  This
is *not* the buffer \\[info] would jump to, it is a separate
entity."
  (interactive)
  (my-info "elisp" "*Emacs Lisp Info*"))

(global-set-key "\C-hj" 'my-elisp-info)

(defun my-emacs-info ()
  "Jump to Emacs Lisp info buffer, creating it if necessary.  This
is *not* the buffer \\[info] would jump to, it is a separate
entity."
  (interactive)
  (my-info "emacs" "*Emacs Info*"))

(global-set-key "\C-hr" 'my-emacs-info)

As can easily be seen, the main thing here is my-info: this function opens the Info manual for the given topic in a buffer with given name, but only if it’s not yet open – if it is, it just switches to it. This way, if I have Org/Emacs/Elisp manual open, the respective keystroke won’t move me to the starting page of these manuals.

Note also that C-h o and C-h j are free by default, but C-h r is not; by default, this last key is bound to info-emacs-manual. That version opens the first page of that manual, which is not really that useful.

CategoryEnglish, CategoryBlog, CategoryEmacs, CategoryOrgMode