GNU bug report logs - #6141
23.2; comment-choose-indent does the wrong thing

Previous Next

Package: emacs;

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

Date: Sat, 8 May 2010 16:53:01 UTC

Severity: minor

Tags: confirmed, fixed, patch

Merged with 19740

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 6141 in the body.
You can then email your comments to 6141 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 owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6141; Package emacs. (Sat, 08 May 2010 16:53:01 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. (Sat, 08 May 2010 16:53:01 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: 23.2; comment-choose-indent does the wrong thing
Date: Sat, 8 May 2010 09:52:38 -0700
Put the cursor on the first comment line in this defun and hit M-;.  The
comment is moved one space to the right.  It should not be moved at all.
 
(defun foo (zz)
  "..."
  (let (;; (xx  xx)
        ;; (ww  ww)
        (mm  mm))
    toto))
 
`comment-choose-indent' is the problematic code.  It is called with arg
INDENT = 0 in this case
 
The doc string of `comment-choose-indent', which is the problematic
code, even says that the code should try to align with surrounding
comments, and that it should prefer INDENT:
 
"Choose the indentation to use for a right-hand-side comment.
The criteria are (in this order):
- try to keep the comment's text within `comment-fill-column'.
- try to align with surrounding comments.
- prefer INDENT (or `comment-column' if nil).
Point is expected to be at the start of the comment."
 
The problem comes from the systematic (1+ (current-column)), which sets
the minimum (variable MIN) to one more than the current column.
 
See also this comment:
 
;; Can't align to a previous comment: let's try to align to comments
;; on the following lines, then.  These have not been re-indented yet,
;; so we can't directly align ourselves with them.  All we do is to try
;; and choose an indentation point with which they will be able to
;; align themselves.
 
The assumption that the following comment lines have not been correctly
indented is incorrect in this case. `comment-choose-indent' should not
be assuming anything about "re-indenting" - it is for _caller_ functions
to deal with any re-indenting that might take place on other lines than
the current one.  `comment-choose-indent' does not do any
"re-indenting".  It does not even do any indenting.  It simply returns a
computed possible indent value for code that might want to indent or
re-indent.
 
This bug exists since Emacs 21, BTW.  Emacs 20 does the right thing in
this case.
 

In GNU Emacs 23.2.1 (i386-mingw-nt5.1.2600)
 of 2010-05-08 on G41R2F1
Windowing system distributor `Microsoft Corp.', version 5.1.2600
configured using `configure --with-gcc (3.4) --no-opt --cflags -Ic:/xpm/include'
 






Added tag(s) confirmed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Mon, 10 Feb 2014 07:39:05 GMT) Full text and rfc822 format available.

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:03 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.

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 7 years and 323 days ago.

Previous Next


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