aboutsummaryrefslogtreecommitdiff
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
parent982dd49c9c7e63fa94b56824f50dea4186081f8e (diff)
Add support for CL generic methods
-rw-r--r--helpful.el18
-rw-r--r--test/helpful-unit-test.el7
2 files changed, 25 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)
diff --git a/test/helpful-unit-test.el b/test/helpful-unit-test.el
index 0250980..544ef00 100644
--- a/test/helpful-unit-test.el
+++ b/test/helpful-unit-test.el
@@ -1042,3 +1042,10 @@ find the source code."
70
"This variable was added, or its default value changed, in helpful version 1.2.3.")
(buffer-string))))
+
+(ert-deftest helpful--display-implementations ()
+ (require 'xref)
+ (helpful-function 'xref-location-marker)
+ (should (s-contains-p "Implementations" (buffer-string)))
+ (should (s-contains-p "((l xref-file-location))" (buffer-string)))
+ (should (s-contains-p "((l xref-buffer-location))" (buffer-string))))