From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: 55716@debbugs.gnu.org
Subject: bug#55716: 29.0.50; latex-mode overrides my `comment-style` choice
Date: Tue, 31 May 2022 14:54:40 -0400 [thread overview]
Message-ID: <jwvczft5y96.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <jwvy1yh6gbr.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Tue, 31 May 2022 08:26:16 -0400")
> Yes, it's a new problem introduced by the new functionality of
> commenting out empty lines (and it probably affects more than just the
> `indent` style, since most styles (other than `plain`) try to indent the
> comment, IIRC).
I suspect that the patch below would fix it.
Stefan
diff --git a/lisp/newcomment.el b/lisp/newcomment.el
index 95adf9f90a1..ebf4357f4fe 100644
--- a/lisp/newcomment.el
+++ b/lisp/newcomment.el
@@ -1177,6 +1177,10 @@ comment-region-internal
(setq max-indent (max max-indent (current-column)))
(not (or (eobp) (progn (forward-line) nil)))))
+ ;; In case there's only whitespace, we could try to look at
+ ;; surrounding text for inspiration, but we'll just use 0 instead.
+ (when (eq min-indent (point-max)) (setq min-indent 0))
+
(setq max-indent
(+ max-indent (max (length cs) (length ccs))
;; Inserting ccs can change max-indent by (1- tab-width)
@@ -1297,9 +1301,9 @@ comment-region-default-1
;; In Lisp and similar modes with one-character comment starters,
;; double it by default if `comment-add' says so.
;; If it isn't indented, triple it.
- (if (and (null arg) (not multi-char))
- (setq numarg (* comment-add (if triple 2 1)))
- (setq numarg (1- (prefix-numeric-value arg))))
+ (setq numarg (if (and (null arg) (not multi-char))
+ (* comment-add (if triple 2 1))
+ (1- (prefix-numeric-value arg))))
(comment-region-internal
beg end
next prev parent reply other threads:[~2022-05-31 18:54 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-29 21:57 bug#55716: 29.0.50; latex-mode overrides my `comment-style` choice Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-05-30 18:24 ` Lars Ingebrigtsen
2022-05-31 12:26 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-05-31 18:27 ` Lars Ingebrigtsen
2022-05-31 18:54 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2022-06-01 2:33 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwvczft5y96.fsf-monnier+emacs@gnu.org \
--to=bug-gnu-emacs@gnu.org \
--cc=55716@debbugs.gnu.org \
--cc=larsi@gnus.org \
--cc=monnier@iro.umontreal.ca \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.