From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Phil Sainty Newsgroups: gmane.emacs.bugs Subject: bug#58608: 29.0.50; Nasty bug with pasting primary selection in term buffers Date: Thu, 20 Oct 2022 11:14:50 +1300 Message-ID: <2e5596b526f1cf77da9e162dc2cb8566@webmail.orcon.net.nz> References: <4b9aa5bac2d1bfe5af7c246ae9648c87@webmail.orcon.net.nz> <62d5bb83a2bd9e5464d198c4ad38ec77@webmail.orcon.net.nz> <83ilkgysxo.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21212"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Orcon Webmail Cc: 58608@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Oct 20 00:15:29 2022 Return-path: Envelope-to: geb-bug-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 1olHLV-0005Gw-3H for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 20 Oct 2022 00:15:29 +0200 Original-Received: from localhost ([::1]:51242 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olHLT-00077J-DH for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 19 Oct 2022 18:15:27 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46760) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olHL5-00076f-9J for bug-gnu-emacs@gnu.org; Wed, 19 Oct 2022 18:15:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:33062) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1olHL4-00060o-MY for bug-gnu-emacs@gnu.org; Wed, 19 Oct 2022 18:15:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1olHL4-0006va-6m for bug-gnu-emacs@gnu.org; Wed, 19 Oct 2022 18:15:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Phil Sainty Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 19 Oct 2022 22:15:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58608 X-GNU-PR-Package: emacs Original-Received: via spool by 58608-submit@debbugs.gnu.org id=B58608.166621769726605 (code B ref 58608); Wed, 19 Oct 2022 22:15:02 +0000 Original-Received: (at 58608) by debbugs.gnu.org; 19 Oct 2022 22:14:57 +0000 Original-Received: from localhost ([127.0.0.1]:60373 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1olHKy-0006v3-QN for submit@debbugs.gnu.org; Wed, 19 Oct 2022 18:14:57 -0400 Original-Received: from smtp-3.orcon.net.nz ([60.234.4.44]:51735) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1olHKv-0006us-S4 for 58608@debbugs.gnu.org; Wed, 19 Oct 2022 18:14:55 -0400 Original-Received: from [10.253.37.70] (port=49104 helo=webmail.orcon.net.nz) by smtp-3.orcon.net.nz with esmtpa (Exim 4.90_1) (envelope-from ) id 1olHKs-00010n-Jt; Thu, 20 Oct 2022 11:14:50 +1300 Original-Received: from ip-180-148-114-34.kinect.net.nz ([180.148.114.34]) via [10.253.37.253] by webmail.orcon.net.nz with HTTP (HTTP/1.1 POST); Thu, 20 Oct 2022 11:14:50 +1300 In-Reply-To: <83ilkgysxo.fsf@gnu.org> X-Sender: psainty@orcon.net.nz X-GeoIP: -- X-Spam_score: -2.9 X-Spam_score_int: -28 X-Spam_bar: -- X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:245904 Archived-At: On 2022-10-20 00:05, Eli Zaretskii wrote: > From: Phil Sainty >> Looking at the docstring for `deactivate-mark' told me about >> `select-active-regions'. I don't know whether this is the correct >> solution, but I can confirm that this change to `term-mouse-paste' >> appears (after only cursory testing) to fix the bug: >> >> - (term-send-raw-string (gui-get-primary-selection))) >> + (let ((select-active-regions nil)) >> + (term-send-raw-string (gui-get-primary-selection)))) > > I think it could be important to understand why select-active-regions > causes this problem in your case. I think mechanically it's because the middle click moves point to the click position, and the call to `deactivate-mark' then causes the primary selection to be updated based on the current point and mark (unless we mess with select-active-regions). You've made me wonder, though... this command is intended only for term char mode, so should a middle click *really* be setting point? If all we're trying to do is send the selection text to the inferior process, that bit might be wrong. There's an explicit (mouse-set-point click) there, but if I comment out both that and my interim binding of `select-active-regions' then this also seems to do the right thing (once more with only very cursory testing). (defun term-mouse-paste (click) "Insert the primary selection at the position clicked on." (interactive "e") ;; Give temporary modes such as isearch a chance to turn off. (run-hooks 'mouse-leave-buffer-hook) (setq this-command 'yank) ;; (mouse-set-point click) ;; (let ((select-active-regions nil)) (term-send-raw-string (gui-get-primary-selection))) ;;) That's more of a change, but perhaps it's the correct thing to do. I'm now looking at that (setq this-command 'yank) as well, and wondering whether it's important for anything under the impression that a `yank' just happened to also see point at the location of the yank. I'm not sure whether a middle click in a terminal to send the primary selection directly to the inferior process *should* be treated as `yank' though -- maybe that code is also wrong. These changes are more nebulous to me, as they represent more of a functional change than binding `select-active-regions' does. -Phil