commit 8c3c3ebcef05902f73573264d4c45cea2b53886b parent 1be4595e2c2fee4c32ee083240a2200ab70ef71b Author: Nick Drozd <nicholasdrozd@gmail.com> Date: Sat, 23 Dec 2017 15:01:39 -0600 Add helpful--calculate-references Diffstat:
| M | helpful.el | | | 28 | +++++++++++++++++----------- |
1 file changed, 17 insertions(+), 11 deletions(-)
diff --git a/helpful.el b/helpful.el @@ -992,6 +992,20 @@ POSITION-HEADS takes the form ((123 (defun foo)) (456 (defun bar)))." "Insert section break into helpful buffer." (insert "\n\n")) +(defun helpful--calculate-references (sym callable-p source-path) + "Calculate references for SYM in SOURCE-PATH." + (when source-path + (let* ((primitive-p (helpful--primitive-p sym callable-p)) + (buf (elisp-refs--contents-buffer source-path)) + (positions + (if primitive-p + nil + (helpful--reference-positions + helpful--sym helpful--callable-p buf))) + (return-value (--map (helpful--outer-sexp buf it) positions))) + (kill-buffer buf) + return-value))) + (defun helpful-update () "Update the current *Helpful* buffer to the latest state of the current symbol." @@ -1017,17 +1031,9 @@ state of the current symbol." (helpful--source helpful--sym helpful--callable-p))) (source-path (when look-for-src (helpful--source-path helpful--sym helpful--callable-p))) - references) - (when source-path - (let* ((buf (elisp-refs--contents-buffer source-path)) - (positions - (if primitive-p - nil - (helpful--reference-positions - helpful--sym helpful--callable-p buf)))) - (setq references - (--map (helpful--outer-sexp buf it) positions)) - (kill-buffer buf))) + (references (helpful--calculate-references + helpful--sym helpful--callable-p + source-path))) (erase-buffer)