all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: help-gnu-emacs@gnu.org
Subject: Re: x-clipboard-yank insert kill-ring entry instead of primary selection
Date: Mon, 02 Mar 2020 11:31:04 -0500	[thread overview]
Message-ID: <jwvk142208a.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: 73781ecb442d054133e5fe81bd0c1805@posteo.net

> 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)))




  parent reply	other threads:[~2020-03-02 16:31 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-28  8:31 x-clipboard-yank insert kill-ring entry instead of primary selection mickbert
2020-02-28 12:45 ` Stefan Monnier
2020-02-28 12:47 ` Eli Zaretskii
2020-03-02  9:57   ` mickbert
2020-03-02 11:34     ` Eli Zaretskii
2020-03-02 16:31     ` Stefan Monnier [this message]
2020-03-02 16:54       ` Eli Zaretskii
2020-03-02 19:56         ` Stefan Monnier
2020-03-02 20:15           ` Eli Zaretskii
2020-03-03 14:35             ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvk142208a.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.