From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.help Subject: Re: x-clipboard-yank insert kill-ring entry instead of primary selection Date: Mon, 02 Mar 2020 11:31:04 -0500 Message-ID: References: <831rqeho9f.fsf@gnu.org> <73781ecb442d054133e5fe81bd0c1805@posteo.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="68109"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) To: help-gnu-emacs@gnu.org Cancel-Lock: sha1:6FTT/Xsl5cHYomHrg54/j1WZ5mk= Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon Mar 02 17:31:32 2020 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1j8nye-000HeE-CF for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 02 Mar 2020 17:31:32 +0100 Original-Received: from localhost ([::1]:34878 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j8nyd-0002DT-Df for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 02 Mar 2020 11:31:31 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51254) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j8nyL-0002DH-BS for help-gnu-emacs@gnu.org; Mon, 02 Mar 2020 11:31:14 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j8nyK-0000CI-Bp for help-gnu-emacs@gnu.org; Mon, 02 Mar 2020 11:31:13 -0500 Original-Received: from ciao.gmane.io ([159.69.161.202]:60188) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j8nyK-0000Bi-4x for help-gnu-emacs@gnu.org; Mon, 02 Mar 2020 11:31:12 -0500 Original-Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1j8nyH-000HGm-5g for help-gnu-emacs@gnu.org; Mon, 02 Mar 2020 17:31:09 +0100 X-Injected-Via-Gmane: http://gmane.org/ X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 159.69.161.202 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:122510 Archived-At: > 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)))