Skip to content
This repository has been archived by the owner on Dec 21, 2022. It is now read-only.

Commit

Permalink
In documentation-symbol, try keyword if symbol not found in current p…
Browse files Browse the repository at this point in the history
…ackage. Fixes ticket #158
  • Loading branch information
gzacharias committed Feb 2, 2016
1 parent 74332b4 commit fdbbceb
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions emacs/glime.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -2643,18 +2643,25 @@ a security hole but is mighty convenient.")
;; m-x slime-documentation
(defslimefun documentation-symbol (symbol-name)
(with-buffer-syntax ()
(multiple-value-bind (sym foundp) (parse-symbol symbol-name)
(if foundp
(with-output-to-string (string)
(format string "Documentation for the symbol ~a:~2%" sym)
(loop with found = nil
for (type . prompt) in *symbol-documentation-types*
(multiple-value-bind (sym foundp sname) (parse-symbol symbol-name)
(with-output-to-string (string)
(let ((heading
(if foundp
"Documentation for the symbol ~s:~2%"
;; If symbol is not found, try the keyword version of it, so we can document messages.
(and (not (find #\: symbol-name))
(setq sym (find-symbol sname keyword-package))
"Documentation for the keyword ~s:~2%"))))
(if heading
(loop for (type . prompt) in *symbol-documentation-types*
as doc = (slime-documentation sym type)
do (when (> (length doc) 0)
(setq found t)
(when heading
(format string heading sym)
(setq heading nil))
(format string "~a:~% ~a~2%" prompt doc))
finally (unless found
(format string "Not documented."))))
(format nil "No such symbol, ~a." symbol-name)))))
finally (when heading ;; didn't find any documentation
(format string "No documentation found for ~a" symbol-name)))
(format string "Symbol not found, ~a" symbol-name)))))))

(provide :glime)

0 comments on commit fdbbceb

Please sign in to comment.