GNU bug report logs - #19740
25.0.50; Bad comment indentation by `C-M-q' in `emacs-lisp-mode'

Previous Next

Package: emacs;

Reported by: Drew Adams <drew.adams <at> oracle.com>

Date: Sun, 1 Feb 2015 04:20:02 UTC

Severity: minor

Tags: confirmed, fixed, patch

Merged with 6141

Found in versions 23.2, 25.0.50

Fixed in version 26.1

Done: npostavs <at> users.sourceforge.net

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 19740 in the body.
You can then email your comments to 19740 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#19740; Package emacs. (Sun, 01 Feb 2015 04:20:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Drew Adams <drew.adams <at> oracle.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 01 Feb 2015 04:20:03 GMT) Full text and rfc822 format available.

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

From: Drew Adams <drew.adams <at> oracle.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 25.0.50; Bad comment indentation by `C-M-q' in `emacs-lisp-mode'
Date: Sat, 31 Jan 2015 20:19:34 -0800 (PST)
This is a regression introduced after Emacs 20 (perhaps after 21).

Emacs should not indent the first `;;' comment line here by a space.
That does no good and interferes with alignment of a multi-line
comments and multiple separate comments that are on the same level.

(let* ( ;; If FOOBAR then blah the blahdy blah and other blahs if blah,
       ;; blah, or blah.  Unless, that is, blah, blah, or blah.
       (the-tatas (bar-bar-toto-babar foo1 foo2 foo3))
       ...)

In Emacs 20, this is the result - no extra space inserted.  The two
comment lines, which are logically at the same level, and in this case
are part of a single multi-line comment, are aligned vertically.

(let* (;; If FOOBAR then blah the blahdy blah and other blahs if blah,
       ;; blah, or blah.  Unless, that is, blah, blah, or blah.
       (the-tatas (bar-bar-toto-babar foo1 foo2 foo3))
       ...)

In GNU Emacs 25.0.50.1 (i686-pc-mingw32)
 of 2014-10-20 on LEG570
Bzr revision: 118168 rgm <at> gnu.org-20141020195941-icp42t8ttcnud09g
Windowing system distributor `Microsoft Corp.', version 6.1.7601
Configured using:
 `configure --enable-checking=yes,glyphs CPPFLAGS=-DGLYPH_DEBUG=1'




Forcibly Merged 6141 19740. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sat, 30 Apr 2016 17:08:02 GMT) Full text and rfc822 format available.

Added tag(s) patch. Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Wed, 14 Jun 2017 04:32:02 GMT) Full text and rfc822 format available.

Added blocking bug(s) 385 Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Wed, 14 Jun 2017 04:32:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#19740; Package emacs. (Wed, 14 Jun 2017 23:53:01 GMT) Full text and rfc822 format available.

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

From: npostavs <at> users.sourceforge.net
To: Drew Adams <drew.adams <at> oracle.com>
Cc: 19740 <at> debbugs.gnu.org
Subject: Re: bug#19740: 25.0.50;
 Bad comment indentation by `C-M-q' in `emacs-lisp-mode'
Date: Wed, 14 Jun 2017 19:54:08 -0400
[Message part 1 (text/plain, inline)]
# I accidentally tagged this bug instead of #385 before
tags 385 + patch
quit

Drew Adams <drew.adams <at> oracle.com> writes:

