[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#34233: 27.0.50; defvar in comment

From: Lars Ingebrigtsen
Subject: bug#34233: 27.0.50; defvar in comment
Date: Wed, 10 Jul 2019 13:42:10 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Michael Heerdegen <address@hidden> writes:

> This is `eval-sexp-add-defvars' not checking if defvars are really code.

So is this the correct solution?

diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el
index cb1b17b447..0e99cb9ac0 100644
--- a/lisp/progmodes/elisp-mode.el
+++ b/lisp/progmodes/elisp-mode.el
@@ -1179,7 +1179,13 @@ eval-sexp-add-defvars
           (let ((var (intern (match-string 1))))
             (and (not (special-variable-p var))
-                   (zerop (car (syntax-ppss (match-beginning 0)))))
+                   (let ((syntax (syntax-ppss (match-beginning 0))))
+                     ;; Top-level.
+                     (and (zerop (car syntax))
+                          ;; Not in a comment.
+                          (null (nth 4 syntax))
+                          ;; Not in a string.
+                          (null (nth 3 syntax)))))
                  (push var vars))))
         `(progn ,@(mapcar (lambda (v) `(defvar ,v)) vars) ,exp)))))
(Those ppss things really should have accessors.  :-))

(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no

reply via email to

[Prev in Thread] Current Thread [Next in Thread]