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

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

bug#46621: Copy line


From: Drew Adams
Subject: bug#46621: Copy line
Date: Wed, 22 Jun 2022 14:10:30 +0000

> Now I realized what's actually missing is a command `mark-line'.

About a decade ago I added command `mark-line' to my
ad hoc library `misc-cmds.el', with this comment:

  ;; Probably not very useful.

And yeah, IMO it's not very useful (for me, at least).

> After marking the line it could move point to the
> beginning of the next line.

FWIW, my version moves to the end of the marked line.
IOW, it marks only the line, not its trailing newline.

(defun mark-line (&optional arg)
  "Put mark at end of line, point at beginning.
A numeric prefix arg means move forward (backward if negative) that
many lines, thus marking a line other than the one point was
originally in."
  (interactive "P")
  (setq arg  (if arg (prefix-numeric-value arg) 0))
  (let ((inhibit-field-motion  t))
    (forward-line arg)
    (push-mark nil t t)
    (goto-char (line-end-position))))

> Then the key sequence would be `mark-line M-w C-y'.  And the case of
> a missing trai[l]ing newline is very rare, so an extra RET is not a
> problem.
> 
> > I.e., `duplicate-line' offers both a practical and
> > mental simplification over what we have today,

Bof.

> > but making that command do region stuff doesn't
> > really give anything except muddling up the command semantics.
> 
> The above suggestion is just an alternative way to do the same.
> 
> BTW, what do you think about the already suggested leaving point
> at the end of duplicated lines?  This means removing save-excursion
> and adding backward-char to the end of `duplicate-line' to move point
> before the last newline.

IMO, it's fine to add any commands you like,
whatever their general use(ful|less)ness.

But please don't succumb to giving them key
bindings just because some new contributor
requested them.  Even if you feel you want
to encourage new participants, that's not
appropriate.  (My impression is that this is
in fact sometimes a thing with Emacs dev.)

Emacs has gotten along quite well for a very
long time without feeling the crying need
for a `duplicate-line', a `copy-line' or a
`mark-line' command.  Maybe ask yourself why.

Just imagine that some such request doesn't
come from a new contributor - treat it as
you would from a longtime participant.





reply via email to

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