Searching Racket documentation from Emacs

21 January 2014

I’ve been working with Racket lately, and got tired of clumsily going to a tab in my browser to look up Racket symbols. A one-minute hack of a function originally written for lispdoc (by whom, I don’t know), solved this problem handily.

(defun racket-doc ()
  "Searches for SYMBOL, which is by default
  the symbol currently under the cursor."
  (let* ((word-at-point (word-at-point))
         (symbol-at-point (symbol-at-point))
         (default (symbol-name symbol-at-point))
         (inp (read-from-minibuffer
               (if (or word-at-point symbol-at-point)
                   (concat "Symbol (default " default "): ")
         "Symbol (no default): "))))
    (if (and (string= inp "")
             (not word-at-point)
             (not symbol-at-point))
      (message "you didn't enter a symbol!")
        (concat ""
                (if (string= inp "")

(define-key scheme-mode-map (kbd "C-c l") 'racket-doc)