[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: bad comment indentation in Emacs Lisp

From: Drew Adams
Subject: RE: bad comment indentation in Emacs Lisp
Date: Sun, 10 Feb 2008 14:38:23 -0800

> > The principle he cites is correct -- could you please fix this
> > and ack?
> I don't see in what way the behavior doesn't follow the 
> principle proposed.
> > Put this in Emacs Lisp mode and use `C-M-q' at the beginning:
> > (let (;; foobar
> >       ;; toto
> >       (titi...)))
> > 
> > You get this:
> > (let ( ;; foobar
> >       ;; toto
> >       (titi...)))
> >
> > However, if you just use TAB on each line, you don't get that.
> Right, because indent-region does both TAB and M-; on each line (more
> or less).

No. Neither `M-;' nor TAB moves `;;' comments, except that TAB can move a
line that *starts* with `;;'. That is not the case for the `;;' comment that
is moved here.

> > To me, this is a bug.  `;;' comments should be aligned just as
> > TAB would align them, always.
> TAB generally doesn't touch the comments unless the line itself starts
> with a comment.

Precisely. But `C-M-q' *does* now move a comment that does not start a line.
TAB still (thankfully) does not (relative to the rest of its line). `C-M-q'
should not do what neither TAB nor `M-;' does.

> > `C-M-q' should be equivalent to using both TAB and `M-;' on 
> > each line of the sexp.
> That's indeed what it does.

Not at all. See above. Neither TAB nor `M-;' moves the first comment of the

Go line by line, and do both TAB and `M-;' on each line, and you will see
that the first comment does not move. But `C-M-q' now moves it. This is a
regression: As you have agreed, `C-M-q' should do only what TAB plus `M-;'

> > Also, in a situation like the preceding, it is likely that you
> > want the two comments to line up.
> It's possible, but not sure.  Use a single ";" to get 
> comments aligned.

Why? Why should someone need to replace `;;' by `;'? Why should code that
has always used `;;' to resist in-line movement now be indented differently?

Users have always used `;;' that is not at the start of a line to make a
comment stay put - unlike what `;' does wrt `M-;'. That's precisely why
`M-;' was designed not to move `;;'. Inline `;;' has always let you align
(position) comments manually.

`C-M-q', like TAB, should leave `;;' comments alone, unless they start a

> And use ";;" but put each comment-line on its own line.

Why? Why should someone now need to move `;;' comments to their own line,
just so `C-M-q' won't move them?

And note that this new behavior does not even indent the same as either (1)
`;' or (2) `;;' on a line by itself. This is some entirely new indentation:
(presumably) add a space before `;;'.

> This way, there won't be any ambiguity and they'll be aligned.

What ambiguity? There is no ambiguity. The `C-M-q' code has simply been
broken. It has previously always been equivalent to TAB + `M-;' on each
line. What problem is the new behavior intended to solve?

reply via email to

[Prev in Thread] Current Thread [Next in Thread]