Create a gist now

Instantly share code, notes, and snippets.

Hotkeys for quick racket documentation lookup. Requires paredit.
(setq raco-location "raco")
(require 'paredit)
(setq raco-doc-history nil)
(defun call-raco-doc (text)
(shell-command (concat raco-location " doc -- '" text "' &")))
(defun get-current-word ()
(progn (backward-sexp)
(buffer-substring (mark) (point))))
(progn (mark-sexp)
(buffer-substring (mark) (point))))))
(defun raco-doc ()
"call raco doc on selected text"
(call-raco-doc (get-current-word)))
(defun raco-doc-prompt ()
"call raco doc on prompted text"
(let ((text (read-string (if (consp raco-doc-history)
(concat "raco doc [" (car raco-doc-history) "]: ")
"raco doc: ")
;; default value should be most recent history item
(if (consp raco-doc-history)
(car raco-doc-history)
t))) ;; inherit the current input method
(call-raco-doc text)))
(defun enable-raco-doc ()
(define-key scheme-mode-map (kbd "C-c C-r") 'raco-doc)
(define-key scheme-mode-map (kbd "C-c C-M-r") 'raco-doc-prompt))
(provide 'raco-doc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment