]> code.delx.au - gnu-emacs-elpa/commitdiff
Don't expand in strings or comments
authorArtur Malabarba <bruce.connor.am@gmail.com>
Tue, 16 Jun 2015 17:47:48 +0000 (18:47 +0100)
committerArtur Malabarba <bruce.connor.am@gmail.com>
Tue, 16 Jun 2015 17:47:48 +0000 (18:47 +0100)
sotlisp.el

index dbdd03b18d13ce06f22f59d32c29b686d0b1b6bd..d093f0cad6a5d26401c7281c969b14c336e2957f 100644 (file)
@@ -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."