From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Visuwesh Newsgroups: gmane.emacs.bugs Subject: bug#55692: 29.0.50; delete-selection-mode: Replace region only if set using the mouse Date: Sat, 28 May 2022 23:03:51 +0530 Message-ID: <87zgj1v9xc.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25214"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) To: 55692@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat May 28 19:34:12 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 1nv0KJ-0006LN-0g for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 28 May 2022 19:34:11 +0200 Original-Received: from localhost ([::1]:33390 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nv0KH-00019E-DD for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 28 May 2022 13:34:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43388) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nv0KA-00018z-Ay for bug-gnu-emacs@gnu.org; Sat, 28 May 2022 13:34:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:44956) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nv0KA-0004BV-2v for bug-gnu-emacs@gnu.org; Sat, 28 May 2022 13:34:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nv0K9-0002VH-VB for bug-gnu-emacs@gnu.org; Sat, 28 May 2022 13:34:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Visuwesh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 28 May 2022 17:34:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 55692 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.16537592409614 (code B ref -1); Sat, 28 May 2022 17:34:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 28 May 2022 17:34:00 +0000 Original-Received: from localhost ([127.0.0.1]:38853 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nv0K8-0002V0-F1 for submit@debbugs.gnu.org; Sat, 28 May 2022 13:34:00 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:40886) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nv0K7-0002Ur-Ov for submit@debbugs.gnu.org; Sat, 28 May 2022 13:34:00 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43386) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nv0K7-00018p-Id for bug-gnu-emacs@gnu.org; Sat, 28 May 2022 13:33:59 -0400 Original-Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:44675) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nv0K5-0004BH-KI for bug-gnu-emacs@gnu.org; Sat, 28 May 2022 13:33:59 -0400 Original-Received: by mail-pl1-x641.google.com with SMTP id q4so6801770plr.11 for ; Sat, 28 May 2022 10:33:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:user-agent:mime-version; bh=aS3hwPhQqRZ+vGGr8OI8+u25j8r/0qfRRjacXE0Cwzk=; b=ZYeEyzT2vE096yFC7etVfOWCOFMiaM4cv5nskIqg+M4i6W7aCt6RSK41r8X2CfjBvz 7EYiw/RRvASCiACchRtc6Pu0kNKuf8k78LFu/DEg3AKGE6XptgkSyzJPhkvJIQ4XMB1j EoEwKCFce/CbMyplJP5O63QKCBnk8KNaUaB/zdiXnJoZ4sJa1hasHOpCqbAfTwaqrx7T wsXvlemBt8mmZYYAbQDkcUeFQ7dK3uGR/bu3p1l2htddACev3+umFDFfnfIpqSqJqNZo GBRxdSX2ZaGxAVxLnRLusrIJgoiYnyqSCMJJCpzTpVQ+9qvf1AHoI3g+hIY3yDbrEoTQ /+WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:user-agent :mime-version; bh=aS3hwPhQqRZ+vGGr8OI8+u25j8r/0qfRRjacXE0Cwzk=; b=5HAl4ATyMrvpNI+HrWmjvR9qpLQjyLTWRPBEQJb5El4QGc91cEwijlq2lngT2jwAPz cPmbwvtCQ4PcyUalD3+FRzjhx3dbb8xFuDcedcGwF4dH2Zd8sqEWQTzgKECAKPXMce9O bymKbslOieI1avUcs4G1rRoJQTr7Zu+7aGyS8zr1Z7SVLJSBjxqP23kkCfKosqPCz/Rg o+vLg0iAlo5No5gffP/erYQf6L28c+68po9PWhEkUMvoCF7qc/DCUbC/B9r8gJX2r0V2 7wXebB7I5V+cAGLNPUVblNYLMTZFOxUVMYs0Hu/94mqhmZX8RVtig8NNLcz7Q4MHwVJy wfXg== X-Gm-Message-State: AOAM5311jmfzqRoturo5hg7jiEFPHYuC/PhbuH/ywzOHh5tymQvAFEYo 8iFB5sIJ0A2cm6uWpB6n4p0WpXgkfKU= X-Google-Smtp-Source: ABdhPJyzIrEjiQ+r1rTwjH3JFw3nd/BptqP38CcZJlFzvrJ7kbiYn7Fx8Vui86W7scSL5DXOJJEPIg== X-Received: by 2002:a17:902:ecc6:b0:163:8bc7:16c5 with SMTP id a6-20020a170902ecc600b001638bc716c5mr10687453plh.75.1653759235318; Sat, 28 May 2022 10:33:55 -0700 (PDT) Original-Received: from localhost ([49.204.114.242]) by smtp.gmail.com with ESMTPSA id y13-20020aa79e0d000000b0050dc76281c9sm5657330pfq.163.2022.05.28.10.33.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 May 2022 10:33:54 -0700 (PDT) Received-SPF: pass client-ip=2607:f8b0:4864:20::641; envelope-from=visuweshm@gmail.com; helo=mail-pl1-x641.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action 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:233270 Archived-At: --=-=-= Content-Type: text/plain Tags: patch Motivation: I often find myself annoyed by `delete-selection-mode' when using the keyboard since the region in Emacs does not translate to text selections in other applications. On the contrary, I find myself wanting the behaviour of `delete-selection-mode' for regions set using the mouse. Attached patch adds an user option to do that. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-delete-selection-mode-Add-user-option-to-delete-mous.patch >From 3db630457b46bb25514a8041eeb80f35e73ef40c Mon Sep 17 00:00:00 2001 From: Visuwesh Date: Sat, 28 May 2022 22:52:19 +0530 Subject: [PATCH] delete-selection-mode: Add user option to delete mouse regions only * lisp/delsel.el (delete-selection-mouse-selection-only): Add new user option. (delete-selection-pre-hook): Respect it. * etc/NEWS: Announce the new user option. --- etc/NEWS | 4 ++++ lisp/delsel.el | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/etc/NEWS b/etc/NEWS index 3065fa85d3..100be767b3 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -265,6 +265,10 @@ startup. Previously, these functions ignored * Changes in Emacs 29.1 +++ +** New user option 'delete-selection-mouse-selection-only'. +When non-nil, 'delete-selection-mode' will only delete the active +region if it was set using the mouse. + ** New user option 'switch-to-prev-buffer-skip-regexp'. This should be a regexp or a list of regexps; buffers whose names match those regexps will be ignored by 'switch-to-prev-buffer' and diff --git a/lisp/delsel.el b/lisp/delsel.el index f5fe7cf793..a011be9ede 100644 --- a/lisp/delsel.el +++ b/lisp/delsel.el @@ -64,6 +64,12 @@ delete-selection-save-to-register "If non-nil, deleted region text is stored in this register. Value must be the register (key) to use.") +(defcustom delete-selection-mouse-selection-only nil + "If non-nil, delete the region only if set using the mouse." + :version "29.1" + :group 'editing-basics + :type 'boolean) + ;;;###autoload (defalias 'pending-delete-mode 'delete-selection-mode) @@ -251,6 +257,9 @@ delete-selection-pre-hook have this property won't delete the selection. See `delete-selection-helper'." (when (and delete-selection-mode (use-region-p) + (if delete-selection-mouse-selection-only + (mouse-region-match) + t) (not buffer-read-only)) (delete-selection-helper (and (symbolp this-command) (get this-command 'delete-selection))))) -- 2.33.1 --=-=-=--