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: David Hansen
Subject: Re: Add functions to C-mode?
Date: Sat, 19 Apr 2008 19:16:50 +0200
User-agent: Gnus/5.110009 (No Gnus v0.9) Emacs/23.0.60 (gnu/linux)

On Sat, 19 Apr 2008 13:04:06 +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.
>
> I would like to change the function to just insert // even though some
> text might not be selected.
>
> Is that possible?

M-; should do just that.  Well in c-mode it will insert /* */ if no
region is selected and will wrap the comment delimiters if the region is
active.

If you insist on "//" (which is btw not ANSI C) you have to play around
a bit with the `comment-start' and `comment-end' variables.  Not tested:

(defun cxx-comments ()
  (set (make-local-variable comment-start) "// ")
  (set (make-local-variable comment-end "")))

(add-hook c-mode-hook #'cxx-comments)

David





reply via email to

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