GNU bug report logs -
#55716
29.0.50; latex-mode overrides my `comment-style` choice
Previous Next
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.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 55716 in the body.
You can then email your comments to 55716 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#55716
; Package
emacs
.
(Sun, 29 May 2022 21:59:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Stefan Monnier <monnier <at> iro.umontreal.ca>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Sun, 29 May 2022 21:59:01 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Package: Emacs
Version: 29.0.50
latex-mode started to impose the old `plain` comment-style a few months
ago, which I find rather annoying and not very user-friendly.
At first, I thought it was a bug somewhere in my config, but I now see
that it comes from:
commit 0870ebb3cbfcb097d85eea5eacaf992dd88ed204
Author: Lars Ingebrigtsen <larsi <at> gnus.org>
Date: Thu Jan 28 07:09:18 2021 +0100
Allow commenting out white space lines in latex-mode
* lisp/newcomment.el (comment-region-default-1): Allow commenting
out whitespace-only regions (bug#41793).
* lisp/textmodes/tex-mode.el (latex--comment-region): Use it.
(latex-mode): Set a comment style shim.
diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el
index c4e4864da17..ce665e61656 100644
--- a/lisp/textmodes/tex-mode.el
+++ b/lisp/textmodes/tex-mode.el
@@ -1169,7 +1169,12 @@ latex-mode
(setq-local outline-regexp latex-outline-regexp)
(setq-local outline-level #'latex-outline-level)
(setq-local forward-sexp-function #'latex-forward-sexp)
- (setq-local skeleton-end-hook nil))
+ (setq-local skeleton-end-hook nil)
+ (setq-local comment-region-function #'latex--comment-region)
+ (setq-local comment-style 'plain))
+
+(defun latex--comment-region (beg end &optional arg)
+ (comment-region-default-1 beg end arg t))
;;;###autoload
(define-derived-mode slitex-mode latex-mode "SliTeX"
The commit message doesn't explain why it changes `comment-style`.
Was that an oversight?
Stefan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#55716
; Package
emacs
.
(Mon, 30 May 2022 18:25:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 55716 <at> debbugs.gnu.org (full text, mbox):
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:
> The commit message doesn't explain why it changes `comment-style`.
> Was that an oversight?
Yes, sort of. The change is wrong, and should be fixed a different way,
I think.
The problem is that if you have this:
---
foo
bar
---
and comments out the blank line in the middle with `M-x comment-region',
you get
---
foo
%%
bar
---
Which doesn't seem right, so I assumed that `indent' didn't work for
latex-mode. But that's probably a bug in the `indent' version instead,
because `indent' should work in general.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#55716
; Package
emacs
.
(Tue, 31 May 2022 12:27:01 GMT)
Full text and
rfc822 format available.
Message #11 received at 55716 <at> debbugs.gnu.org (full text, mbox):
Lars Ingebrigtsen [2022-05-30 20:24:33] wrote:
> Stefan Monnier <monnier <at> iro.umontreal.ca> writes:
>> The commit message doesn't explain why it changes `comment-style`.
>> Was that an oversight?
>
> Yes, sort of. The change is wrong, and should be fixed a different way,
> I think.
>
> The problem is that if you have this:
>
> ---
> foo
>
> bar
> ---
>
> and comments out the blank line in the middle with `M-x comment-region',
> you get
>
> ---
> foo
> %%
> bar
> ---
>
> Which doesn't seem right, so I assumed that `indent' didn't work for
> latex-mode.
Before your patch, this didn't comment out anything since it skipped
empty lines, thus the problem didn't exist.
> But that's probably a bug in the `indent' version instead,
> because `indent' should work in general.
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).
Stefan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#55716
; Package
emacs
.
(Tue, 31 May 2022 18:29:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 55716 <at> debbugs.gnu.org (full text, mbox):
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:
> Before your patch, this didn't comment out anything since it skipped
> empty lines, thus the problem didn't exist.
Yes, that's the problem I was trying to fix.
>> But that's probably a bug in the `indent' version instead,
>> because `indent' should work in general.
>
> 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).
Yup. I've now reverted the change, and is reopening the bug report. I
guess it has to be fixed in the various indenting styles instead.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
bug marked as fixed in version 29.1, send any further explanations to
55716 <at> debbugs.gnu.org and Stefan Monnier <monnier <at> iro.umontreal.ca>
Request was from
Lars Ingebrigtsen <larsi <at> gnus.org>
to
control <at> debbugs.gnu.org
.
(Tue, 31 May 2022 18:29:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#55716
; Package
emacs
.
(Tue, 31 May 2022 18:55:02 GMT)
Full text and
rfc822 format available.
Message #19 received at 55716 <at> debbugs.gnu.org (full text, mbox):
> 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
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#55716
; Package
emacs
.
(Wed, 01 Jun 2022 02:35:02 GMT)
Full text and
rfc822 format available.
Message #22 received at 55716 <at> debbugs.gnu.org (full text, mbox):
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:
> I suspect that the patch below would fix it.
Makes sense to me, I think.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Wed, 29 Jun 2022 11:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 2 years and 358 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.