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: Wed, 15 Mar 2023 01:46:28 +1300 Message-ID: <628154950d12e3e6c6989ae14f843bbb@webmail.orcon.net.nz> References: <4b9aa5bac2d1bfe5af7c246ae9648c87@webmail.orcon.net.nz> <62d5bb83a2bd9e5464d198c4ad38ec77@webmail.orcon.net.nz> <83ilkgysxo.fsf@gnu.org> <2e5596b526f1cf77da9e162dc2cb8566@webmail.orcon.net.nz> <835ygfys2k.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=_80e76aeb33181c113278f0cfb92f5719" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39711"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Orcon Webmail Cc: 58608@debbugs.gnu.org, "Richard M. Stallman" To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Mar 14 13:47:20 2023 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 1pc43k-0009zY-8h for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 14 Mar 2023 13:47:20 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pc43U-00010U-6k; Tue, 14 Mar 2023 08:47:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pc43S-0000zp-Q4 for bug-gnu-emacs@gnu.org; Tue, 14 Mar 2023 08:47:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pc43S-00009d-Ha for bug-gnu-emacs@gnu.org; Tue, 14 Mar 2023 08:47:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pc43S-00034c-8G for bug-gnu-emacs@gnu.org; Tue, 14 Mar 2023 08:47: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: Tue, 14 Mar 2023 12:47: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.167879799411779 (code B ref 58608); Tue, 14 Mar 2023 12:47:02 +0000 Original-Received: (at 58608) by debbugs.gnu.org; 14 Mar 2023 12:46:34 +0000 Original-Received: from localhost ([127.0.0.1]:36641 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pc42z-00033u-OU for submit@debbugs.gnu.org; Tue, 14 Mar 2023 08:46:34 -0400 Original-Received: from smtp-1.orcon.net.nz ([60.234.4.34]:32809) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pc42y-00033m-2x for 58608@debbugs.gnu.org; Tue, 14 Mar 2023 08:46:33 -0400 Original-Received: from [10.253.37.70] (port=52492 helo=webmail.orcon.net.nz) by smtp-1.orcon.net.nz with esmtpa (Exim 4.90_1) (envelope-from ) id 1pc42v-0001JJ-AR; Wed, 15 Mar 2023 01:46:30 +1300 Original-Received: from ip-180-148-124-51.kinect.net.nz ([180.148.124.51]) via [10.253.37.253] by webmail.orcon.net.nz with HTTP (HTTP/1.1 POST); Wed, 15 Mar 2023 01:46:28 +1300 In-Reply-To: <835ygfys2k.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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:257931 Archived-At: --=_80e76aeb33181c113278f0cfb92f5719 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed On 2022-10-20 18:36, Eli Zaretskii wrote: >> Date: Thu, 20 Oct 2022 11:14:50 +1300 >> From: Phil Sainty >> 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. > > It could be, but maybe looking at the Git history of that code will > tell you why we have that part there? I mean, maybe there are use > cases where that is important? > > If nothing comes up, I think you are right, and that move should be > removed. On a GUI frame, a middle click leaves point _at_the_end_ of > the inserted text, not where I click. I don't have my head around all of this, but I've done some digging... The call to `mouse-set-point' in `term-mouse-paste' dates back to its origins in commit 4060e6ee3b796ecac506b1ca54217b100795d73a (by RMS) dated 1994, and then there are a couple of subsequent commits of interest: commit aade4ab28e774bc2d74a6567aae24e805f30e78a by Per Bothner in 1995 removed the call to `mouse-set-point' (amongst other changes), and then in 2004 Richard explicitly added it back again: commit 2d7502b55b52b9668c2c920f1bfa5bd437fb3b96 Author: Richard M. Stallman Date: Fri Jan 30 16:53:11 2004 +0000 (term-mouse-paste): Call mouse-set-point. Richard, I've CC'd you on this basis, as it's not clear to me why the `term-mouse-paste' command (which I would expect to do nothing besides send the primary selection text to the inferior process) should be setting point. Do you recall the use-case for that? (n.b. I've attached the above-mentioned commits to this email.) > But if we aren't sure, it's okay to momentarily disable > select-active-regions here, we just need a comment with the > explanation you wrote above. I'm certainly unsure of much of this. I can add that bug#2449 from 2009 is where (deactivate-mark) in `term-send-raw-string' originates, so I think that will be when the `term-mouse-paste' problem I've reported was effectively introduced, as it's the `deactivate-mark' call which causes the primary selection to be updated. The commits for that were: commit c5f894821d04f6fbaf3b8c62308692439ec598d3 2009-03-08 19:33 commit 212bb1a81ade52dcbcbb1bceb680e3e0e0b6264c 2009-03-08 19:37 commit 1cb6d11e13c5e28f96558b85f15344abd56f5e18 2009-03-13 01:43 I haven't read through that bug report, but as `deactivate-mark' was the solution to that, I don't imagine removing that call would be a viable thing to do now, so let-binding `select-active-regions' still feels like a reasonable option for the current problem. >> 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. > > Indeed, we don't by default treat middle click as yank on GUI frames. > So maybe you are right -- but please note that there are some user > options which perhaps do cause the middle click to be treated as yank > as optional behavior, in which case they should do the same in the > term case. This code also dates back to the original implementation of `term-mouse-paste', and bug#6845 from 2010 seems notable for this part. That bug was about `term-mouse-paste' pasting the current kill instead of the primary selection. I don't believe the changes for that are relevant to the *main* problem I've reported, but when the command was pasting from the kill ring the (setq this-command 'yank) call would have made sense, so I suspect this call should have been removed in commit ff98b2dd51e84b812e061859fa8c682d22b2e459 ? All in all: * The (deactivate-mark) in `term-send-raw-string' seems important. * I don't understand the `mouse-set-point' call, but it may be wanted. * Disabling `select-active-regions' in `term-mouse-paste' still seems like the way to go if point is being set (or maybe regardless). * (setq this-command 'yank) looks like an old remnant (now a bug). -Phil (not currently subscribed to the lists; please keep me CC'd) --=_80e76aeb33181c113278f0cfb92f5719 Content-Transfer-Encoding: base64 Content-Type: text/x-diff; name=term-mouse-paste-mouse-set-point.diff Content-Disposition: attachment; filename=term-mouse-paste-mouse-set-point.diff; size=2569 Y29tbWl0IDJkNzUwMmI1NWI1MmI5NjY4YzJjOTIwZjFiZmE1YmQ0MzdmYjNiOTYKQXV0aG9yOiBS aWNoYXJkIE0uIFN0YWxsbWFuIDxybXNAZ251Lm9yZz4KRGF0ZTogICBGcmkgSmFuIDMwIDE2OjUz OjExIDIwMDQgKzAwMDAKCiAgICAodGVybS1tb3VzZS1wYXN0ZSk6IENhbGwgbW91c2Utc2V0LXBv aW50LgoKZGlmZiAtLWdpdCBhL2xpc3AvdGVybS5lbCBiL2xpc3AvdGVybS5lbAotLS0gYS9saXNw L3Rlcm0uZWwKKysrIGIvbGlzcC90ZXJtLmVsCkBAIC0xMTYzLDE2ICsxMTYzLDE3IEBACgogKGRl ZnVuIHRlcm0tbW91c2UtcGFzdGUgKGNsaWNrIGFyZykKICAgIkluc2VydCB0aGUgbGFzdCBzdHJl dGNoIG9mIGtpbGxlZCB0ZXh0IGF0IHRoZSBwb3NpdGlvbiBjbGlja2VkIG9uLiIKICAgKGludGVy YWN0aXZlICJlXG5QIikKICAgKHRlcm0taWYteGVtYWNzCiAgICAodGVybS1zZW5kLXJhdy1zdHJp bmcgKG9yIChjb25kaXRpb24tY2FzZSAoKSAoeC1nZXQtc2VsZWN0aW9uKSAoZXJyb3IgKCkpKQog CQkJICAgICAoeC1nZXQtY3V0YnVmZmVyKQogCQkJICAgICAoZXJyb3IgIk5vIHNlbGVjdGlvbiBv ciBjdXQgYnVmZmVyIGF2YWlsYWJsZSIpKSkpCiAgICh0ZXJtLWlmbm90LXhlbWFjcwogICAgOzsg R2l2ZSB0ZW1wb3JhcnkgbW9kZXMgc3VjaCBhcyBpc2VhcmNoIGEgY2hhbmNlIHRvIHR1cm4gb2Zm LgogICAgKHJ1bi1ob29rcyAnbW91c2UtbGVhdmUtYnVmZmVyLWhvb2spCiAgICAoc2V0cSB0aGlz LWNvbW1hbmQ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