helpful

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

commit e511e8dbd32a8b8423f07178f0ea7c1ecfc63935
parent 982dd49c9c7e63fa94b56824f50dea4186081f8e
Author: Damien Cassou <damien@cassou.me>
Date:   Fri, 29 Nov 2019 17:33:15 +0100

Add support for CL generic methods

Diffstat:
Mhelpful.el | 18++++++++++++++++++
Mtest/helpful-unit-test.el | 7+++++++
2 files changed, 25 insertions(+), 0 deletions(-)

diff --git 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 @@ -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))))