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:37:19 +0200 Organization: DJCBSoftware Message-ID: <87fx64x0f4.wl%djcb@djcbsoftware.nl> References: <27198868.post@talk.nabble.com> Reply-To: djcb@djcbsoftware.nl 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 1263739080 27906 80.91.229.12 (17 Jan 2010 14:38:00 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 17 Jan 2010 14:38:00 +0000 (UTC) To: Emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jan 17 15:37:53 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 1NWWGG-0004A1-9w for ged-emacs-devel@m.gmane.org; Sun, 17 Jan 2010 15:37:52 +0100 Original-Received: from localhost ([127.0.0.1]:36380 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NWWGH-0007Kb-8T for ged-emacs-devel@m.gmane.org; Sun, 17 Jan 2010 09:37:53 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NWWFu-000790-VB for emacs-devel@gnu.org; Sun, 17 Jan 2010 09:37:31 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NWWFq-00076F-DG for Emacs-devel@gnu.org; Sun, 17 Jan 2010 09:37:30 -0500 Original-Received: from [199.232.76.173] (port=41678 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NWWFq-000765-3F for Emacs-devel@gnu.org; Sun, 17 Jan 2010 09:37:26 -0500 Original-Received: from gw01.mail.saunalahti.fi ([195.197.172.115]:36933) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NWWFp-0002bj-HD for Emacs-devel@gnu.org; Sun, 17 Jan 2010 09:37:25 -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 E1D131514DC for ; Sun, 17 Jan 2010 16:37:22 +0200 (EET) Original-Received: from cthulhu.mindcrime.djcbsoftware.nl (localhost [127.0.0.1]) by djcbsoftware.nl (Postfix) with ESMTP id AA32339C1CD for ; Sun, 17 Jan 2010 16:37:19 +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-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:120145 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