summaryrefslogtreecommitdiff
path: root/lisp/progmodes/elisp-mode.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/progmodes/elisp-mode.el')
-rw-r--r--lisp/progmodes/elisp-mode.el6
1 files changed, 5 insertions, 1 deletions
diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el
index cb1b17b4474..ae09bfc0224 100644
--- a/lisp/progmodes/elisp-mode.el
+++ b/lisp/progmodes/elisp-mode.el
@@ -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)))))