unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Visuwesh <visuweshm@gmail.com>
To: emacs-devel@gnu.org
Cc: Lars Ingebrigtsen <larsi@gnus.org>
Subject: Re: master 6362f65474: Add new command `duplicate-line'
Date: Fri, 17 Jun 2022 23:14:14 +0530	[thread overview]
Message-ID: <87ilozrxqp.fsf@gmail.com> (raw)
In-Reply-To: <20220617173432.17B6FC00BAF@vcs2.savannah.gnu.org> (Lars Ingebrigtsen's message of "Fri, 17 Jun 2022 13:34:31 -0400 (EDT)")

[வெள்ளி ஜூன் 17, 2022 13:34] Lars Ingebrigtsen wrote:

> branch: master
> commit 6362f65474bad81c1d57b9b603c65686a0dd853e
> Author: Lars Ingebrigtsen <larsi@gnus.org>
> Commit: Lars Ingebrigtsen <larsi@gnus.org>
>
>     Add new command `duplicate-line'
>     
>     * lisp/misc.el (copy-from-above-command): Mention it.
>     (duplicate-line): New command (bug#46621).
> ---
>  etc/NEWS     |  4 ++++
>  lisp/misc.el | 17 ++++++++++++++++-
>  2 files changed, 20 insertions(+), 1 deletion(-)
>
> diff --git a/etc/NEWS b/etc/NEWS
> index 3b9515c2d4..d27c18f4ec 100644
> --- a/etc/NEWS
> +++ b/etc/NEWS
> @@ -298,6 +298,10 @@ startup.  Previously, these functions ignored
>  \f
>  * Changes in Emacs 29.1
>  
> +---
> +** New command 'duplicate-line'.
> +This command duplicates the current line the specified number of times.
> +
>  ---
>  ** Files with the '.eld' extension are now visited in 'lisp-data-mode'.
>  
> diff --git a/lisp/misc.el b/lisp/misc.el
> index 0bb8ee6c7b..88932681c1 100644
> --- a/lisp/misc.el
> +++ b/lisp/misc.el
> @@ -33,7 +33,9 @@
>    "Copy characters from previous nonblank line, starting just above point.
>  Copy ARG characters, but not past the end of that line.
>  If no argument given, copy the entire rest of the line.
> -The characters copied are inserted in the buffer before point."
> +The characters copied are inserted in the buffer before point.
> +
> +Also see the `copy-line' command."

Shouldn't this be `duplicate-line'?

>    (interactive "P")
>    (let ((cc (current-column))
>  	n
> @@ -61,6 +63,19 @@ The characters copied are inserted in the buffer before point."
>  				 (+ n (point)))))))
>      (insert string)))
>  
> +;;;###autoload
> +(defun duplicate-line (&optional n)
> +  "Duplicate the current line N times.
> +Also see the `copy-from-above-command' command."
> +  (interactive "p")
> +  (let ((line (buffer-substring (line-beginning-position) (line-end-position))))
> +    (save-excursion
> +      (forward-line 1)
> +      (unless (bolp)
> +        (insert "\n"))
> +      (dotimes (_ n)
> +        (insert line "\n")))))
> +
>  ;; Variation of `zap-to-char'.
>  
>  ;;;###autoload



       reply	other threads:[~2022-06-17 17:44 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <165548727183.24473.6170306052807994962@vcs2.savannah.gnu.org>
     [not found] ` <20220617173432.17B6FC00BAF@vcs2.savannah.gnu.org>
2022-06-17 17:44   ` Visuwesh [this message]
2022-06-17 17:47     ` master 6362f65474: Add new command `duplicate-line' Lars Ingebrigtsen
2022-06-18 16:30     ` Ergus
2022-06-18 16:52       ` Eli Zaretskii
2022-06-18 22:22         ` Ergus
2022-06-19  5:55           ` Eli Zaretskii
2022-06-19 11:55           ` Andreas Schwab
2022-06-19 11:06       ` Lars Ingebrigtsen
2022-06-19 17:10         ` [External] : " Drew Adams
2022-06-19  5:53 Pedro Andres Aranda Gutierrez

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ilozrxqp.fsf@gmail.com \
    --to=visuweshm@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=larsi@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).