> This is a regression introduced after Emacs 20 (perhaps after 21).
>
> Emacs should not indent the first `;;' comment line here by a space.
> That does no good and interferes with alignment of a multi-line
> comments and multiple separate comments that are on the same level.
>
> (let* ( ;; If FOOBAR then blah the blahdy blah and other blahs if blah,
>        ;; blah, or blah.  Unless, that is, blah, blah, or blah.
>        (the-tatas (bar-bar-toto-babar foo1 foo2 foo3))
>        ...)
>
> In Emacs 20, this is the result - no extra space inserted.  The two
> comment lines, which are logically at the same level, and in this case
> are part of a single multi-line comment, are aligned vertically.
>
> (let* (;; If FOOBAR then blah the blahdy blah and other blahs if blah,
>        ;; blah, or blah.  Unless, that is, blah, blah, or blah.
>        (the-tatas (bar-bar-toto-babar foo1 foo2 foo3))
>        ...)


This was introduced in [1: bdbe3a8995].  I think in most contexts, it
makes sense to put the space, but it definitely looks wrong in a lisp
let.  Here's patch to override the alignment for comments following an
open in paren in lisp modes.  It requires the patch I posted for #385.

[v1-0001-Don-t-put-whitespace-between-open-paren-and-comme.patch (text/x-diff, inline)]
From f314ec8ee3b99bb6adc5ee789ef07b8b834b5c57 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs <at> gmail.com>
Date: Wed, 14 Jun 2017 00:13:06 -0400
Subject: [PATCH v1] Don't put whitespace between open paren and comment in
 Lisp modes (Bug#19740)

* lisp/emacs-lisp/lisp-mode.el (lisp-comment-indent): If current
line's code ends in open paren, set comment indentation exactly to
column following it.
(lisp-mode-variables): Set `comment-indent-function' to
`lisp-comment-indent'.
---
 lisp/emacs-lisp/lisp-mode.el | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el
index 59db00d5f9..985b7513a3 100644
--- a/lisp/emacs-lisp/lisp-mode.el
+++ b/lisp/emacs-lisp/lisp-mode.el
@@ -602,6 +602,7 @@ (defun lisp-mode-variables (&optional lisp-syntax keywords-case-insensitive
   ;;(set (make-local-variable 'adaptive-fill-mode) nil)
   (setq-local indent-line-function 'lisp-indent-line)
   (setq-local indent-region-function 'lisp-indent-region)
+  (setq-local comment-indent-function #'lisp-comment-indent)
   (setq-local outline-regexp ";;;\\(;* [^ \t\n]\\|###autoload\\)\\|(")
   (setq-local outline-level 'lisp-outline-level)
   (setq-local add-log-current-defun-function #'lisp-current-defun-name)
@@ -735,9 +736,15 @@ (defalias 'common-lisp-mode 'lisp-mode)
 
 (autoload 'lisp-eval-defun "inf-lisp" nil t)
 
-;; May still be used by some external Lisp-mode variant.
-(define-obsolete-function-alias 'lisp-comment-indent
-    'comment-indent-default "22.1")
+(defun lisp-comment-indent ()
+  "Like `comment-indent-default', but don't put space after open paren."
+  (let ((pt (point)))
+    (skip-syntax-backward " ")
+    (if (eq (preceding-char) ?\()
+        (cons (current-column) (current-column))
+      (goto-char pt)
+      (comment-indent-default))))
+
 (define-obsolete-function-alias 'lisp-mode-auto-fill 'do-auto-fill "23.1")
 
 (defcustom lisp-indent-offset nil
-- 
2.11.1

[Message part 3 (text/plain, inline)]

[1: bdbe3a8995]: 2000-09-29 19:11:42 +0000
  (comment-indent-function): Use 0 for ;;; and %%%. (comment-indent): Make sure there's a space between code and comment[...]
  http://git.savannah.gnu.org/cgit/emacs.git/commit/?id=bdbe3a8995c5f1dae126acd4be4872f6af687cd1

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#19740; Package emacs. (Thu, 06 Jul 2017 02:59:02 GMT) Full text and rfc822 format available.

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

From: npostavs <at> users.sourceforge.net
To: Drew Adams <drew.adams <at> oracle.com>
Cc: 19740 <at> debbugs.gnu.org
Subject: Re: bug#19740: 25.0.50;
 Bad comment indentation by `C-M-q' in `emacs-lisp-mode'
Date: Wed, 05 Jul 2017 23:00:03 -0400
tags 19740 fixed
close 19740 26.1
quit

npostavs <at> users.sourceforge.net writes:

>> This is a regression introduced after Emacs 20 (perhaps after 21).
>>
>> Emacs should not indent the first `;;' comment line here by a space.
>> That does no good and interferes with alignment of a multi-line
>> comments and multiple separate comments that are on the same level.
>>
>> (let* ( ;; If FOOBAR then blah the blahdy blah and other blahs if blah,
>>        ;; blah, or blah.  Unless, that is, blah, blah, or blah.
>>        (the-tatas (bar-bar-toto-babar foo1 foo2 foo3))
>>        ...)
>>
>> In Emacs 20, this is the result - no extra space inserted.  The two
>> comment lines, which are logically at the same level, and in this case
>> are part of a single multi-line comment, are aligned vertically.
>>
>> (let* (;; If FOOBAR then blah the blahdy blah and other blahs if blah,
>>        ;; blah, or blah.  Unless, that is, blah, blah, or blah.
>>        (the-tatas (bar-bar-toto-babar foo1 foo2 foo3))
>>        ...)
>
>
> This was introduced in [1: bdbe3a8995].  I think in most contexts, it
> makes sense to put the space, but it definitely looks wrong in a lisp
> let.  Here's patch to override the alignment for comments following an
> open in paren in lisp modes.

Pushed: [2: 7a0170de20] 

[2: 7a0170de20]: 2017-07-05 22:52:36 -0400
  Don't put whitespace between open paren and comment in Lisp modes (Bug#19740)
  http://git.savannah.gnu.org/cgit/emacs.git/commit/?id=7a0170de20fe1225d3eeac099d1e61a0c0410bf3




Added tag(s) fixed. Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Thu, 06 Jul 2017 02:59:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 26.1, send any further explanations to 19740 <at> debbugs.gnu.org and Drew Adams <drew.adams <at> oracle.com> Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Thu, 06 Jul 2017 02:59:03 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 03 Aug 2017 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 8 years and 13 days ago.

Previous Next


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