From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.bugs Subject: bug#32747: Be able to append mouse selections at the head of `kill-ring' (e.g, with C-M-w) Date: Sun, 22 May 2022 18:07:53 +0200 Message-ID: <87o7zptusm.fsf@gnus.org> References: >>> <83tvmlew2a.fsf@gnu.org>>>> <932a1915-c043-4708-9f16-dc0ee8fafdb3@default>>> <83pnx9een5.fsf@gnu.org>>> <01b0f0c4-e3b8-440f-a739-5995ca4ff615@default>> <83o9cte392.fsf@gnu.org>> <9136cccc-7e97-4a74-89a9-00eccab73c32@default> <87h8ikpf4u.fsf_-_@gmail.com> <87sfq64iwk.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="2271"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: 32747@debbugs.gnu.org To: Noam Postavsky Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun May 22 18:09:11 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 1nso8l-0000Qs-Le for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 22 May 2022 18:09:11 +0200 Original-Received: from localhost ([::1]:54262 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nso8k-0005LV-HJ for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 22 May 2022 12:09:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53544) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nso8c-0005Ij-Nj for bug-gnu-emacs@gnu.org; Sun, 22 May 2022 12:09:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:52275) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nso8c-0001om-Eo for bug-gnu-emacs@gnu.org; Sun, 22 May 2022 12:09:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nso8c-0002MB-8O for bug-gnu-emacs@gnu.org; Sun, 22 May 2022 12:09:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 22 May 2022 16:09:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 32747 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: moreinfo Original-Received: via spool by 32747-submit@debbugs.gnu.org id=B32747.16532356888998 (code B ref 32747); Sun, 22 May 2022 16:09:02 +0000 Original-Received: (at 32747) by debbugs.gnu.org; 22 May 2022 16:08:08 +0000 Original-Received: from localhost ([127.0.0.1]:46172 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nso7j-0002L4-NB for submit@debbugs.gnu.org; Sun, 22 May 2022 12:08:07 -0400 Original-Received: from quimby.gnus.org ([95.216.78.240]:41848) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nso7f-0002KV-4Y for 32747@debbugs.gnu.org; Sun, 22 May 2022 12:08:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=hENGGvuOQuq7H5v9UQLrOOAA1KeSrMqiufQjA6Xo0f4=; b=XDnKXvQ6lfMKZzjOEeiXTZ7jmL WWnd2OnsPX3z/zx/EO7e4sCCW5XFdml3fwgeeKjlHY5EoG0MoTYKdE2ZW3ggqEABxm9sogaSarj2N CdCJHjThZRoQGuRwDjYXJS5vLimXIuKuBJndMeITZvgdUbBMpRLJP2NmdeIZDoQc3xL4=; Original-Received: from [84.212.220.105] (helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nso7V-0008A6-L3; Sun, 22 May 2022 18:07:56 +0200 X-Now-Playing: Steven Brown's _Music for Film & Theatre (2)_: "Sangemar Mar" In-Reply-To: <87sfq64iwk.fsf_-_@gnus.org> (Lars Ingebrigtsen's message of "Thu, 21 Apr 2022 16:20:59 +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:232902 Archived-At: Lars Ingebrigtsen writes: > And this seems to be because `C-M-w' works by setting `last-command' to > `kill-region' to signal that the next `copy-region-as-kill' should > append. However, when dragging a region, `last-command' ends up being > nil by the time we reach `copy-region-as-kill' -- presumably because we > clear it somewhere in the mouse handling? > > Anybody have any ideas how to fix this, if we want to fix this? The following patch fixes this, but it's not clear that we want to do this. `C-w C-d' (kill-region + kill-word) will make the second kill append to the first, while similar commands like `M-w C-d' don't. So the mouse.el code has: ;; Ignore ;; `last-command' so we don't append to a preceding kill. Because we don't want `C-w ' to append to that `C-w', apparently. But -- if you do something like `C-d M-w', then that `M-w' is morally equivalent to the (i.e., we're putting more stuff onto the kill ring without killing text). So why is `C-w ' different here? The patch makes them behave the same way. If we don't want that, we have to come up with a whole nother way to implement `C-M-w', because it just sets last-command to `kill-region'. Opinions? diff --git a/lisp/mouse.el b/lisp/mouse.el index 4b5f6ed223..5913992e44 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -1396,7 +1396,8 @@ mouse-set-region ;; Don't set this-command to `kill-region', so a following ;; C-w won't double the text in the kill ring. Ignore ;; `last-command' so we don't append to a preceding kill. - (let (this-command last-command deactivate-mark) + (let ((last-command last-command) + this-command deactivate-mark) (copy-region-as-kill beg end))) (if (numberp beg) (goto-char beg)) ;; On a text terminal, bounce the cursor. @@ -1499,6 +1500,7 @@ mouse-drag-region (mouse-drag-and-drop-region start-event) ;; Give temporary modes such as isearch a chance to turn off. (run-hooks 'mouse-leave-buffer-hook) + (ignore-preserving-kill-region) (mouse-drag-track start-event))) ;; Inhibit the region-confinement when undoing mouse-drag-region @@ -1708,7 +1710,8 @@ mouse-drag-track nil start-point)) ((>= mouse-row bottom) (mouse-scroll-subr start-window (1+ (- mouse-row bottom)) - nil start-point)))))))) + nil start-point)))))) + (ignore-preserving-kill-region))) map) t (lambda () (funcall cleanup) -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no