diff options
| author | Nick Drozd <nicholasdrozd@gmail.com> | 2017-12-23 15:01:39 -0600 |
|---|---|---|
| committer | Wilfred Hughes <me@wilfred.me.uk> | 2018-01-01 11:52:32 +0000 |
| commit | 8c3c3ebcef05902f73573264d4c45cea2b53886b (patch) | |
| tree | 2240624573cc52fc4845600a5c7df37353674fde | |
| parent | 1be4595e2c2fee4c32ee083240a2200ab70ef71b (diff) | |
Add helpful--calculate-references
| -rw-r--r-- | helpful.el | 28 |
1 files changed, 17 insertions, 11 deletions
@@ -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) |
