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)