On Sun, Jan 17, 2010 at 6:37 AM, Dirk-Jan C. Binnema
<address@hidden> wrote:
Hi,
>>>>> "alin" == alin s <address@hidden> 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:address@hidden w:www.djcbsoftware.nl
pgp: D09C E664 897D 7D39 5047 A178 E96A C7A1 017D DA3C