about photos bookshelf portfolio blog home
Begin main content

Search ruby docs (ri) in emacs

It's far from perfect, but it's a start and it applies ansi colors. My emacs lisp is pretty bad, so please feel free to provide enhancements.

Note one MAJOR bug is that if you have a buffer called *shell* it will switch there instead of your docs (so rename your shell buffers to something else). What I really need to do is figure out how to use ansi-color.el outside the interactive shell.

(defun ri (ruby-class-name)
  "Lookup a class in ri and put it into a buffer"
  (interactive "sClass: ")
  (let* ((explicit-shell-file-name "ri")
         (explicit-ri-args '("-T" "-f" "ansi"))
         (rishell-buffer-name (concat "*ri " ruby-class-name "*")))
    (comint-check-proc rishell-buffer-name) ; see shell.el
    (if (not (get-buffer rishell-buffer-name))
        (progn
          (setq ansi-color-for-comint-mode t)
          (add-to-list 'explicit-ri-args ruby-class-name)
          (shell)
          (rename-buffer rishell-buffer-name)
          ))
    (pop-to-buffer (get-buffer rishell-buffer-name))
    (setq buffer-read-only t)
    (setq buffer-modified-p nil)
    (goto-line '1)
    ))

01:45 AM, 13 Feb 2006 by Mark Aufflick Permalink

Add comment