helpful

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

commit d37d32e01183143b62d51fb7967883959f48bbeb
parent e82cdba6c34bb8f8b80fd62d7afc54e133b5b46e
Author: Wilfred Hughes <me@wilfred.me.uk>
Date:   Sat, 27 Oct 2018 16:30:16 +0100

Use syntax-ppss to find the outer sexp

beginning-of-defun just uses open-paren-in-column-0-is-defun-start,
which fooled functions like face-attribute where the docstring
contains a open paren at the start of the line.

Fixes #170

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

diff --git a/helpful.el b/helpful.el @@ -1411,9 +1411,10 @@ along with its position. Moves point in BUF." (with-current-buffer buf (goto-char pos) - (let* ((ppss (syntax-ppss))) - (unless (zerop (syntax-ppss-depth ppss)) - (beginning-of-defun))) + (let* ((ppss (syntax-ppss)) + (outer-sexp-posns (nth 9 ppss))) + (when outer-sexp-posns + (goto-char (car outer-sexp-posns)))) (list (point) (-take 2 (read buf))))) (defun helpful--count-values (items) diff --git a/test/helpful-unit-test.el b/test/helpful-unit-test.el @@ -134,6 +134,8 @@ symbol (not a form)." (should (helpful--primitive-p 'rename-buffer t))) (ert-deftest helpful-callable () + ;; Functions. Also a regression test for #170. + (helpful-callable 'face-attribute) ;; We should not crash when looking at macros. (helpful-callable 'when) ;; Special forms should work too.