bug-gnu-emacs
[Top][All Lists]
Advanced

[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: Thu, 18 Feb 2021 21:07:05 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu)

Why there is still no such fundamental command as duplicating the current
line?  This command slightly extends the existing copy-from-above-command:
diff --git a/lisp/misc.el b/lisp/misc.el
index 09f6011f98..b3b7d8355f 100644
--- a/lisp/misc.el
+++ b/lisp/misc.el
@@ -61,6 +61,16 @@ copy-from-above-command
                                 (+ n (point)))))))
     (insert string)))
 
+;;;###autoload
+(defun copy-line (&optional arg)
+  "Duplicate the current line ARG times."
+  (interactive "p")
+  (dotimes (_ arg)
+    (forward-line 1)
+    (insert "\n")
+    (forward-line -1)
+    (copy-from-above-command)))
+
 ;; Variation of `zap-to-char'.
 
 ;;;###autoload

reply via email to

[Prev in Thread] Current Thread [Next in Thread]