GNU bug report logs - #64185
proposal for new function: copy-line

Previous Next

Package: emacs;

Reported by: Zachary Kanfer <zkanfer <at> gmail.com>

Date: Tue, 20 Jun 2023 05:09:02 UTC

Severity: wishlist

Full log


View this message in rfc822 format

From: Juri Linkov <juri <at> linkov.net>
To: Mattias EngdegÄrd <mattias.engdegard <at> gmail.com>
Cc: 64185 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>, me <at> eshelyaron.com, zkanfer <at> gmail.com
Subject: bug#64185: proposal for new function: copy-line
Date: Fri, 23 Jun 2023 19:45:31 +0300
>>  'duplicate-dwim' duplicates the region if it is active.  If not, it
>>  works like 'duplicate-line'.  An active rectangular region is
>> -duplicated on its right-hand side.
>> +duplicated on its right-hand side.  The new user option
>> +'duplicate-line-final-position' specifies where to move point
>> +after duplicating the line.
>
> This makes it unclear to what extent the variable affects
> `duplicate-dwim`.  (For some reason it only does so when the region is
> inactive, which doesn't seem right.)

The new command `duplicate-line` would be useless for many users
without that option.  There is no such problem for `duplicate-dwim`
that is more complicated.  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.

> And I agree that allowing any integer as value isn't necessary the
> best choice here.  It's a false flexibility; nobody will ever set it
> to something other than 0, 1 or -1.  Symbols would probably be better,
> for several reasons.

For users of the Customization UI the choices are explained clearly:

  :type '(choice (const :tag "Leave point on old line" 0)
                 (const :tag "Move point to first new line" 1)
                 (const :tag "Move point to last new line" -1)
                 (integer))

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.

BTW, 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.




This bug report was last modified 1 year and 286 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.