emacs-diffs
[Top][All Lists]
Advanced

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

master 855fd92: Make `M-x clipboard-yank' work reliably


From: Lars Ingebrigtsen
Subject: master 855fd92: Make `M-x clipboard-yank' work reliably
Date: Tue, 6 Jul 2021 13:25:52 -0400 (EDT)

branch: master
commit 855fd921201a75a21ff225128a8dced16cd95b52
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Make `M-x clipboard-yank' work reliably
    
    * lisp/menu-bar.el (clipboard-yank): Make the command work
    consistently (bug#27442).
    
    * lisp/select.el (gui-selection-value): Try to explain why the
    logic is the way it is.
---
 lisp/menu-bar.el |  4 +++-
 lisp/select.el   | 16 +++++++++++-----
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el
index 739e751..8def157 100644
--- a/lisp/menu-bar.el
+++ b/lisp/menu-bar.el
@@ -570,7 +570,9 @@
 (defun clipboard-yank ()
   "Insert the clipboard contents, or the last stretch of killed text."
   (interactive "*")
-  (let ((select-enable-clipboard t))
+  (let ((select-enable-clipboard t)
+        ;; Ensure that we defeat the DWIM login in `gui-selection-value'.
+        (gui--last-selected-text-clipboard nil))
     (yank)))
 
 (defun clipboard-kill-ring-save (beg end &optional region)
diff --git a/lisp/select.el b/lisp/select.el
index c39bc93..eaa74ce 100644
--- a/lisp/select.el
+++ b/lisp/select.el
@@ -184,11 +184,17 @@ decoded.  If `gui-get-selection' signals an error, return 
nil."
   (let ((clip-text
          (when select-enable-clipboard
            (let ((text (gui--selection-value-internal 'CLIPBOARD)))
-             (if (string= text "") (setq text nil))
-
-             ;; Check the CLIPBOARD selection for 'newness', is it different
-             ;; from what we remembered them to be last time we did a
-             ;; cut/paste operation.
+             (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)



reply via email to

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