Subject: Re: bug#79197: [PATCH] ; * lisp/simple.el (yank): Update docstring., Re: bug#79197: [PATCH] ; * lisp/simple.el (yank): Update docstring., Re: bug#79197: [PATCH] ; * lisp/simple.el (yank): Update docstring.

From: James Thomas <[email-masked]>
Date: Fri, 15 Aug 2025 01:55:28 +0530

James Thomas <> writes:

> Eli Zaretskii <[email-masked]> writes:
>
>>> From: James Thomas <>
>>> Cc: [email-masked],  [email-masked]
>>> Date: Mon, 11 Aug 2025 18:37:38 +0530
>>> 
>>> Eli Zaretskii <[email-masked]> writes:
>>> 
>>> > OK, so given these observations, how do you propose to continue?  Do
>>> > you have a patch to propose, either for the doc string or for the code
>>> > or both? if so, please show the patch, and let's take it from there.
>>> 
>>> 
>>> diff --git a/lisp/simple.el b/lisp/simple.el
>>> index cd13e0a55f4..97701ead69d 100644
>>> --- a/lisp/simple.el
>>> +++ b/lisp/simple.el
>>> @@ -5758,9 +5758,10 @@ kill-new
>>>  	  (setcar kill-ring string)
>>>          (let ((history-delete-duplicates nil))
>>>            (add-to-history 'kill-ring string kill-ring-max t))))
>>> -    (setq kill-ring-yank-pointer kill-ring)
>>> +    (prog1
>>> +        (setq kill-ring-yank-pointer kill-ring)
>>>      (if interprogram-cut-function
>>> -        (funcall interprogram-cut-function string))))
>>> +        (funcall interprogram-cut-function string)))))
>>
>> Why do we need this hunk?
>
> For the correct return value?

Mea culpa:

From 0409140aee3cfe42fac33e924da4a0a0233aae55 Mon Sep 17 00:00:00 2001
From: James Thomas <[email-masked]>
Date: Fri, 15 Aug 2025 01:28:53 +0530
Subject: [PATCH] Bugfix#79197 yank does not insert earliest kill consistently

* lisp/simple.el (yank): Make the change and update docstring.
---
 lisp/simple.el | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lisp/simple.el b/lisp/simple.el
index f7f059793ca..d823aa5badb 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -6354,6 +6354,9 @@ yank
 at beginning, and mark at end.
 With argument N, reinsert the Nth most recent kill.
 
+With the negative prefix argument, reinsert the earliest kill
+available.
+
 This command honors the `yank-handled-properties' and
 `yank-excluded-properties' variables, and the `yank-handler' text
 property, as described below.
@@ -6397,7 +6400,7 @@ yank
   (push-mark)
   (insert-for-yank (current-kill (cond
 				  ((listp arg) 0)
-				  ((eq arg '-) -2)
+				  ((eq arg '-) (1- (length kill-ring-yank-pointer)))
 				  (t (1- arg)))))
   (if (consp arg)
       ;; This is like exchange-point-and-mark, but doesn't activate the mark.
-- 
2.50.0

>
>>
>>>  ;; It has been argued that this should work like `self-insert-command'
>>>  ;; which merges insertions in `buffer-undo-list' in groups of 20
>>> @@ -6399,7 +6400,8 @@ yank
>>>    (push-mark)
>>>    (insert-for-yank (current-kill (cond
>>>  				  ((listp arg) 0)
>>> -				  ((eq arg '-) -1)
>>> +				  ((eq arg '-) (- (length kill-ring)
>>> +                                                  (length kill-ring-yank-pointer)))
>>>  				  (t (1- arg)))))
>>
>> So, once again "C-u -" and "C-u - 1" will produce different results?
>>
>> And what about documenting the effect of a negative arg?
>>
>> Thanks.
>
> It was final only for yesterday. :D
>
> A docstring update that turned out to be a bugfix for a faeture that
> wasn't:
>
>
>
>
> Also, my personal wishlist has a new entry: A similar -ve prefix for
> yank-pop equivalent to -1: would be useful after this...

--