unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* M-; and M-j and c-comment alignment
@ 2013-11-26  9:24 Luca Ferrari
  0 siblings, 0 replies; 9+ messages in thread
From: Luca Ferrari @ 2013-11-26  9:24 UTC (permalink / raw)
  To: help-gnu-emacs

Hi,
I would like my comments to be multi-line as follows:
    /*
     * <here the cursor>
     */
and so a comment decorated with an empty top and bottom line. When I
press M-; emacs correctly opens the comment, and if then I hit M-j
emacs goes down one line and places the '*' for the new line, but this
makes the end of the comment on the last line:
    /*
     * <here the cursor> */

and so I have to manually C-j and indent the last line. Is there a way
to automatically open an aligned comment as the one I would like to
have?

Thanks,
Luca



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

* Re: M-; and M-j and c-comment alignment
       [not found] <mailman.7147.1385457886.10748.help-gnu-emacs@gnu.org>
@ 2013-11-26 10:52 ` Damien Wyart
  2013-11-26 10:53   ` Damien Wyart
                     ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Damien Wyart @ 2013-11-26 10:52 UTC (permalink / raw)
  To: help-gnu-emacs

* Luca Ferrari <fluca1978@infinito.it> in gnu.emacs.help:
> [...]

> Is there a way to automatically open an aligned comment as the one
> I would like to have?

Does setting comment-end to "\n*/" for C/C++ mode answers the question ?

A quit test with:

(add-hook 'c-mode-common-hook
          '(lambda ()
           (setq comment-end "\n*/")))

did the trick for me.

-- 
DW


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

* Re: M-; and M-j and c-comment alignment
  2013-11-26 10:52 ` M-; and M-j and c-comment alignment Damien Wyart
@ 2013-11-26 10:53   ` Damien Wyart
  2013-11-26 12:52     ` Luca Ferrari
       [not found]     ` <mailman.7160.1385470332.10748.help-gnu-emacs@gnu.org>
  2013-11-26 13:40   ` Stefan Monnier
       [not found]   ` <mailman.7164.1385473254.10748.help-gnu-emacs@gnu.org>
  2 siblings, 2 replies; 9+ messages in thread
From: Damien Wyart @ 2013-11-26 10:53 UTC (permalink / raw)
  To: help-gnu-emacs

> Does setting comment-end to "\n*/" for C/C++ mode answers the question ?

You can also have a look at doxymacs, which defines additional
comment-related commands you might find useful (even if you do not use
Doxygen at all).

-- 
DW


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

* Re: M-; and M-j and c-comment alignment
  2013-11-26 10:53   ` Damien Wyart
@ 2013-11-26 12:52     ` Luca Ferrari
       [not found]     ` <mailman.7160.1385470332.10748.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 9+ messages in thread
From: Luca Ferrari @ 2013-11-26 12:52 UTC (permalink / raw)
  To: Damien Wyart; +Cc: help-gnu-emacs

On Tue, Nov 26, 2013 at 11:53 AM, Damien Wyart <damien.wyart@free.fr> wrote:
>> Does setting comment-end to "\n*/" for C/C++ mode answers the question ?
>
> You can also have a look at doxymacs, which defines additional
> comment-related commands you might find useful (even if you do not use
> Doxygen at all).

Currently I've doxymacs installed, but the
doxymacs-insert-blank-multiline-comment is not strictly what I want
because:
1) it adds and extra line and an extra '*' in the beginning of the
comment (to mark it doxygen-like)
2) it requires me to use another key binding when M-; works for both
insert a new comment and comment out a region.

Thanks,
Luca



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

* Re: M-; and M-j and c-comment alignment
       [not found]     ` <mailman.7160.1385470332.10748.help-gnu-emacs@gnu.org>
