From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.help Subject: Re: Add functions to C-mode? Date: Sun, 20 Apr 2008 12:01:15 +0000 Message-ID: <20080420120115.GB1133@muc.de> 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 1208691837 12218 80.91.229.12 (20 Apr 2008 11:43:57 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 20 Apr 2008 11:43:57 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: saneman Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Apr 20 13:44:31 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 1JnXy9-0007En-Hg for geh-help-gnu-emacs@m.gmane.org; Sun, 20 Apr 2008 13:44:29 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JnXxU-0004ih-9h for geh-help-gnu-emacs@m.gmane.org; Sun, 20 Apr 2008 07:43:48 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JnXxB-0004i5-8U for help-gnu-emacs@gnu.org; Sun, 20 Apr 2008 07:43:29 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JnXxA-0004hn-Q5 for help-gnu-emacs@gnu.org; Sun, 20 Apr 2008 07:43:29 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JnXxA-0004hj-Kq for help-gnu-emacs@gnu.org; Sun, 20 Apr 2008 07:43:28 -0400 Original-Received: from colin.muc.de ([193.149.48.1] helo=mail.muc.de) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JnXxA-0005Tc-8p for help-gnu-emacs@gnu.org; Sun, 20 Apr 2008 07:43:28 -0400 Original-Received: (qmail 48843 invoked by uid 3782); 20 Apr 2008 11:43:26 -0000 Original-Received: from acm.muc.de (p57AF70DF.dip.t-dialin.net [87.175.112.223]) by colin2.muc.de (tmda-ofmipd) with ESMTP; Sun, 20 Apr 2008 13:43:24 +0200 Original-Received: (qmail 1789 invoked by uid 1000); 20 Apr 2008 12:01:15 -0000 Content-Disposition: inline In-Reply-To: <4809d165$0$90270$14726298@news.sunsite.dk> User-Agent: Mutt/1.5.9i X-Delivery-Agent: TMDA/1.1.5 (Fettercairn) X-Primary-Address: acm@muc.de X-detected-kernel: by monty-python.gnu.org: FreeBSD 4.6-4.9 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:53414 Archived-At: 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) > Is that possible? Hey, what sort of a question is that? This is Emacs. :-) -- Alan Mackenzie (Nuremberg, Germany).