unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Alan Mackenzie<none@example.invalid>
Subject: Re: emacs: indent automatically on c, c++, php comments
Date: Sat, 6 Sep 2003 10:37:40 +0000	[thread overview]
Message-ID: <kddcjb.t5.ln@acm.acm> (raw)
In-Reply-To: pan.2003.09.06.09.30.47.439117@msedv.at

Alex Braumann <ab@msedv.at> wrote on Sat, 06 Sep 2003 09:30:47 GMT:
> Hi,

> I am not familiar with all the functions provided by this wonderful
> editor, also the configuration is not a task for 5 minutes :).

> I have a simple need:
>  If I type a '//' in my emacs, the cursor should jump to column number 30.

You're using C++ Mode, right?

> Is this practicable via the .emacs file in my home dir?

In essence, yes.  Instead of typing '//', use M-;  (that is, press the
semicolon key whilst holding the Meta key (probably the <alt> or <window>
key).  This will then insert the '//' at comment-column, which is by
default 32.  (if there's room on the line, that is.  If you've already
got a long statement on the line, M-; does the Right Thing).  You can
also use M-; to tidy up existing comments which have got ragged.

If you really, truly, absolutely want your comments at column 30 and not
32, change the value of comment-column in your C++ Mode hook.  If your
reaction to that is "My WHAT??", then the C++ Mode hook is that bit of
code, written by you, which gets executed each time a C++ buffer is
loaded.  Put the following into your .emacs:

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

Hook functions (like my-c++-mode-hook) typically contain personal
settings for indentation style, tab width, and so on.  You can read all
about this in the CC Mode manual:  C-h i, select CC Mode, then select the
page "Sample .emacs File".

> thanks! :)

> tc,
> alex.

-- 
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	other threads:[~2003-09-06 10:37 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-09-06  9:30 emacs: indent automatically on c, c++, php comments Alex Braumann
2003-09-06 10:37 ` Alan Mackenzie [this message]
2003-09-13 12:04   ` Alex Braumann
2003-09-13 13:36     ` Alan Mackenzie
2003-09-13 15:38       ` Alex Braumann
2003-09-13 18:59         ` Alan Mackenzie
2003-09-14 13:33           ` Alex Braumann
2003-09-15 15:21             ` Stefan Monnier
2003-09-15 19:50               ` Alex Braumann
2003-09-15 20:13                 ` Stefan Monnier
2003-09-17 13:42             ` Alan Mackenzie
2003-09-18  7:44               ` Alex Braumann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=kddcjb.t5.ln@acm.acm \
    --to=none@example.invalid \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).