helpful

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

commit 3e08b24e9eabbb17535d39b087895c04cbcd5c1f
parent f3c20d831a80ac00b411358fffab4789ba9f67f6
Author: Wilfred Hughes <me@wilfred.me.uk>
Date:   Mon, 16 Oct 2017 22:37:35 +0100

Simplify and rename helpful--position-head

helpful--outer-sexp more closely reflects the purpose of the function,
which is to summarise the outer sexp.

Use beginning-of-defun rather than walking the sexp ourself. Hopefully
this will help with #46.

Diffstat:
Mhelpful.el | 12++++--------
1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/helpful.el b/helpful.el @@ -466,17 +466,13 @@ Ensures global keybindings are shown first." (s-join "\n" lines) "This command is not in any keymaps.")))) -(defun helpful--position-head (buf pos) +(defun helpful--outer-sexp (buf pos) "Find position POS in BUF, and return the name of the outer sexp, along with its position." (with-current-buffer buf (goto-char pos) - (let (finished) - (while (not finished) - (condition-case _err - (backward-up-list) - (error (setq finished t)))) - (list (point) (-take 2 (read buf)))))) + (beginning-of-defun) + (list (point) (-take 2 (read buf))))) (defun helpful--count-values (items) "Return an alist of the count of each value in ITEMS. @@ -564,7 +560,7 @@ state of the current symbol." (helpful--reference-positions helpful--sym helpful--callable-p buf)))) (setq references - (--map (helpful--position-head buf it) positions)) + (--map (helpful--outer-sexp buf it) positions)) (kill-buffer buf))) (erase-buffer) (when helpful--callable-p