]> git.eshelyaron.com Git - emacs.git/commitdiff
Use syntax-ppss-toplevel-pos for defvar search (Bug#34233)
authorNoam Postavsky <npostavs@gmail.com>
Thu, 11 Jul 2019 22:38:02 +0000 (18:38 -0400)
committerNoam Postavsky <npostavs@gmail.com>
Sun, 14 Jul 2019 01:25:10 +0000 (21:25 -0400)
* lisp/progmodes/elisp-mode.el (eval-sexp-add-defvars): Use
syntax-ppss-toplevel-pos instead of a raw check of syntax components.

lisp/progmodes/elisp-mode.el

index ae09bfc022406e45799d72141c6c7a36be7bce64..16851c0d826b4772a6e02a948f67ad8028802fca 100644 (file)
@@ -1177,14 +1177,11 @@ POS specifies the starting position where EXP was found and defaults to point."
                 "(def\\(?:var\\|const\\|custom\\)[ \t\n]+\\([^; '()\n\t]+\\)"
                 pos t)
           (let ((var (intern (match-string 1))))
-            (and (not (special-variable-p var))
-                 (save-excursion
-                   (let ((syntax (syntax-ppss (match-beginning 0))))
-                     ;; Top-level.
-                     (and (zerop (car syntax))
-                          ;; Not in a comment or string.
-                          (null (nth 8 syntax)))))
-                 (push var vars))))
+            (unless (or (special-variable-p var)
+                        (syntax-ppss-toplevel-pos
+                         (save-excursion
+                           (syntax-ppss (match-beginning 0)))))
+              (push var vars))))
         `(progn ,@(mapcar (lambda (v) `(defvar ,v)) vars) ,exp)))))
 
 (defun eval-last-sexp (eval-last-sexp-arg-internal)