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

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

Re: Add functions to C-mode?


From: saneman
Subject: Re: Add functions to C-mode?
Date: Mon, 21 Apr 2008 09:36:55 +0200
User-agent: Thunderbird 2.0.0.12 (X11/20080227)

Alan Mackenzie wrote:
Hi, Saneman!

On Sat, Apr 19, 2008 at 01:04:06PM +0200, saneman wrote:
I would like to add/change the comment/uncomment function in the C-mode for emacs.

Currently it only works when a piece of text is selected and then /* */
is inserted.

OK, just to check, "it" here means "M-;" (or your newly bound C-d), bound
to `comment-dwim', doesn't it?

I'm not sure about "selected" (I don't use delete-selection-mode and
stuff like that), but the "/* */" style of comments is fixed for C.
Somebody asked some while ago for a way to change this to "//", and I'm
planning to add a command to CC Mode (probably C-c C-;) in the next
release to toggle the commenting style.

I would like to change the function to just insert // even though some text might not be selected.

In the meantime, you could use the following workaround.  M-; (or your
C-d ;-) will then insert "// ".

    (defun sm-do-line-comments ()
      (setq comment-start "// ")
      (setq comment-end ""))
    (add-hook 'c-mode-hook 'sm-do-line-comments)



But I still have to select the lines that I want to comment out. If the cursor is on a line the I would like to comment out and I press C-d the // get inserted and the end of the line.

Only when I select the line and then press C-d it works.

Is there some way to insert // at the start of the line without first selecting it?


reply via email to

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