unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Lars Ingebrigtsen <larsi@gnus.org>,
	Toby Cubitt <toby-dated-1593024851.318b83@dr-qubit.org>
Cc: "41793@debbugs.gnu.org" <41793@debbugs.gnu.org>
Subject: bug#41793: `comment-only-p' erroneously flags blank lines as comments
Date: Mon, 9 May 2022 15:07:10 +0000	[thread overview]
Message-ID: <SJ0PR10MB54881A520251B80A43F05F95F3C69@SJ0PR10MB5488.namprd10.prod.outlook.com> (raw)
In-Reply-To: <87sfpj7yaj.fsf@gnus.org>

> Anyway, I think it's ambiguous whether whitespace only 
> should be a comment or not.  The current algo considers
> this to be one comment:
> 
> ;; foo
> 
> ;; bar
> 
> And I think that's correct.  If we consider whitespace lines to not be
> comments, this would change how our comment navigation commands work.

We do NOT consider that to be the case.  Never have.

> So there's some DWIM in this area, but I think how it currently works
> is basically the way we want it to work, so I'm closing this bug report.

Those are two separate comments.  The line between them
is NOT commented out.

A comment is delimited by `comment-start' and
`comment-end'.  (And `comment-(start|end)-skip' and
`comment-end-can-be-escaped', if you like.)

Comments that have "" as `comment-end' "are terminated
by end-of-line" (to quote the doc string).

The doc is quite clear about all of this, IMO - in doc
strings, in the Emacs manual, and in the Elisp manual.

A Lisp comment "continues to the end of the line" - no
further.  ((elisp) `Comments'.)

Beyond the doc, this is fundamental to Elisp behavior.
Try `(forward-comment 1) on your test case, for example.

Code depends on `forward-comment' and the like,
including thingatpt.el code.
___

Whether `comment-only-p' should or should not report
`t' here is a different question from what I addressed
above.

That depends on what the intention of `comment-only-p
is.  I suggest you find out what that function was
intended for, and what existing code might depend on
its current behavior.

But one thing is certain: what you said about the
example you show being a single comment is 100% wrong.
It is two comments.

The same thing is true for this example, BTW:

;; foo
;; bar

Those are two comments.  It's possible, maybe even
likely, that the intention of `comment-only-p' is
to return non-nil when one comment is immediately
followed by another.  Or maybe even when one is
followed by whitespace and then by another.  TBD.

But those are two separate comments, each delimited
by the first `;' on each line and the first
end-of-line that follows that first `;'.





      reply	other threads:[~2022-05-09 15:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-10 17:53 bug#41793: `comment-only-p' erroneously flags blank lines as comments Toby Cubitt
2020-06-10 18:52 ` Toby Cubitt
2021-01-28  6:11   ` Lars Ingebrigtsen
2022-05-09 11:14     ` Lars Ingebrigtsen
2022-05-09 15:07       ` Drew Adams [this message]

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=SJ0PR10MB54881A520251B80A43F05F95F3C69@SJ0PR10MB5488.namprd10.prod.outlook.com \
    --to=drew.adams@oracle.com \
    --cc=41793@debbugs.gnu.org \
    --cc=larsi@gnus.org \
    --cc=toby-dated-1593024851.318b83@dr-qubit.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).