branch: master
commit 7f3838330bcba0277fe571125155150db0f8ca16
Author: Artur Malabarba <[email protected]>
Commit: Artur Malabarba <[email protected]>
Don't expand in strings or comments
---
sotlisp.el | 13 +++++++++++--
1 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/sotlisp.el b/sotlisp.el
index dbdd03b..d093f0c 100644
--- a/sotlisp.el
+++ b/sotlisp.el
@@ -109,6 +109,14 @@ Specially, avoids matching inside argument lists."
(forward-char -2)
(looking-at-p "#'"))))
+(defun sotlisp--code-p ()
+ (save-excursion
+ (let ((r (point)))
+ (beginning-of-defun)
+ (let ((pps (parse-partial-sexp (point) r)))
+ (not (or (elt pps 3)
+ (elt pps 4)))))))
+
(defun sotlisp--function-p ()
"Non-nil if point is at reasonable place for a function name.
Returns non-nil if, after moving backwards by a sexp, either
@@ -117,8 +125,9 @@ non-nil."
(save-excursion
(ignore-errors
(skip-chars-backward (rx alnum))
- (or (sotlisp--function-form-p)
- (sotlisp--function-quote-p)))))
+ (and (sotlisp--code-p)
+ (or (sotlisp--function-form-p)
+ (sotlisp--function-quote-p))))))
(defun sotlisp--whitespace-p ()
"Non-nil if current `self-insert'ed char is whitespace."