help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: emacs: indent automatically on c, c++, php comments


From: Alan Mackenzie
Subject: Re: emacs: indent automatically on c, c++, php comments
Date: Sat, 13 Sep 2003 18:59:54 +0000
User-agent: tin/1.4.5-20010409 ("One More Nightmare") (UNIX) (Linux/2.0.35 (i686))

Alex Braumann <ab@msedv.at> wrote on Sat, 13 Sep 2003 15:38:38 GMT:
> On Sat, 13 Sep 2003 13:36:52 +0000, Alan Mackenzie wrote:

>>> (defun my-php-mode-hook ( )
>>>    (setq comment-column 30))
>>>   (add-hook 'c++-mode-hook 'my-php-mode-hook)

>> It's your third line that's at fault.

>> (add-hook 'c++-mode-hook 'my-php-mode-hook) says "Add the function
>> my-php-mode-hook to the list of functions which is called whenever C++
>> MODE is started."

>> Replace "c++-mode-hook" with "php-mode-hook", giving this: (add-hook
>> 'php-mode-hook 'my-php-mode-hook)

>> [Or, if you'd already written that and merely made a typo when composing
>> your article (it happens to the best of us) come back again!]


> It has been a typo :)

> so, here I am!

Hi, there!

I've actually loaded up the mode and tried it out.  I should have done
this earlier.  :-(

What I see is that M-; on a _blank_ line leaves the "//" at column zero.
On a non-blank line (even if it's only got a single space), the "//" does
indeed go to column 32 (or 30).

So if you want a comment at C30 on an otherwise blank line, type a single
space followed by M-;

If you have a line with a comment at C0, and you want to reallign it to
C30, type a single space at the start of the line, followed by M-;  .
This will move the existing comment rather than creating a silly "second
comment" on the line.

Finally, a useful command if you've got a comment at C30 but you really
wanted it at C0 is M-\ 'delete-horizontal-space', which does what it
says.  [Yes, I know M-\ is awkward to type on a German keyboard layout.
You can use <esc> \ (two separate key actions) instead.]

Hope all this works as described and does what you want.  If not, come
back yet again!

-- 
Alan Mackenzie (Munich, Germany)
Email: aacm@muuc.dee; to decode, wherever there is a repeated letter
(like "aa"), remove half of them (leaving, say, "a").



reply via email to

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