[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#41793: `comment-only-p' erroneously flags blank lines as comments
From: |
Drew Adams |
Subject: |
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 `;'.