[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#46621: Copy line
From: |
Juri Linkov |
Subject: |
bug#46621: Copy line |
Date: |
Wed, 06 Jul 2022 20:34:19 +0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) |
>> duplicate-line should keep point at the same column.
>
> Ah, yes, that might be nice...
Here is the patch that does this. So if you have
foo 1 bar
and need to get
foo 1 bar
foo 2 bar
foo 3 bar
foo 4 bar
foo 5 bar
it requires typing the minimal number of keys -
move point to the column with 1, and type:
C-u <copy-line> 2 <down> 3 <down> 4 <down> 5 <down>
```
diff --git a/lisp/misc.el b/lisp/misc.el
index 28c5d6e07f..57cf8c59ed 100644
--- a/lisp/misc.el
+++ b/lisp/misc.el
@@ -71,13 +71,15 @@ duplicate-line
(interactive "p")
(unless n
(setq n 1))
- (let ((line (buffer-substring (line-beginning-position)
(line-end-position))))
+ (let ((line (buffer-substring (line-beginning-position) (line-end-position)))
+ (column (current-column)))
+ (forward-line 1)
+ (unless (bolp)
+ (insert "\n"))
(save-excursion
- (forward-line 1)
- (unless (bolp)
- (insert "\n"))
(dotimes (_ n)
- (insert line "\n")))))
+ (insert line "\n")))
+ (move-to-column column)))
;; Variation of `zap-to-char'.
```
- bug#46621: Copy line, Lars Ingebrigtsen, 2022/07/01
- bug#46621: Copy line,
Juri Linkov <=
- bug#46621: Copy line, Lars Ingebrigtsen, 2022/07/07
- bug#46621: Copy line, Juri Linkov, 2022/07/07
- bug#46621: Copy line, Lars Ingebrigtsen, 2022/07/07
- bug#46621: Copy line, Juri Linkov, 2022/07/07
- bug#46621: Copy line, Lars Ingebrigtsen, 2022/07/07
- bug#46621: Copy line, Juri Linkov, 2022/07/08
- bug#46621: Copy line, Lars Ingebrigtsen, 2022/07/10
- bug#46621: Copy line, Juri Linkov, 2022/07/14
- bug#46621: Copy line, Andreas Schwab, 2022/07/14
- bug#46621: Copy line, Juri Linkov, 2022/07/14