diff options
| author | Wilfred Hughes <me@wilfred.me.uk> | 2018-10-27 16:30:16 +0100 |
|---|---|---|
| committer | Wilfred Hughes <me@wilfred.me.uk> | 2018-10-27 16:30:16 +0100 |
| commit | d37d32e01183143b62d51fb7967883959f48bbeb (patch) | |
| tree | 83203febfb5341f9e0a09b619d62be977de7b3a7 | |
| parent | e82cdba6c34bb8f8b80fd62d7afc54e133b5b46e (diff) | |
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
| -rw-r--r-- | helpful.el | 7 | ||||
| -rw-r--r-- | test/helpful-unit-test.el | 2 |
2 files changed, 6 insertions, 3 deletions
@@ -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 index f6d4048..dc8acdc 100644 --- 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. |
