* Re: c-mode comment indent alignment issue
[not found] <mailman.24526.1366762780.855.help-gnu-emacs@gnu.org>
@ 2013-04-24 11:56 ` Alan Mackenzie
2013-04-26 0:12 ` Francis Belliveau
0 siblings, 1 reply; 4+ messages in thread
From: Alan Mackenzie @ 2013-04-24 11:56 UTC (permalink / raw)
To: help-gnu-emacs
Francis Belliveau <f.belliveau@comcast.net> wrote:
> I am having trouble figuring out how to control comment indentation and
> alignment. Consider the following sequence of comments:
> /*****
> *
> * @file foo.h
> *
> *****
> */
> /*
> * $Revision$
> *
> *****
> */
> /*
> *****
> *
> * Sample...
> *
> *****
> */
> In c-mode when they are all in the region and I "indent-region", the
> first two comments don't change, but the content of the last comment
> gets jammed against the left edge.
> If I put a " *" before the upper row of asterisks all is okay.
> Can anybody tell me how I can take control of the comment indentation
> logic to stop the indentation from being eliminated?
This is difficult. The critical line which determines the indentation
of the entire comment is the second line, thus:
/*
***** <===============
....
If the number of asterisks is greater than the number in the "/***"
comment opener, the second line is "aligned left" under the "/***".
(This is what you don't like here.) Otherwise, like in the "foo.h"
and "$Revision$" comments, it is "aligned right". The thinking behind
this left alignment is to indent this case:
/*
** Text.
** Text.
*/
This is all done by the lisp function `c-lineup-C-comments'. Adapting
this function to change this behaviour could give you the result you want.
Instructions for doing this are on page "Custom Line-Up" of the CC Mode
manual.
Sorry I can't be more helpful.
> Fran
--
Alan Mackenzie (Nuremberg, Germany).
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: c-mode comment indent alignment issue
2013-04-24 11:56 ` c-mode comment indent alignment issue Alan Mackenzie
@ 2013-04-26 0:12 ` Francis Belliveau
2013-04-30 14:47 ` Ludwig, Mark
0 siblings, 1 reply; 4+ messages in thread
From: Francis Belliveau @ 2013-04-26 0:12 UTC (permalink / raw)
To: help-gnu-emacs@gnu.org
Thanks to Alan I can at least create a work-around by changing to
/*
* ****
*
* Sample…
*
* ****
*/
I found the function "c-lineup-C-comments" to complicated for me to quickly modify.
I would actually like to hear from those who would like a reasonable modification to the logic as follows:
"If the line following the comment open contains all the same "non-alpha-numeric" character then that becomes the controlling line"
That would mean that"
/*
** Text
*/
Continues to work as before but
/*
**
** Text
**
*/
Stays indented.
Does anybody else have a strong opinion about this?
Fran
On Apr 24, 2013, at 7:56 AM, Alan Mackenzie <acm@muc.de> wrote:
> Francis Belliveau <f.belliveau@comcast.net> wrote:
>> I am having trouble figuring out how to control comment indentation and
>> alignment. Consider the following sequence of comments:
>
>> /*****
>> *
>> * @file foo.h
>> *
>> *****
>> */
>> /*
>> * $Revision$
>> *
>> *****
>> */
>> /*
>> *****
>> *
>> * Sample...
>> *
>> *****
>> */
>
>> In c-mode when they are all in the region and I "indent-region", the
>> first two comments don't change, but the content of the last comment
>> gets jammed against the left edge.
>
>> If I put a " *" before the upper row of asterisks all is okay.
>
>> Can anybody tell me how I can take control of the comment indentation
>> logic to stop the indentation from being eliminated?
>
> This is difficult. The critical line which determines the indentation
> of the entire comment is the second line, thus:
>
> /*
> ***** <===============
> ....
>
> If the number of asterisks is greater than the number in the "/***"
> comment opener, the second line is "aligned left" under the "/***".
> (This is what you don't like here.) Otherwise, like in the "foo.h"
> and "$Revision$" comments, it is "aligned right". The thinking behind
> this left alignment is to indent this case:
>
> /*
> ** Text.
> ** Text.
> */
>
> This is all done by the lisp function `c-lineup-C-comments'. Adapting
> this function to change this behaviour could give you the result you want.
> Instructions for doing this are on page "Custom Line-Up" of the CC Mode
> manual.
>
> Sorry I can't be more helpful.
>
>> Fran
>
> --
> Alan Mackenzie (Nuremberg, Germany).
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: c-mode comment indent alignment issue
2013-04-26 0:12 ` Francis Belliveau
@ 2013-04-30 14:47 ` Ludwig, Mark
0 siblings, 0 replies; 4+ messages in thread
From: Ludwig, Mark @ 2013-04-30 14:47 UTC (permalink / raw)
To: Francis Belliveau, help-gnu-emacs@gnu.org
> From: Francis Belliveau, Thursday, April 25, 2013 7:13 PM
> I would actually like to hear from those who would like a reasonable
> modification to the logic as follows:
> "If the line following the comment open contains all the same "non-alpha-
> numeric" character then that becomes the controlling line"
> That would mean that"
> /*
> ** Text
> */
> Continues to work as before but
> /*
> **
> ** Text
> **
> */
> Stays indented.
>
> Does anybody else have a strong opinion about this?
I like the proposal, and would go further (I do not like the example
that works as before). It's not a style I have ever seen. Best would
be to "make it all configurable" similar to the way the rest of
cc-mode works. Ahh, what a beautiful Blue Sky.... ;-)
Thanks,
Mark Ludwig
^ permalink raw reply [flat|nested] 4+ messages in thread
* c-mode comment indent alignment issue
@ 2013-04-24 0:01 Francis Belliveau
0 siblings, 0 replies; 4+ messages in thread
From: Francis Belliveau @ 2013-04-24 0:01 UTC (permalink / raw)
To: help-gnu-emacs
I am having trouble figuring out how to control comment indentation and alignment. Consider the following sequence of comments:
/*****
*
* @file foo.h
*
*****
*/
/*
* $Revision$
*
*****
*/
/*
*****
*
* Sample...
*
*****
*/
In c-mode when they are all in the region and I "indent-region", the first two comments don't change, but the content of the last comment gets jammed against the left edge.
If I put a " *" before the upper row of asterisks all is okay.
Can anybody tell me how I can take control of the comment indentation logic to stop the indentation from being eliminated?
Fran
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-04-30 14:47 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <mailman.24526.1366762780.855.help-gnu-emacs@gnu.org>
2013-04-24 11:56 ` c-mode comment indent alignment issue Alan Mackenzie
2013-04-26 0:12 ` Francis Belliveau
2013-04-30 14:47 ` Ludwig, Mark
2013-04-24 0:01 Francis Belliveau
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).