help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: x-clipboard-yank insert kill-ring entry instead of primary selection


From: Stefan Monnier
Subject: Re: x-clipboard-yank insert kill-ring entry instead of primary selection
Date: Mon, 02 Mar 2020 11:31:04 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

> mouse-yank-primary (which can only be bound to mouse event).

>From where I stand, this restriction is a bug.

    (advice-add 'mouse-yank-primary :before
      (lambda (&rest _) (interactive (list last-nonmenu-event)) nil))

should work around the bug.  A more complete fix might look like the
patch below.


        Stefan


diff --git a/lisp/mouse.el b/lisp/mouse.el
index c1ddfc2b85..7bfcf2f3c4 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -1521,12 +1521,14 @@ mouse-yank-at-click
   (setq mouse-selection-click-count 0)
   (yank arg))
 
-(defun mouse-yank-primary (click)
-  "Insert the primary selection at the position clicked on.
+(defun mouse-yank-primary (&optional event)
+  "Insert the primary selection.
 Move point to the end of the inserted text, and set mark at
-beginning.  If `mouse-yank-at-point' is non-nil, insert at point
-regardless of where you click."
-  (interactive "e")
+beginning.
+By default, insert at the position of the EVENT, but
+if `mouse-yank-at-point' is non-nil, insert at point
+regardless of where the event happened."
+  (interactive (list last-nonmenu-event))
   ;; Give temporary modes such as isearch a chance to turn off.
   (run-hooks 'mouse-leave-buffer-hook)
   ;; Without this, confusing things happen upon e.g. inserting into
@@ -1534,7 +1536,7 @@ mouse-yank-primary
   (when select-active-regions
     (let (select-active-regions)
       (deactivate-mark)))
-  (or mouse-yank-at-point (mouse-set-point click))
+  (or mouse-yank-at-point (mouse-set-point event))
   (let ((primary (gui-get-primary-selection)))
     (push-mark)
     (insert-for-yank primary)))




reply via email to

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