GNU bug report logs - #55716
29.0.50; latex-mode overrides my `comment-style` choice

Previous Next

Package: emacs;

Reported by: Stefan Monnier <monnier <at> iro.umontreal.ca>

Date: Sun, 29 May 2022 21:59:01 UTC

Severity: normal

Found in version 29.0.50

Fixed in version 29.1

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

Bug is archived. No further changes may be made.

Full log


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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 55716 <at> debbugs.gnu.org
Subject: Re: bug#55716: 29.0.50; latex-mode overrides my `comment-style` choice
Date: Tue, 31 May 2022 14:54:40 -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





This bug report was last modified 2 years and 359 days ago.

Previous Next


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