all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Drew Adams" <drew.adams@oracle.com>
To: 6141@debbugs.gnu.org
Subject: bug#6141: 23.2; comment-choose-indent does the wrong thing
Date: Sat, 8 May 2010 09:52:38 -0700	[thread overview]
Message-ID: <05022FFFFF0A4CB5A9568BD72D554BA9@us.oracle.com> (raw)

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'
 








                 reply	other threads:[~2010-05-08 16:52 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=05022FFFFF0A4CB5A9568BD72D554BA9@us.oracle.com \
    --to=drew.adams@oracle.com \
    --cc=6141@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.