Subject: Re: bug#53894: 27.2; Clipboard copy -> C-y -> M-y -> Same clipboard copy does not push to kill ring

From: Lars Ingebrigtsen <[email-masked]>
Date: Wed, 09 Feb 2022 12:44:38 +0100

Ignacio Casso <[email-masked]> writes:

> I'm not sure if it's intentional or not, or even if Emacs can do
> anything about it (maybe since the text is the same, the clipboard is not
> actually modified and Emacs has no way to know). I just wanted to report
> it in case it is a bug.

It's intentional:

(defun gui-selection-value ()
  (let ((clip-text
         (when select-enable-clipboard
           (let ((text (gui--selection-value-internal 'CLIPBOARD)))
             (when (string= text "")
               (setq text nil))
             ;; When `select-enable-clipboard' is non-nil,
             ;; killing/copying text (with, say, `C-w') will push the
             ;; text to the clipboard (and store it in
             ;; `gui--last-selected-text-clipboard').  We check
             ;; whether the text on the clipboard is identical to this
             ;; text, and if so, we report that the clipboard is
             ;; empty.  See (bug#27442) for further discussion about
             ;; this DWIM action, and possible ways to make this check
             ;; less fragile, if so desired.
             (prog1
                 (unless (equal text gui--last-selected-text-clipboard)
                   text)
               (setq gui--last-selected-text-clipboard text)))))

But it's pretty fragile DWIM action, and is frequently not what I mean,
so I often resort to `clipboard-yank' instead to ensure that I really
get the clipboard contents.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no