From 5d713c89e923fbc3192719792090cc40327b13a2 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Thu, 11 Jul 2019 18:38:02 -0400 Subject: [PATCH] Use syntax-ppss-toplevel-pos for defvar search (Bug#34233) * 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 | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el index ae09bfc0224..16851c0d826 100644 --- a/lisp/progmodes/elisp-mode.el +++ b/lisp/progmodes/elisp-mode.el @@ -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) -- 2.39.2