]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix C-x C-e with defvars in comments preceding
authorLars Ingebrigtsen <larsi@gnus.org>
Thu, 11 Jul 2019 13:42:13 +0000 (15:42 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Thu, 11 Jul 2019 13:46:06 +0000 (15:46 +0200)
* lisp/progmodes/elisp-mode.el (eval-sexp-add-defvars): When
collecting defvars in the current buffer, ignore the ones that are
in comments or strings (bug#34233).

lisp/progmodes/elisp-mode.el

index cb1b17b4474cb166250c9e1bc0fd95098b13cdde..ae09bfc022406e45799d72141c6c7a36be7bce64 100644 (file)
@@ -1179,7 +1179,11 @@ POS specifies the starting position where EXP was found and defaults to point."
           (let ((var (intern (match-string 1))))
             (and (not (special-variable-p var))
                  (save-excursion
-                   (zerop (car (syntax-ppss (match-beginning 0)))))
+                   (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))))
         `(progn ,@(mapcar (lambda (v) `(defvar ,v)) vars) ,exp)))))