Subject: bug#385: [PATCH] comment-indent doesn't respect comment-indent-function

From: "Christopher J. Madsen" <[email-masked]>
Date: Wed, 11 Jun 2008 13:59:01 -0500 (CDT)

On Wed, June 11, 2008 1:04 pm, Stefan Monnier wrote:
>> It appears that comment-indent changed in 22.1.  It gained some code

>> For example, I had a custom indent function that placed comments
>> immediately after a closing brace.  However, in Emacs 22, I'd see this:
>
>>   while (1) {
>>     while (2) {
>
>>     } # end 2 <-- this comment placed correctly
>>   }   # end 1 <-- this comment was aligned with the previous one
>
>> instead of this:
>
>>   while (1) {
>>     while (2) {
>
>>     } # end 2
>>   } # end 1 <-- here's where comment-indent-function placed it
>
> I'm not sure I understand.  Are you saying that you don't want comments
> to be aligned in that case?

Yes.  I want the comment one space after the closing brace.  Period.  In
Emacs 22, there's no way for the comment-indent-function to say "Put it
here and don't second guess me."

> If you need more control over the placement, rather than a variable
> comment-indent-fixed, maybe we should just say that if
> comment-indent-function returns a list of a single integer, it should be
> taken as the indentation position and not second-guessed.  Or it could
> return a cons cell (MIN . MAX) to say "anywhere between MIN and MAX".

I thought about something like that.  The problem is that current versions
of Emacs would have no idea what to do with a return value that's not an
integer.  I use a variety of Emacs versions on a number of machines.  The
indent function would have to check emacs-version and change the return
value accordingly.  That's always a mess.

The advantage of my approach is that you can use the same indent function
on any version of Emacs.  Older versions just won't pay any attention to
comment-indent-fixed.  Otherwise, I'd go with returning a list.

-- 
Chris Madsen                                           cjm cjmweb.net
   --------------------  http://www.cjmweb.net  --------------------