Subject: bug#56418: Add duplicate-dwim [PATCH]

From: Richard Stallman <[email-masked]>
Date: Thu, 04 Aug 2022 00:01:25 -0400

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

I've seen no cogent argument against making `duplicate-line' operate
on the region when that is active.  Someone presented this argument,

    Simen proposed something quite similar (added to the CCs), and my only
    objection was that the semantics of the simpler command is quite
    clear -- it always creates a new line, even if we're at a final line in
    a buffer without a newline.  When dealing with regions, it's not quite
    clear what the semantics should be in those corner cases (i.e., regions
    that doesn't end with a newline)...

but "duplicate the region" is totally clear, if interpreted strictly:

    Not much of a edge case, is it? If you select "bon" and duplicate you =
    end up with "bonbon", as promised.

The practical question is, which way will people find more convenient
to use?

Making `duplicate-line' region-sensitive would enable people to do both
operations with one key binding.  That is clearly a plus.  Good key
bindings are scarce and they take up space in the mind.

Making `duplicate-line' region-sensitive could lead to surprises when
the region is active, for a user who only ever uses it to duplicate
lines.  That is clearly a minus -- but how big is it in practice?

If we can only spare one binding for this, which behavior should that
binding have?

I suggest we define `duplicate-lines' with an option to control
whether it is region-sensitive, so that people can try it both ways
and tell us which way they like better.  Then we could set the
default for that option accordingly.

-- 
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)