helpful

a fork of Wilfred's helpful
git clone https://git.trogloxene.org/helpful.git
Log | Files | Refs | README

commit e9098907b23562a83f3271adaa16904c19af81c8
parent 6c86fcdd04883976c18995f5e74d9eb07a46a15f
Author: Wilfred Hughes <me@wilfred.me.uk>
Date:   Sat,  3 Jun 2017 17:05:31 +0100

Support both functions and macros

Diffstat:
Mhelpful.el | 27+++++++++++++++++++--------
1 file changed, 19 insertions(+), 8 deletions(-)

diff --git a/helpful.el b/helpful.el @@ -342,7 +342,11 @@ state of the current symbol." (kill-buffer buf))) (erase-buffer) (insert - (helpful--heading "Signature\n") + + (helpful--heading + (if (macrop helpful--sym) + "Macro Signature\n" + "Function Signature\n")) (helpful--signature helpful--sym) (helpful--heading "\n\nDocumentation\n") ;; TODO: a link to find this symbol in the manual, much like @@ -436,17 +440,24 @@ For example, \"(some-func FOO &optional BAR)\"." (setq docstring (helpful--skip-advice docstring)))) docstring)) -(defun helpful--read-fn-symbol () +(defun helpful--read-symbol (prompt predicate) (let ((sym-here (symbol-at-point))) - (read (completing-read "Symbol: " obarray - #'fboundp nil nil nil - (when (fboundp sym-here) + (read (completing-read prompt obarray + predicate nil nil nil + (when (funcall predicate sym-here) (symbol-name sym-here)))))) -(defun helpful (symbol) - "Show Help for SYMBOL." +(defun helpful-function (symbol) + "Show help for function named SYMBOL." (interactive - (list (helpful--read-fn-symbol))) + (list (helpful--read-symbol "Function:" #'functionp))) + (switch-to-buffer (helpful--buffer symbol)) + (helpful-update)) + +(defun helpful-macro (symbol) + "Show help for macro named SYMBOL." + (interactive + (list (helpful--read-symbol "Macro:" #'macrop))) (switch-to-buffer (helpful--buffer symbol)) (helpful-update))