all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* comments in cc mode
@ 2009-10-06 15:39 Michael
  2009-10-07 19:04 ` John A Pershing Jr
  2009-10-08  9:06 ` Andreas Röhler
  0 siblings, 2 replies; 8+ messages in thread
From: Michael @ 2009-10-06 15:39 UTC (permalink / raw
  To: help-gnu-emacs

Dear all,

I was wondering whether there is a simple way of changing the various
ways comments are placed in cc mode to one single default: always
place a double forward slash in column, say, 100 and then the comment
thereafter? I have experimented with the menu options yet so far to no
avail.

Any suggestion is appreciated. Thanks.

Greetings,
Michael


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: comments in cc mode
  2009-10-06 15:39 comments in cc mode Michael
@ 2009-10-07 19:04 ` John A Pershing Jr
  2009-10-08  9:06 ` Andreas Röhler
  1 sibling, 0 replies; 8+ messages in thread
From: John A Pershing Jr @ 2009-10-07 19:04 UTC (permalink / raw
  To: help-gnu-emacs

Michael <mmassmann@econ.vu.nl> writes:

> I was wondering whether there is a simple way of changing the various
> ways comments are placed in cc mode to one single default: always place
> a double forward slash in column, say, 100 and then the comment
> thereafter?

I don't know what "cc mode" is.  However, for C-like languages, try
putting the following into your ~/.emacs file:

    (add-hook 'c-mode-common-hook
              '(lambda ()
                 (setq comment-column 100)
                 ))

(You *really* want your comments way over there in column 100???)

  -jp


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: comments in cc mode
  2009-10-06 15:39 comments in cc mode Michael
  2009-10-07 19:04 ` John A Pershing Jr
@ 2009-10-08  9:06 ` Andreas Röhler
  2010-05-20  9:33   ` Massmann, M. (Michael)
       [not found]   ` <mailman.0.1274363526.31702.help-gnu-emacs@gnu.org>
  1 sibling, 2 replies; 8+ messages in thread
From: Andreas Röhler @ 2009-10-08  9:06 UTC (permalink / raw
  To: Michael; +Cc: help-gnu-emacs

Michael wrote:
> Dear all,
> 
> I was wondering whether there is a simple way of changing the various
> ways comments are placed in cc mode to one single default: always
> place a double forward slash in column, say, 100 and then the comment
> thereafter? I have experimented with the menu options yet so far to no
> avail.
> 
> Any suggestion is appreciated. Thanks.
> 
> Greetings,
> Michael
> 

M-x set-comment-column
M-x customize-variable RET comment-style

mode has it's own list BTW

cc-mode-help@lists.sourceforge.net

HTH




^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: comments in cc mode
  2009-10-08  9:06 ` Andreas Röhler
@ 2010-05-20  9:33   ` Massmann, M. (Michael)
       [not found]   ` <mailman.0.1274363526.31702.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 8+ messages in thread
From: Massmann, M. (Michael) @ 2010-05-20  9:33 UTC (permalink / raw
  To: Andreas Röhler; +Cc: help-gnu-emacs

Dear Andreas,

Many thanks for this. Could you point me to the documentation for the options available for comment-style? After playing around with some of them I did not get the desired effect.

I also had a look at cc-mode's `c-indent-comment-alist' and set every single entry to `column' and `nil', so as to have the default column (ie 100) apply, no matter what the surrounding syntax is. The variable `c-indent-comments-syntactically-p' I set to nil so that it does not override the previous settings.

This seems to have the desired effect that when I press M-; to insert a *new* comment on a line, empty or not, the comment indeed starts in column 100.

Yet when I press M-; to re-align an *existing* comment, the entire comment is moved to a column other than 100 in 9 out of 10 cases.

Any advice on how to rectify this problem would be appreciated. Thanks!

Regards,
Michael




> -----Original Message-----
> From: Andreas Röhler [mailto:andreas.roehler@easy-emacs.de]
> Sent: donderdag 8 oktober 2009 11:07
> To: Massmann, M. (Michael)
> Cc: help-gnu-emacs@gnu.org
> Subject: Re: comments in cc mode
> 
> Michael wrote:
> > Dear all,
> >
> > I was wondering whether there is a simple way of changing the various
> > ways comments are placed in cc mode to one single default: always
> > place a double forward slash in column, say, 100 and then the comment
> > thereafter? I have experimented with the menu options yet so far to
> no
> > avail.
> >
> > Any suggestion is appreciated. Thanks.
> >
> > Greetings,
> > Michael
> >
> 
> M-x set-comment-column
> M-x customize-variable RET comment-style
> 
> mode has it's own list BTW
> 
> cc-mode-help@lists.sourceforge.net
> 
> HTH



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: comments in cc mode
       [not found]   ` <mailman.0.1274363526.31702.help-gnu-emacs@gnu.org>
@ 2010-05-22  9:43     ` Alan Mackenzie
  2010-05-22 16:20       ` Michael
  0 siblings, 1 reply; 8+ messages in thread
From: Alan Mackenzie @ 2010-05-22  9:43 UTC (permalink / raw
  To: help-gnu-emacs

Hi, Michael,

"Massmann, M. (Michael)" <mmassmann@feweb.vu.nl> wrote:
> Dear Andreas,

> Many thanks for this. Could you point me to the documentation for the
> options available for comment-style? After playing around with some of
> them I did not get the desired effect.

> I also had a look at cc-mode's `c-indent-comment-alist' and set every
> single entry to `column' and `nil', so as to have the default column
> (ie 100) apply, no matter what the surrounding syntax is. The variable
> `c-indent-comments-syntactically-p' I set to nil so that it does not
> override the previous settings.

> This seems to have the desired effect that when I press M-; to insert a
> *new* comment on a line, empty or not, the comment indeed starts in
> column 100.

> Yet when I press M-; to re-align an *existing* comment, the entire
> comment is moved to a column other than 100 in 9 out of 10 cases.

> Any advice on how to rectify this problem would be appreciated. Thanks!

I've just gone through `comment-dwim' in edebug (the Emacs debugger), and
it seems like comments are being made to fit within `fill-column'.  I
don't know why this is being done, but could you try setting it to a high
value, say

    (setq fill-column 150)

.  Does this solve the immediate problem?  Does it introduce any new
problems?

> Regards,
> Michael

-- 
Alan Mackenzie (Nuremberg, Germany).



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: comments in cc mode
  2010-05-22  9:43     ` Alan Mackenzie
@ 2010-05-22 16:20       ` Michael
  2010-05-22 19:15         ` Alan Mackenzie
  0 siblings, 1 reply; 8+ messages in thread
From: Michael @ 2010-05-22 16:20 UTC (permalink / raw
  To: help-gnu-emacs

Dear Alan,

On May 22, 11:43 am, Alan Mackenzie <a...@muc.de> wrote:
> Hi, Michael,
>
> "Massmann, M. (Michael)" <mmassm...@feweb.vu.nl> wrote:
>
> > Dear Andreas,
> > Many thanks for this. Could you point me to the documentation for the
> > options available for comment-style? After playing around with some of
> > them I did not get the desired effect.
> > I also had a look at cc-mode's `c-indent-comment-alist' and set every
> > single entry to `column' and `nil', so as to have the default column
> > (ie 100) apply, no matter what the surrounding syntax is. The variable
> > `c-indent-comments-syntactically-p' I set to nil so that it does not
> > override the previous settings.
> > This seems to have the desired effect that when I press M-; to insert a
> > *new* comment on a line, empty or not, the comment indeed starts in
> > column 100.
> > Yet when I press M-; to re-align an *existing* comment, the entire
> > comment is moved to a column other than 100 in 9 out of 10 cases.
> > Any advice on how to rectify this problem would be appreciated. Thanks!
>
> I've just gone through `comment-dwim' in edebug (the Emacs debugger), and
> it seems like comments are being made to fit within `fill-column'.  I
> don't know why this is being done, but could you try setting it to a high
> value, say
>
>     (setq fill-column 150)
>
> .  Does this solve the immediate problem?  Does it introduce any new
> problems?
>
> > Regards,
> > Michael
>
> --
> Alan Mackenzie (Nuremberg, Germany).

Many thanks for your suggestion! This was precisely what was going
pear-shaped. I did have my fill-column at 150 to start with, but some
of my comments were more than 50 characters long, and they seem to
have been shifted left such that they ended on column 150. I have now
increased fill-column to 200 and everything works beautifully.

One more question if I may: is there an easy way to tell Emacs to
automatically set fill-column to 200 when in cc-mode and to leave it
at 150 otherwise (eg when loading auctex)? Column 200 is off my screen
and it is only with code comments that this doesn't bother me.

Thanks again for your help,
Michael


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: comments in cc mode
  2010-05-22 16:20       ` Michael
@ 2010-05-22 19:15         ` Alan Mackenzie
  2010-05-23 11:45           ` Michael
  0 siblings, 1 reply; 8+ messages in thread
From: Alan Mackenzie @ 2010-05-22 19:15 UTC (permalink / raw
  To: help-gnu-emacs

Michael <mmassmann@econ.vu.nl> wrote:
> Dear Alan,

> On May 22, 11:43?am, Alan Mackenzie <a...@muc.de> wrote:
>> Hi, Michael,

>> "Massmann, M. (Michael)" <mmassm...@feweb.vu.nl> wrote:

>> > Dear Andreas,
>> > Many thanks for this. Could you point me to the documentation for the
>> > options available for comment-style? After playing around with some of
>> > them I did not get the desired effect.
>> > I also had a look at cc-mode's `c-indent-comment-alist' and set every
>> > single entry to `column' and `nil', so as to have the default column
>> > (ie 100) apply, no matter what the surrounding syntax is. The variable
>> > `c-indent-comments-syntactically-p' I set to nil so that it does not
>> > override the previous settings.
>> > This seems to have the desired effect that when I press M-; to insert a
>> > *new* comment on a line, empty or not, the comment indeed starts in
>> > column 100.
>> > Yet when I press M-; to re-align an *existing* comment, the entire
>> > comment is moved to a column other than 100 in 9 out of 10 cases.
>> > Any advice on how to rectify this problem would be appreciated. Thanks!

>> I've just gone through `comment-dwim' in edebug (the Emacs debugger), and
>> it seems like comments are being made to fit within `fill-column'. ?I
>> don't know why this is being done, but could you try setting it to a high
>> value, say

>> ? ? (setq fill-column 150)

>> . ?Does this solve the immediate problem? ?Does it introduce any new
>> problems?

>> > Regards,
>> > Michael

>> --
>> Alan Mackenzie (Nuremberg, Germany).

> Many thanks for your suggestion! This was precisely what was going
> pear-shaped. I did have my fill-column at 150 to start with, but some
> of my comments were more than 50 characters long, and they seem to
> have been shifted left such that they ended on column 150. I have now
> increased fill-column to 200 and everything works beautifully.

> One more question if I may: is there an easy way to tell Emacs to
> automatically set fill-column to 200 when in cc-mode and to leave it
> at 150 otherwise (eg when loading auctex)? Column 200 is off my screen
> and it is only with code comments that this doesn't bother me.

The following (not tested) should do it:

(setq-default fill-column 150)
(defun mm-cc-fill-column ()
  (setq fill-column 200))
(add-hook 'c-mode-common-hook 'mm-cc-fill-column)

> Thanks again for your help,

No problem.  I must say, you've got a MUCH wider screen than I have.  ;-)

> Michael

-- 
Alan Mackenzie (Nuremberg, Germany).



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: comments in cc mode
  2010-05-22 19:15         ` Alan Mackenzie
@ 2010-05-23 11:45           ` Michael
  0 siblings, 0 replies; 8+ messages in thread
From: Michael @ 2010-05-23 11:45 UTC (permalink / raw
  To: help-gnu-emacs

On May 22, 9:15 pm, Alan Mackenzie <a...@muc.de> wrote:
> Michael <mmassm...@econ.vu.nl> wrote:
> > Dear Alan,
> > On May 22, 11:43?am, Alan Mackenzie <a...@muc.de> wrote:
> >> Hi, Michael,
> >> "Massmann, M. (Michael)" <mmassm...@feweb.vu.nl> wrote:
> >> > Dear Andreas,
> >> > Many thanks for this. Could you point me to the documentation for the
> >> > options available for comment-style? After playing around with some of
> >> > them I did not get the desired effect.
> >> > I also had a look at cc-mode's `c-indent-comment-alist' and set every
> >> > single entry to `column' and `nil', so as to have the default column
> >> > (ie 100) apply, no matter what the surrounding syntax is. The variable
> >> > `c-indent-comments-syntactically-p' I set to nil so that it does not
> >> > override the previous settings.
> >> > This seems to have the desired effect that when I press M-; to insert a
> >> > *new* comment on a line, empty or not, the comment indeed starts in
> >> > column 100.
> >> > Yet when I press M-; to re-align an *existing* comment, the entire
> >> > comment is moved to a column other than 100 in 9 out of 10 cases.
> >> > Any advice on how to rectify this problem would be appreciated. Thanks!
> >> I've just gone through `comment-dwim' in edebug (the Emacs debugger), and
> >> it seems like comments are being made to fit within `fill-column'. ?I
> >> don't know why this is being done, but could you try setting it to a high
> >> value, say
> >> ? ? (setq fill-column 150)
> >> . ?Does this solve the immediate problem? ?Does it introduce any new
> >> problems?
> >> > Regards,
> >> > Michael
> >> --
> >> Alan Mackenzie (Nuremberg, Germany).
> > Many thanks for your suggestion! This was precisely what was going
> > pear-shaped. I did have my fill-column at 150 to start with, but some
> > of my comments were more than 50 characters long, and they seem to
> > have been shifted left such that they ended on column 150. I have now
> > increased fill-column to 200 and everything works beautifully.
> > One more question if I may: is there an easy way to tell Emacs to
> > automatically set fill-column to 200 when in cc-mode and to leave it
> > at 150 otherwise (eg when loading auctex)? Column 200 is off my screen
> > and it is only with code comments that this doesn't bother me.
>
> The following (not tested) should do it:
>
> (setq-default fill-column 150)
> (defun mm-cc-fill-column ()
>   (setq fill-column 200))
> (add-hook 'c-mode-common-hook 'mm-cc-fill-column)
>
> > Thanks again for your help,
>
> No problem.  I must say, you've got a MUCH wider screen than I have.  ;-)
>
> > Michael
>
> --
> Alan Mackenzie (Nuremberg, Germany).

This works like a dream! Thanks, Alan.

PS: I would think my screen is standard size, but I do love small
fonts!


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2010-05-23 11:45 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-06 15:39 comments in cc mode Michael
2009-10-07 19:04 ` John A Pershing Jr
2009-10-08  9:06 ` Andreas Röhler
2010-05-20  9:33   ` Massmann, M. (Michael)
     [not found]   ` <mailman.0.1274363526.31702.help-gnu-emacs@gnu.org>
2010-05-22  9:43     ` Alan Mackenzie
2010-05-22 16:20       ` Michael
2010-05-22 19:15         ` Alan Mackenzie
2010-05-23 11:45           ` Michael

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.