[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 85335157dd4: Speed up duplicate-dwim and duplicate-line by anothe
From: |
Mattias Engdegård |
Subject: |
master 85335157dd4: Speed up duplicate-dwim and duplicate-line by another factor 10 |
Date: |
Wed, 28 Jun 2023 09:16:57 -0400 (EDT) |
branch: master
commit 85335157dd4a8bf6a0c92525360ec35362750c30
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>
Speed up duplicate-dwim and duplicate-line by another factor 10
* lisp/misc.el (duplicate--insert-copies): New.
(duplicate-line, duplicate-dwim): Call it.
---
lisp/misc.el | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/lisp/misc.el b/lisp/misc.el
index de82b97fa6f..ab083728a69 100644
--- a/lisp/misc.el
+++ b/lisp/misc.el
@@ -63,6 +63,10 @@ Also see the `duplicate-line' command."
(+ n (point)))))))
(insert string)))
+(defun duplicate--insert-copies (n string)
+ "Insert N copies of STRING at point."
+ (insert (mapconcat #'identity (make-list n string))))
+
;;;###autoload
(defun duplicate-line (&optional n)
"Duplicate the current line N times.
@@ -78,8 +82,7 @@ Also see the `copy-from-above-command' command."
(forward-line 1)
(unless (bolp)
(insert "\n"))
- (dotimes (_ n)
- (insert line)))))
+ (duplicate--insert-copies n line))))
(declare-function rectangle--duplicate-right "rect" (n))
@@ -111,8 +114,7 @@ Interactively, N is the prefix numeric argument, and
defaults to 1."
(text (buffer-substring beg end)))
(save-excursion
(goto-char end)
- (dotimes (_ n)
- (insert text))))
+ (duplicate--insert-copies n text)))
(setq deactivate-mark nil))
;; Duplicate line.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 85335157dd4: Speed up duplicate-dwim and duplicate-line by another factor 10,
Mattias Engdegård <=