From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: saneman Newsgroups: gmane.emacs.help Subject: Re: Add functions to C-mode? Date: Mon, 21 Apr 2008 09:36:55 +0200 Organization: SunSITE.dk - Supporting Open source Message-ID: <480c43d0$0$90272$14726298@news.sunsite.dk> References: <4809d165$0$90270$14726298@news.sunsite.dk> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1208763729 8712 80.91.229.12 (21 Apr 2008 07:42:09 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 21 Apr 2008 07:42:09 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Apr 21 09:42:41 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 1Jnqfe-0003bw-FA for geh-help-gnu-emacs@m.gmane.org; Mon, 21 Apr 2008 09:42:38 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Jnqez-0006UX-7m for geh-help-gnu-emacs@m.gmane.org; Mon, 21 Apr 2008 03:41:57 -0400 Original-Path: shelby.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!news.glorb.com!dotsrc.org!filter.dotsrc.org!news.dotsrc.org!not-for-mail User-Agent: Thunderbird 2.0.0.12 (X11/20080227) Original-Newsgroups: gnu.emacs.help In-Reply-To: Original-Lines: 40 Original-NNTP-Posting-Host: 130.225.245.182 Original-X-Trace: news.sunsite.dk DXC=P]RB`Sm4C\ 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:53442 Archived-At: 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?