GNU bug report logs - #41793
`comment-only-p' erroneously flags blank lines as comments

Previous Next

Package: emacs;

Reported by: Toby Cubitt <toby-dated-1593021285.3f7973 <at> dr-qubit.org>

Date: Wed, 10 Jun 2020 18:02:02 UTC

Severity: normal

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


Message #19 received at 41793 <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>, Toby Cubitt
 <toby-dated-1593024851.318b83 <at> dr-qubit.org>
Cc: "41793 <at> debbugs.gnu.org" <41793 <at> debbugs.gnu.org>
Subject: RE: [External] : bug#41793: `comment-only-p' erroneously flags blank
 lines as comments
Date: Mon, 9 May 2022 15:07:10 +0000
> 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 `;'.




This bug report was last modified 3 years and 14 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.