Subject: bug#72862: 29.1; Strange interaction between append-next-kill and kill-whole-line

From: Eli Zaretskii <[email-masked]>
Date: Sun, 08 Sep 2024 09:56:51 +0300

> Cc: [email-masked]
> Date: Thu, 29 Aug 2024 07:53:52 +0300
> From: Eli Zaretskii <[email-masked]>
> 
> > From: Sean McAfee <[email-masked]>
> > Date: Wed, 28 Aug 2024 14:12:11 -0700
> > 
> > Starting from emacs -Q:
> > 
> > - Enter the text "12345\n" in the scratch buffer.
> > - Kill the text by any means, eg: C-SPC C-p C-w
> > - Enter the text "ABCDE" and put point on the C.
> > - Run append-next-kill with C-M-w and then kill-whole-line with C-S-<backspace>.
> > - Yank the most recent kill with C-y.
> > 
> > The text I get back is "AB12345\nCDE".  Apparently the killed whole line
> > is being wrapped around the preceding kill, at the place where point
> > was, rather than being appended to it.
> 
> Yes, because kill-whole-line kills the line in two parts.  The
> commentary to the code there says:
> 
>   ;; - We need to kill in two steps, because the previous command
>   ;;   could have been a kill command, in which case the text before
>   ;;   point needs to be prepended to the current kill ring entry and
>   ;;   the text after point appended.
> 
> Perhaps what the code there does needs to be augmented for the case of
> append-next-kill.

After reading the documentation of append-next-kill, I think I'm
changing my mind on this.  The doc string of append-next-kill says:

  (append-next-kill &optional INTERACTIVE)

  Cause following command, if it kills, to add to previous kill.
  If the next command kills forward from point, the kill is
  appended to the previous killed text.  If the command kills
  backward, the kill is prepended.

Since kill-whole-line kills both backward and forward from point, it
seems we should expect that the first part is prepended to previous
kill, whereas the second part is appended.  Which is what the command
already does.

WDYT?