aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Drozd <nicholasdrozd@gmail.com>2017-12-23 15:01:39 -0600
committerWilfred Hughes <me@wilfred.me.uk>2018-01-01 11:52:32 +0000
commit8c3c3ebcef05902f73573264d4c45cea2b53886b (patch)
tree2240624573cc52fc4845600a5c7df37353674fde
parent1be4595e2c2fee4c32ee083240a2200ab70ef71b (diff)
Add helpful--calculate-references
-rw-r--r--helpful.el28
1 files changed, 17 insertions, 11 deletions
diff --git a/helpful.el b/helpful.el
index 44c8088..ea68944 100644
--- 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)