From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#56530: 29.0.50; mouse-2 cut selected text when cua-mode is enabled Date: Sun, 17 Jul 2022 21:49:41 +0300 Organization: LINKOV.NET Message-ID: <86r12j5yya.fsf@mail.linkov.net> References: <3c83c124-95a9-9dc6-a7a6-6e357c7574e4@orange.fr> <877d4hmjdh.fsf@gmail.com> <87lesxtivx.fsf@gnus.org> <87wnchl1fm.fsf@gmail.com> <86mtdcg6qr.fsf@mail.linkov.net> <87edyna9wy.fsf@gnus.org> <867d4fa9p7.fsf@mail.linkov.net> <87h73j7epu.fsf@gnus.org> <86edym1a36.fsf@mail.linkov.net> <8735f1tkg2.fsf@gnus.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35964"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) Cc: David Ponce , 56530@debbugs.gnu.org, Visuwesh To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jul 17 21:36:13 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 1oDA3o-000981-NU for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 17 Jul 2022 21:36:12 +0200 Original-Received: from localhost ([::1]:36942 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oDA3n-00021O-BZ for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 17 Jul 2022 15:36:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33576) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oDA3f-0001zm-8O for bug-gnu-emacs@gnu.org; Sun, 17 Jul 2022 15:36:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:50843) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oDA3e-0002Ct-VU for bug-gnu-emacs@gnu.org; Sun, 17 Jul 2022 15:36:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oDA3e-0006rA-Rp for bug-gnu-emacs@gnu.org; Sun, 17 Jul 2022 15:36:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 17 Jul 2022 19:36:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 56530 X-GNU-PR-Package: emacs Original-Received: via spool by 56530-submit@debbugs.gnu.org id=B56530.165808651026277 (code B ref 56530); Sun, 17 Jul 2022 19:36:02 +0000 Original-Received: (at 56530) by debbugs.gnu.org; 17 Jul 2022 19:35:10 +0000 Original-Received: from localhost ([127.0.0.1]:48598 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oDA2o-0006pk-Fl for submit@debbugs.gnu.org; Sun, 17 Jul 2022 15:35:10 -0400 Original-Received: from relay12.mail.gandi.net ([217.70.178.232]:48389) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oDA2m-0006pG-0X for 56530@debbugs.gnu.org; Sun, 17 Jul 2022 15:35:08 -0400 Original-Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id 188FC200004; Sun, 17 Jul 2022 19:34:58 +0000 (UTC) In-Reply-To: <8735f1tkg2.fsf@gnus.org> (Lars Ingebrigtsen's message of "Sat, 16 Jul 2022 12:34:37 +0200") 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:237296 Archived-At: >> but only like Visuwesh pointed out >> when mouse-yank-at-point is set to t. This is because >> mouse-yank-primary has such line: >> >> (or mouse-yank-at-point (mouse-set-point event)) >> >> When delete-selection deletes the region where the mouse is clicked, >> mouse-set-point loses track and sets point to a random position, >> because the event contains fixed positions, not markers. >> I wonder why? > > Sounds like a bug. All affected mouse commands mouse-yank-from-menu, mouse-yank-at-click, mouse-yank-primary, mouse-yank-secondary have the same line: (or mouse-yank-at-point (mouse-set-point event)) So when the region is deleted by delete-selection-pre-hook `mouse-set-point' tries to set point using outdated information of the event's position in the deleted region. Maybe delete-selection-pre-hook could directly modify the event? Everything works fine with this: ((eq type 'yank-on-region) (let ((pos (posn-point (event-end last-nonmenu-event)))) (when (and (>= pos (region-beginning)) (<= pos (region-end))) (delete-selection-helper 'yank) (setf (nth 5 (nth 1 last-nonmenu-event)) (region-beginning))))) But is this a good idea?