Subject: Re: bug#64185: proposal for new function: copy-line

From: Mattias Engdegård <[email-masked]>
Date: Tue, 27 Jun 2023 17:35:43 +0200

26 juni 2023 kl. 19.37 skrev Juri Linkov <[email-masked]>:

> I remember already the need of doing this several times: to create
> initial content for testing first I select one line then duplicate
> its region, then select the whole buffer and duplicate it again
> and so on, so the duplicated region grows exponentially.

Yes, but there is no reason to do that now. Just use duplicate-dwim (or duplicate-line).
Both benefit a lot from immediate repeatability.

> `duplicate-dwim-final-column` should be applied to both cases?
> To rectangular regions and to lines?  In case of lines it could
> define whether to keep the original column, or move to the
> beginning of the line, or to the end of the line?

No, I meant the same as you were proposing for lines: whether to insert copies before or after the original (or where point and the region should be afterwards, but that's pretty much the same thing as long as we preserve window-start, as you correctly pointed out).

> Then I think `duplicate-dwim` is a misnomer, and it was misdesigned.
> A proper name that matches the design of `thing-at-point`, would be
> `duplicate-thing`.  thingatpt.el contains the definition of the region
> among many other things that are candidates for duplication.

That is a very different operation. `duplicate-dwim` acts on a buffer area designated by the user regardless of its content. The 'thing' functions (there seem to be no commands) parse buffer contents to derive a value or extent.

I don't like the 'dwim' name part either but it has some precedence. A single function should suffice but since this is Emacs, we have two of them for historical reasons before anything is even released.