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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Mattias Engdegård
Subject: bug#64185: proposal for new function: copy-line
Date: Sat, 24 Jun 2023 13:29:36 +0200

23 juni 2023 kl. 18.45 skrev Juri Linkov <juri@linkov.net>:

> It would be a major undertaking to design
> a similar option for `duplicate-dwim` for consistency with `duplicate-line`
> because of more decisions necessary to make: whether to move point
> to the beginning or the end of the copied regions, whether to select
> all the copied regions or only one of them, etc.

Actually we are helped by some constraints: duplicate-dwim must keep the region 
active afterwards, so that the user can run the same command immediately and 
get another copy. This is important for usability.

It seems reasonable to assume that a user wants the same behaviour in 
`duplicate-dwim` whether it is lines or columns being duplicated, and have a 
single variable controlling both. This assumption may be wrong: perhaps a user 
prefers to stay when copying a line, but move when copying columns?

If we use separate settings they should naturally work the same way, or users 
will wonder who is running the asylum.

A perhaps more intuitive way of describing the behaviour is not where to put 
point afterwards, but whether copies are inserted before or after the original. 
That will generalise to duplication of regions, rectangular or contiguous, a 
little better.

It's also easy to describe:

(defcustom duplicate-direction 'after
  "Where to insert the copies made by `duplicate-line' and `duplicate-dwim'.
Valid values are `after' and `before' (the original text).
  :group 'editing
  :type '(choice (const :tag "After original" after)
                 (const :tag "Before original" before)))

What do you think? Should we have a single setting for lines and regions, or 
individual settings for lines and regions, or for lines, rectangles and 
contiguous regions?

> For users who know Emacs Lisp and like to write plain values in ~/.emacs,
> the values 0, 1, -1 are more intuitive and familiar due to functions
> like `substring`, etc.

I suppose I'm one of those who don't know Emacs Lisp then!

> to my surprise the shortdoc of `substring` has no examples
> of a negative argument.  I don't know whether this omission
> is intentional to make the string section shorter.

Thank you for noticing this. I doubt it was intentional.
The examples have now been extended a bit.
I'm sure we could do better with examples in general if we were to make an 
effort.






reply via email to

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