From: Noam Postavsky <npostavs@gmail.com>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: Michael Heerdegen <michael_heerdegen@web.de>,
34233@debbugs.gnu.org,
Sebastian Miele <sebastian.miele@gmail.com>,
Stefan Monnier <monnier@IRO.UMontreal.CA>
Subject: bug#34233: 27.0.50; defvar in comment
Date: Wed, 10 Jul 2019 07:49:43 -0400 [thread overview]
Message-ID: <87y3161548.fsf@gmail.com> (raw)
In-Reply-To: <m3pnmi15gt.fsf@gnus.org> (Lars Ingebrigtsen's message of "Wed, 10 Jul 2019 13:42:10 +0200")
Lars Ingebrigtsen <larsi@gnus.org> writes:
> Michael Heerdegen <michael_heerdegen@web.de> 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.
next prev parent reply other threads:[~2019-07-10 11:49 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-28 8:51 bug#34233: 27.0.50; defvar in comment Sebastian Miele
2019-07-09 18:11 ` Lars Ingebrigtsen
2019-07-09 18:49 ` Michael Heerdegen
2019-07-10 11:42 ` Lars Ingebrigtsen
2019-07-10 11:49 ` Noam Postavsky [this message]
2019-07-11 13:45 ` Lars Ingebrigtsen
2019-07-14 1:42 ` Noam Postavsky
2019-07-10 21:17 ` Michael Heerdegen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87y3161548.fsf@gmail.com \
--to=npostavs@gmail.com \
--cc=34233@debbugs.gnu.org \
--cc=larsi@gnus.org \
--cc=michael_heerdegen@web.de \
--cc=monnier@IRO.UMontreal.CA \
--cc=sebastian.miele@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.