[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: keybinding to duplicate the current line.
From: |
Dirk-Jan C . Binnema |
Subject: |
Re: keybinding to duplicate the current line. |
Date: |
Sun, 17 Jan 2010 16:52:32 +0200 |
User-agent: |
Wanderlust/2.15.6 (Almost Unreal) Emacs/23.1 Mule/6.0 (HANACHIRUSATO) |
>>>>> Dirk-Jan C Binnema <address@hidden> writes:
> Hi,
>>>>> "alin" == alin s <address@hidden> writes:
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:
<snip>
That was a bit *too* quick and dirty, this works better:
(defun comment-and-dup ()
"duplicate line at point, and comment the current one"
(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))
(insert-string str)))
(next-line))
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
- keybinding to duplicate the current line., alin.s, 2010/01/17
- Re: keybinding to duplicate the current line., Deniz Dogan, 2010/01/17
- Re: keybinding to duplicate the current line., Daniel Colascione, 2010/01/17
- Re: keybinding to duplicate the current line., Dirk-Jan C . Binnema, 2010/01/17
- Re: keybinding to duplicate the current line., Helmut Eller, 2010/01/17
- Re: keybinding to duplicate the current line., Teemu Likonen, 2010/01/17
- Re: keybinding to duplicate the current line., Lennart Borgman, 2010/01/17
- Re: keybinding to duplicate the current line., Ken Hori, 2010/01/17
- Re: keybinding to duplicate the current line., Deniz Dogan, 2010/01/17
- Re: keybinding to duplicate the current line., Ken Hori, 2010/01/17
- Re: keybinding to duplicate the current line., Deniz Dogan, 2010/01/17
- Re: keybinding to duplicate the current line., Chong Yidong, 2010/01/17
- Re: keybinding to duplicate the current line., Ken Hori, 2010/01/17
- Re: keybinding to duplicate the current line., Lennart Borgman, 2010/01/17