all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#6141: 23.2; comment-choose-indent does the wrong thing
@ 2010-05-08 16:52 Drew Adams
  0 siblings, 0 replies; only message in thread
From: Drew Adams @ 2010-05-08 16:52 UTC (permalink / raw)
  To: 6141

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'
 








^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-05-08 16:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-08 16:52 bug#6141: 23.2; comment-choose-indent does the wrong thing Drew Adams

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.