@ 2013-11-26 13:07       ` Damien Wyart
  2013-11-27  7:16         ` Luca Ferrari
       [not found]         ` <mailman.7230.1385536609.10748.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 9+ messages in thread
From: Damien Wyart @ 2013-11-26 13:07 UTC (permalink / raw)
  To: help-gnu-emacs

* Luca Ferrari <fluca1978@infinito.it> in gnu.emacs.help:
> > > Does setting comment-end to "\n*/" for C/C++ mode answers the question ?

What about this proposal? Does it work for you?

-- 
DW


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

* Re: M-; and M-j and c-comment alignment
  2013-11-26 10:52 ` M-; and M-j and c-comment alignment Damien Wyart
  2013-11-26 10:53   ` Damien Wyart
@ 2013-11-26 13:40   ` Stefan Monnier
       [not found]   ` <mailman.7164.1385473254.10748.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 9+ messages in thread
From: Stefan Monnier @ 2013-11-26 13:40 UTC (permalink / raw)
  To: help-gnu-emacs

> (add-hook 'c-mode-common-hook
>           '(lambda ()
>            (setq comment-end "\n*/")))

Running for the Useless Use of Quote Award?


        Stefan




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

* Re: M-; and M-j and c-comment alignment
       [not found]   ` <mailman.7164.1385473254.10748.help-gnu-emacs@gnu.org>
@ 2013-11-26 14:43     ` Damien Wyart
  0 siblings, 0 replies; 9+ messages in thread
From: Damien Wyart @ 2013-11-26 14:43 UTC (permalink / raw)
  To: help-gnu-emacs

* Stefan Monnier <monnier@iro.umontreal.ca> in gnu.emacs.help:
> Running for the Useless Use of Quote Award?

Did I win the award for this week? :)

Kidding aside, you are right, I'd better cleanup some old snippets
I have in my startup files...

-- 
DW


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

* Re: M-; and M-j and c-comment alignment
  2013-11-26 13:07       ` Damien Wyart
@ 2013-11-27  7:16         ` Luca Ferrari
       [not found]         ` <mailman.7230.1385536609.10748.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 9+ messages in thread
From: Luca Ferrari @ 2013-11-27  7:16 UTC (permalink / raw)
  To: Damien Wyart; +Cc: help-gnu-emacs

On Tue, Nov 26, 2013 at 2:07 PM, Damien Wyart <damien.wyart@free.fr> wrote:
> * Luca Ferrari <fluca1978@infinito.it> in gnu.emacs.help:
>> > > Does setting comment-end to "\n*/" for C/C++ mode answers the question ?
>
> What about this proposal? Does it work for you?
>

Not exactly. The above provides me always a comment like:
/*
 */

while I want this to be a comment like that in multi line comments
only, that is I want to have a single line comment that can be
translated into a multiline one. In other words:
M-; ==> /* single line comment */
M-; <comment> M-; ==> /*
                                      * multiline comment
                                      */

Is that possible?
Thanks,
Luca



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

* Re: M-; and M-j and c-comment alignment
       [not found]         ` <mailman.7230.1385536609.10748.help-gnu-emacs@gnu.org>
@ 2013-11-27  7:31           ` Damien Wyart
  0 siblings, 0 replies; 9+ messages in thread
From: Damien Wyart @ 2013-11-27  7:31 UTC (permalink / raw)
  To: help-gnu-emacs

* Luca Ferrari <fluca1978@infinito.it> in gnu.emacs.help:
> In other words:
> M-; ==> /* single line comment */
> M-; <comment> M-; ==> /*
>                        * multiline comment
>                        */

> Is that possible?

"Natively" (through simple configuration), I don't think so.

With some custom elisp code, I guess yes (everything is possible in
elisp :) but I do not have time right now to think about it.

-- 
DW


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

end of thread, other threads:[~2013-11-27  7:31 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.7147.1385457886.10748.help-gnu-emacs@gnu.org>
2013-11-26 10:52 ` M-; and M-j and c-comment alignment Damien Wyart
2013-11-26 10:53   ` Damien Wyart
2013-11-26 12:52     ` Luca Ferrari
     [not found]     ` <mailman.7160.1385470332.10748.help-gnu-emacs@gnu.org>
2013-11-26 13:07       ` Damien Wyart
2013-11-27  7:16         ` Luca Ferrari
     [not found]         ` <mailman.7230.1385536609.10748.help-gnu-emacs@gnu.org>
2013-11-27  7:31           ` Damien Wyart
2013-11-26 13:40   ` Stefan Monnier
     [not found]   ` <mailman.7164.1385473254.10748.help-gnu-emacs@gnu.org>
2013-11-26 14:43     ` Damien Wyart
2013-11-26  9:24 Luca Ferrari

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