unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* C style comments
@ 2004-02-18 17:24 Peter Collingbourne
  2004-02-18 18:52 ` Peter Collingbourne
  2004-02-18 19:11 ` Alan Mackenzie
  0 siblings, 2 replies; 3+ messages in thread
From: Peter Collingbourne @ 2004-02-18 17:24 UTC (permalink / raw)


Hello

I am new to Emacs and I am trying to get C style comments in Java. I.e.
/*
 *
 */

The below .emacs file works when the comment is not indented, but when there
is an indent before the code I am commenting I get something like this
        /*
 * 
 */
i.e. there is no indent on the lines after the first one. I use M-; to open
a comment and M-C-j to go the next line.

Here's my .emacs

(defun my-indent-setup ()
  (setq c-basic-offset 8)
  (setq indent-tabs-mode t)
  (setq comment-multi-line t)
  (setq comment-start "/*")
  (setq fill-prefix   " * ")
  (setq comment-end   " */")
)

(add-hook 'java-mode-hook 'my-indent-setup)

-- 
Peter

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

* Re: C style comments
  2004-02-18 17:24 C style comments Peter Collingbourne
@ 2004-02-18 18:52 ` Peter Collingbourne
  2004-02-18 19:11 ` Alan Mackenzie
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Collingbourne @ 2004-02-18 18:52 UTC (permalink / raw)


Sorry, please disregard my previous posting as I have figured out the
right way to do it (i.e. just typing the comments).
-- 
Peter

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

* Re: C style comments
  2004-02-18 17:24 C style comments Peter Collingbourne
  2004-02-18 18:52 ` Peter Collingbourne
@ 2004-02-18 19:11 ` Alan Mackenzie
  1 sibling, 0 replies; 3+ messages in thread
From: Alan Mackenzie @ 2004-02-18 19:11 UTC (permalink / raw)


Peter Collingbourne <pcc03@doc.ic.ac.uk> wrote on 18 Feb 2004 17:24:53 +0000:
> Hello

> I am new to Emacs and I am trying to get C style comments in Java. I.e.
> /*
>  *
>  */

> The below .emacs file works when the comment is not indented, but when there
> is an indent before the code I am commenting I get something like this
>         /*
>  * 
>  */
> i.e. there is no indent on the lines after the first one. I use M-; to open
> a comment and M-C-j to go the next line.

> Here's my .emacs

> (defun my-indent-setup ()
>   (setq c-basic-offset 8)
>   (setq indent-tabs-mode t)
>   (setq comment-multi-line t)
>   (setq comment-start "/*")
>   (setq fill-prefix   " * ")
>   (setq comment-end   " */")
> )

> (add-hook 'java-mode-hook 'my-indent-setup)

Remove the `(setq fill-prefix " * ")' from my-indent-setup.

What's happening is that in `c-indent-new-comment-line' (what C-M-j is
bound to) a fill-prefix overrules everything else, and this doesn't get
indented.  Incidentally, M-j is also bound to this function, and might be
easier to type.  :-)

If you actually need fill-prefix in this buffer for some good reason,
then we'll need to think of another solution.

> Peter

-- 
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").

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

end of thread, other threads:[~2004-02-18 19:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-02-18 17:24 C style comments Peter Collingbourne
2004-02-18 18:52 ` Peter Collingbourne
2004-02-18 19:11 ` Alan Mackenzie

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).