bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#55716: 29.0.50; latex-mode overrides my `comment-style` choice


From: Stefan Monnier
Subject: bug#55716: 29.0.50; latex-mode overrides my `comment-style` choice
Date: Tue, 31 May 2022 14:54:40 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

> 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






reply via email to

[Prev in Thread] Current Thread [Next in Thread]