all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ergus <spacibba@aol.com>
To: emacs-devel@gnu.org, Lars Ingebrigtsen <larsi@gnus.org>
Subject: Re: master 6362f65474: Add new command `duplicate-line'
Date: Sat, 18 Jun 2022 18:30:43 +0200	[thread overview]
Message-ID: <20220618163043.g4r2a5inkldmwjue@Ergus> (raw)
In-Reply-To: <87ilozrxqp.fsf@gmail.com>

Hi:

I saw this command and I would like to make some suggestions very simple
to implement, but that provides some consistency and improve user
interaction.

1) Could we consider to move the cursor when duplicate-line based on
prefix value?  This may be useful to bind the command giving a more
intuitive behavior. For example: USERPREFIX-<up> and USERPREFIX-<down>.

Actually the current command `duplicate-line' is what I expect for
USERPREFIX-<up>, which "emulates" like "we have duplicated before or
up".

Many packages around try to implement such commands because they are
available y sublime ad VS-Code... for example:
https://github.com/wyuenho/move-dup/blob/master/move-dup.el

2) From the same package may we consider a command "move-line", which in
the same fashion the user could bind to move the current line up/down?

3) Could we provide a consistent alternative to all mark-? commands?
Because mark-work selects from the current position to the end of the
work, but mark-sexp or mark-paragraph marks the whole current
sexp/paragraph... moving the cursor to the beginning maybe as mark-word
is a current a long standing command we may provide an alternative like
mark-current-word or similes...

The idea behind this is to provide a more consistent API that avoids to
wrap all per-case commands like transpose-word could have bother like
duplicate-work with just a few lines.

4) Could we provide a mark-line command to complete the family of
mark-something commands? Actually all this could rely on thing-at-point
api right?

Best,
Ergus

On Fri, Jun 17, 2022 at 11:14:14PM +0530, Visuwesh wrote:
>[வெள்ளி ஜூன் 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
>>
>>  * 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
>



  parent reply	other threads:[~2022-06-18 16:30 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   ` master 6362f65474: Add new command `duplicate-line' Visuwesh
2022-06-17 17:47     ` Lars Ingebrigtsen
2022-06-18 16:30     ` Ergus [this message]
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

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

  git send-email \
    --in-reply-to=20220618163043.g4r2a5inkldmwjue@Ergus \
    --to=spacibba@aol.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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.