Commit a87bdb8f authored by Lars Ingebrigtsen's avatar Lars Ingebrigtsen

Fix C-x C-e with defvars in comments preceding

* 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).
parent 60fc771a
Pipeline #2367 passed with stage
in 66 minutes and 2 seconds
......@@ -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))
(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)))))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment