bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#34233: 27.0.50; defvar in comment


From: Noam Postavsky
Subject: bug#34233: 27.0.50; defvar in comment
Date: Wed, 10 Jul 2019 07:49:43 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2.90 (gnu/linux)

Lars Ingebrigtsen <address@hidden> writes:

> 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))
>                   (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.
> +                          (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.  :-))

There is already a function for this particular case:
syntax-ppss-toplevel-pos.





reply via email to

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