From f5293b336478ca48052b6a4b1538de45446317f4 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Tue, 28 Jun 2022 18:25:50 +0800 Subject: [PATCH] Adjust x-clipboard-yank for recent selection ownership changes * lisp/term/x-win.el (x-clipboard-yank): Don't own CLIPBOARD inside kill-new. --- lisp/term/x-win.el | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lisp/term/x-win.el b/lisp/term/x-win.el index 32675a07b1f..7c88c85ceff 100644 --- a/lisp/term/x-win.el +++ b/lisp/term/x-win.el @@ -1182,8 +1182,12 @@ as returned by `x-server-vendor'." (interactive "*") (let ((clipboard-text (gui--selection-value-internal 'CLIPBOARD)) (select-enable-clipboard t)) - (if (and clipboard-text (> (length clipboard-text) 0)) - (kill-new clipboard-text)) + (when (and clipboard-text (> (length clipboard-text) 0)) + ;; Avoid asserting ownership of CLIPBOARD, which will cause + ;; `gui-selection-value' to return nil in the future. + ;; (bug#56273) + (let ((select-enable-clipboard nil)) + (kill-new clipboard-text))) (yank))) (declare-function accelerate-menu "xmenu.c" (&optional frame) t) -- 2.39.5