aboutsummaryrefslogtreecommitdiff
path: root/helpful.el
diff options
context:
space:
mode:
authorDamien Cassou <damien@cassou.me>2019-11-29 17:33:15 +0100
committerWilfred Hughes <me@wilfred.me.uk>2020-01-11 23:24:02 +0000
commite511e8dbd32a8b8423f07178f0ea7c1ecfc63935 (patch)
tree29a0e02f045012d8bb82df636366e0a41e61126a /helpful.el
parent982dd49c9c7e63fa94b56824f50dea4186081f8e (diff)
Add support for CL generic methods
Diffstat (limited to 'helpful.el')
-rw-r--r--helpful.el18
1 files changed, 18 insertions, 0 deletions
diff --git a/helpful.el b/helpful.el
index 717d6a9..20713d2 100644
--- a/helpful.el
+++ b/helpful.el
@@ -1662,6 +1662,21 @@ POSITION-HEADS takes the form ((123 (defun foo)) (456 (defun bar)))."
"Insert section break into helpful buffer."
(insert "\n\n"))
+(defun helpful--insert-implementations ()
+ "When `helpful--sym' is a generic method, insert its implementations."
+ (let ((func helpful--sym)
+ (content))
+ (when (fboundp #'cl--generic-describe)
+ (with-temp-buffer
+ (declare-function cl--generic-describe "cl-generic" (function))
+ (cl--generic-describe func)
+ (setf (point) (point-min))
+ (when (re-search-forward "^Implementations:$" nil t)
+ (setq content (buffer-substring (point) (point-max)))))
+ (when content
+ (helpful--insert-section-break)
+ (insert (helpful--heading "Implementations") (s-trim content))))))
+
(defun helpful--calculate-references (sym callable-p source-path)
"Calculate references for SYM in SOURCE-PATH."
(when source-path
@@ -2288,6 +2303,9 @@ state of the current symbol."
(s-join "\n" (--map (helpful--format-alias it helpful--callable-p)
aliases))))
+ (when helpful--callable-p
+ (helpful--insert-implementations))
+
(helpful--insert-section-break)
(when (or source-path primitive-p)