From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Hansen Newsgroups: gmane.emacs.help Subject: Re: Add functions to C-mode? Date: Sat, 19 Apr 2008 19:16:50 +0200 Organization: disorganized Message-ID: <87k5ithiil.fsf@localhorst.mine.nu> References: <4809d165$0$90270$14726298@news.sunsite.dk> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1208627825 20056 80.91.229.12 (19 Apr 2008 17:57:05 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 19 Apr 2008 17:57:05 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Apr 19 19:57:39 2008 connect(): Connection refused Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1JnGpB-0007So-F3 for geh-help-gnu-emacs@m.gmane.org; Sat, 19 Apr 2008 19:26:05 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JnGoW-0005w0-Cm for geh-help-gnu-emacs@m.gmane.org; Sat, 19 Apr 2008 13:25:24 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JnGoG-0005vv-7s for help-gnu-emacs@gnu.org; Sat, 19 Apr 2008 13:25:08 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JnGoE-0005vj-Tp for help-gnu-emacs@gnu.org; Sat, 19 Apr 2008 13:25:07 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JnGoE-0005vg-O9 for help-gnu-emacs@gnu.org; Sat, 19 Apr 2008 13:25:06 -0400 Original-Received: from main.gmane.org ([80.91.229.2] helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JnGoD-0001KR-Gs for help-gnu-emacs@gnu.org; Sat, 19 Apr 2008 13:25:06 -0400 Original-Received: from root by ciao.gmane.org with local (Exim 4.43) id 1JnGoA-0000zy-N8 for help-gnu-emacs@gnu.org; Sat, 19 Apr 2008 17:25:02 +0000 Original-Received: from e178021005.adsl.alicedsl.de ([85.178.21.5]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 19 Apr 2008 17:25:02 +0000 Original-Received: from david.hansen by e178021005.adsl.alicedsl.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 19 Apr 2008 17:25:02 +0000 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: help-gnu-emacs@gnu.org Original-Lines: 27 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: e178021005.adsl.alicedsl.de Mail-Copies-To: nobody User-Agent: Gnus/5.110009 (No Gnus v0.9) Emacs/23.0.60 (gnu/linux) Cancel-Lock: sha1:RM0XzLesADZD8qq4NUUh9SStOOw= X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:53405 Archived-At: 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