GNU bug report logs -
#78003
31.0.50; comment-indent misbehaves in multiline comments
Previous Next
Reported by: Sean Whitton <spwhitton <at> spwhitton.name>
Date: Wed, 23 Apr 2025 03:19:01 UTC
Severity: normal
Found in version 31.0.50
Fixed in version 31.1
Done: Sean Whitton <spwhitton <at> spwhitton.name>
Bug is archived. No further changes may be made.
Full log
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
X-debbugs-cc: monnier <at> iro.umontreal.ca
1. emacs -q
2. C-x b foo RET
3. M-x lisp-mode RET
4. Enter this content:
--8<---------------cut here---------------start------------->8---
#|
foo
#|
--8<---------------cut here---------------end--------------->8---
5. Put point after "foo".
6. M-;
The result is an insertion of trailing single-semicolon comment.
As we are already within a comment, this makes no sense. M-; should
either do nothing, or possibly perform some form of indentation.
We could fix this within comment-dwim. However, I propose instead to
change comment-indent (or possibly comment-search-forward).
This is because I first encountered this problem not via comment-dwim,
but via how indent-sexp calls comment-indent.
The above recipe with M-; is just the simplest reproducer I found.
Making comment-indent behave better within multiline comments would make
it a more useful function in general and also fix these various
misbehaviours at once.
Other background:
- Possibly indent-sexp needs some adjustment too, but any change to
comment-indent should come first.
- A similar problem shows up with syntax-propertize-function values
which set comment-fence syntax-table text properties, which are
another kind of multiline comment.
(Came up for me in consfigurator.el's syntax-propertize-function.)
- A similar problem shows up with the literate-scratch library
Stefan M. and I were discussing over the past few days, where the
problem is that the library adds a whitespace syntax-table property to
some trailing newlines such that it is only the second of the two
newlines following a paragraph which ends the comment. With point
between the two newlines, we're still in a comment, but comment-indent
doesn't think so.
--
Sean Whitton
This bug report was last modified 27 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.