aboutsummaryrefslogtreecommitdiff
path: root/helpful.el
diff options
context:
space:
mode:
authorWilfred Hughes <me@wilfred.me.uk>2018-03-02 22:22:06 +0000
committerWilfred Hughes <me@wilfred.me.uk>2018-03-02 22:22:06 +0000
commit656ff91eb6094bbd5a78dcd6ef1e9ccb4d257a4d (patch)
treef7030b729725c6ca3557efbca11879fc6e20cdc7 /helpful.el
parent4abe04870467beb8a5a798773e1f145f65298e59 (diff)
Fix references to top-level forms
Previoiusly helpful--outer-sexp assumed point was inside a form, so returned the wrong sexp for top-level forms.
Diffstat (limited to 'helpful.el')
-rw-r--r--helpful.el8
1 files changed, 6 insertions, 2 deletions
diff --git a/helpful.el b/helpful.el
index 7a59d5b..e5efd67 100644
--- a/helpful.el
+++ b/helpful.el
@@ -1098,10 +1098,14 @@ from parent keymaps."
(defun helpful--outer-sexp (buf pos)
"Find position POS in BUF, and return the name of the outer sexp,
-along with its position."
+along with its position.
+
+Moves point in BUF."
(with-current-buffer buf
(goto-char pos)
- (beginning-of-defun)
+ (let* ((ppss (syntax-ppss)))
+ (unless (zerop (syntax-ppss-depth ppss))
+ (beginning-of-defun)))
(list (point) (-take 2 (read buf)))))
(defun helpful--count-values (items)