From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dirk-Jan C. Binnema Newsgroups: gmane.emacs.devel Subject: Re: keybinding to duplicate the current line. Date: Sun, 17 Jan 2010 16:31:45 +0200 Organization: DJCBSoftware Message-ID: <87hbqkx0oe.wl%djcb@djcbsoftware.nl> References: <27198868.post@talk.nabble.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII X-Trace: ger.gmane.org 1263742493 5939 80.91.229.12 (17 Jan 2010 15:34:53 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 17 Jan 2010 15:34:53 +0000 (UTC) Cc: Emacs-devel@gnu.org To: "alin.s" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jan 17 16:34:45 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1NWX9I-0007rF-FF for ged-emacs-devel@m.gmane.org; Sun, 17 Jan 2010 16:34:44 +0100 Original-Received: from localhost ([127.0.0.1]:49627 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NWX9J-0007HY-Ce for ged-emacs-devel@m.gmane.org; Sun, 17 Jan 2010 10:34:45 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NWWAc-0004kU-VN for emacs-devel@gnu.org; Sun, 17 Jan 2010 09:32:03 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NWWAY-0004jF-Oq for Emacs-devel@gnu.org; Sun, 17 Jan 2010 09:32:02 -0500 Original-Received: from [199.232.76.173] (port=56253 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NWWAY-0004jA-Jo for Emacs-devel@gnu.org; Sun, 17 Jan 2010 09:31:58 -0500 Original-Received: from gw01.mail.saunalahti.fi ([195.197.172.115]:36495) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NWWAX-0007Tz-VX for Emacs-devel@gnu.org; Sun, 17 Jan 2010 09:31:58 -0500 Original-Received: from djcbsoftware.nl (a88-114-93-212.elisa-laajakaista.fi [88.114.93.212]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by gw01.mail.saunalahti.fi (Postfix) with ESMTP id 8A2BE1515DE; Sun, 17 Jan 2010 16:31:48 +0200 (EET) Original-Received: from cthulhu.mindcrime.djcbsoftware.nl (localhost [127.0.0.1]) by djcbsoftware.nl (Postfix) with ESMTP id 552E839C1CD; Sun, 17 Jan 2010 16:31:45 +0200 (EET) In-Reply-To: <27198868.post@talk.nabble.com> Mail-Reply-To: djcb@djcbsoftware.nl User-Agent: Wanderlust/2.15.6 (Almost Unreal) Emacs/23.1 Mule/6.0 (HANACHIRUSATO) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Mailman-Approved-At: Sun, 17 Jan 2010 10:33:10 -0500 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:120157 Archived-At: Hi, >>>>> "alin" == alin s writes: alin> For me it would be very convenient to have a key-binding to duplicate the alin> current line. alin> In order to duplicate it I have to press alin> C-a C-SPACE C-e C-f M-w C-g C-y alin> It's too much for an usual function. C-x C-a would be good? I like 'slick copy', ie., copy without needing to select: http://emacs-fu.blogspot.com/2009/11/copying-lines-without-selecting-them.html Then, you can duplicate lines with: M-w C-y Which is very natural. alin> More than that, if I press C-u C-x C-a, I wish to duplicate the current alin> line, and to comment the old line. alin> Do you consider that such a function would be useful for many of you? alin> Otherwise, I have to wtite it myseld in my own .emacs... Something quick and fairly dirty: (defun comment-and-dup () (interactive) (save-excursion (beginning-of-line) (push-mark) (forward-line 1) (let ((str (buffer-substring (region-beginning) (region-end)))) (comment-region (region-beginning) (region-end)) (next-line) (insert-string str)))) Best wishes, Dirk. -- Dirk-Jan C. Binnema Helsinki, Finland e:djcb@djcbsoftware.nl w:www.djcbsoftware.nl pgp: D09C E664 897D 7D39 5047 A178 E96A C7A1 017D DA3C