From: Alan McKenzie <MAILER-DAEMON@mail.muc.de>
To: 24172@debbugs.gnu.org
Subject: bug#24172: 25.1; Doc of parse-sexp-ignore-comments: what does a value of nil mean?
Date: Sun, 28 Jul 2019 09:20:38 +0000 [thread overview]
Message-ID: <20190728092038.GC5072@ACM> (raw)
In-Reply-To: <874m6xqxy9.fsf@web.de>
Hello, Lars.
In article <mailman.2415.1564240928.2688.bug-gnu-emacs@gnu.org> you wrote:
> Michael Heerdegen <michael_heerdegen@web.de> writes:
>> in the docstring of `parse-sexp-ignore-comments' (or at least in the
>> manual), I miss a description about what a value of nil exactly means:
>> How are comments treated then? Are they treated as separate units that
>> can then be parsed as well, but separately from code, or are they treated
>> as indistinguishable from code?
>> For example, if parsing starts from within a comment, and parsing finds
>> the end of the comment and is not yet finished, is parsing just
>> continued inside the following code, or does it fail?
> After doing some testing, it seems that if it's nil, the commands
> affected by the setting just treat the commented-out text as if it
> wasn't commented out.
> So the answer to your last question seems to be "yes".
> ;; (foo
> (bar zot))
> However, pretty much the same thing happens with a non-nil value, too --
> with point before (foo C-M-f will advance past zot)).
> So it doesn't treat comments as whitespace, really -- it only does that
> if point is outside (before, at the end of a line, etc) the comment to
> begin with. Seems like you could write an essay about it, but perhaps
> it's not worth listing the eccentricities here which I guess could change.
parse-sexp-ignore-comments (or, rather, parse_sexp_ignore_comments) is
tested, and acted upon, by precisely one C function, scan_lists in
syntax.c. scan_lists is used by just two primitives, scan-lists and
scan-sexps. These, in turn, are called by forward-list, etc.
When this variable is nil, scan_lists fails to recognise comment
delimiters - it just goes past them as though they were random
punctuation characters. By contrast, when parse-sexp-ignore-comments is
t, scan_lists calls a comment scanning function when it encounters a
comment delimiter.
Noteworthy is that parse-partial-sexp doesn't respect the setting of
parse-sexp-ignore-comments. This might be considered a bug.
All in all, this variable seems not to be a good idea. It is not tested
consistently by the syntax routines (see above), must be set explicitly
to t by any major mode with comments, the nil value is rarely used, and
it is not clear whether this nil value is actually ever useful.
It would seem that if a major mode does not want comments to be
recognised, it would be better not to give any character comment syntax
in its syntax table.
> --
> (domestic pets only, the antidote for overdose, milk.)
> bloggy blog: http://lars.ingebrigtsen.no
--
Alan Mackenzie (Nuremberg, Germany).
next prev parent reply other threads:[~2019-07-28 9:20 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-06 23:28 bug#24172: 25.1; Doc of parse-sexp-ignore-comments: what does a value of nil mean? Michael Heerdegen
2019-07-27 15:21 ` Lars Ingebrigtsen
2021-10-23 17:32 ` Stefan Kangas
2021-10-24 13:11 ` Lars Ingebrigtsen
2019-07-28 9:20 ` Alan McKenzie [this message]
2019-07-29 2:18 ` Michael Heerdegen
[not found] <20190728082012.19960.qmail@mail.muc.de>
2019-07-28 10:11 ` Lars Ingebrigtsen
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190728092038.GC5072@ACM \
--to=mailer-daemon@mail.muc.de \
--cc=24172@debbugs.gnu.org \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).