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: Sun, 29 May 2022 11:47:32 +0530 Message-ID: <8735gs9819.fsf@gmail.com> References: <87zgj1v9xc.fsf@gmail.com> <83ilpplbhr.fsf@gnu.org> 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="38274"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: 55692@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun May 29 08:19:26 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 1nvCGo-0009Z6-Mx for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 29 May 2022 08:19:22 +0200 Original-Received: from localhost ([::1]:44282 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nvCGn-0008R8-4p for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 29 May 2022 02:19:21 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56026) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nvCGU-0008Qs-Ow for bug-gnu-emacs@gnu.org; Sun, 29 May 2022 02:19:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:45362) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nvCGU-0000mh-Df for bug-gnu-emacs@gnu.org; Sun, 29 May 2022 02:19:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nvCGU-0004m7-7J for bug-gnu-emacs@gnu.org; Sun, 29 May 2022 02:19:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Visuwesh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 29 May 2022 06:19:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 55692 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 55692-submit@debbugs.gnu.org id=B55692.165380509418300 (code B ref 55692); Sun, 29 May 2022 06:19:02 +0000 Original-Received: (at 55692) by debbugs.gnu.org; 29 May 2022 06:18:14 +0000 Original-Received: from localhost ([127.0.0.1]:39259 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nvCFi-0004l6-CZ for submit@debbugs.gnu.org; Sun, 29 May 2022 02:18:14 -0400 Original-Received: from mail-pg1-f193.google.com ([209.85.215.193]:37812) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nvCFg-0004kr-Jo for 55692@debbugs.gnu.org; Sun, 29 May 2022 02:18:13 -0400 Original-Received: by mail-pg1-f193.google.com with SMTP id f4so7438487pgf.4 for <55692@debbugs.gnu.org>; Sat, 28 May 2022 23:18:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:in-reply-to:date:lines:references:user-agent :message-id:mime-version; bh=SKhkl/lFNLITbsfd8ihtO1Kmyoc5FM5kL5GAnnB76qw=; b=ZZBnp7BxzNhn/Qwmq3P1uFjY108TLt8US6uG1l172bP+cjYIZG9VGWenXE94PjZq82 if50Gln+8mP+3lupLt7qrX1n0GGryQp4YkxhyubSG8FuoS3B6CT4mePsDfmqCx7dBE7v 4qbgo+fQUSbT9VoYMc7xa8BcgmPkUqiTXshQ/nG0TPT7gvHYyLt5xdotYkHUvBUxJWJM 2gWvPBDiMSN/OMRXATtmLKfeaucuQZQdvVxWm46AffDa6E91Irfy9/7ZgAbwumLiNe/M Tm1FjskOgUK4wt4xVuJOwArAnNwndFEXyUzrCpDaPbH6T7RCBTlhAlkN1jha3xPqo19g vFYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:date:lines :references:user-agent:message-id:mime-version; bh=SKhkl/lFNLITbsfd8ihtO1Kmyoc5FM5kL5GAnnB76qw=; b=jb/m86nwUcrKzQWk2l2LpPiOYAnXZ4XQjwnff9PYEAcf2uSyIkaCOWC7kONAk6ZNtk Vx0M2N38DsdG/BGh2fK8ALcArmisrLzCWRkg0KOBDZkM9GYZhLgv47CAXv1iVMKErCj6 yvfkFkbR2dW+0boudUi/2tAOm6KpCyf60pxWy3/dBx77cWBdInCD2waO3pFiafwhmP6T GCZBviAo/s5cU+KBwvPLQvFExZOLfjdeVMyHhn+fbXRGTvNAsA6ZpFry9BzrVgNMzgt2 +8JJwua3WSrQBRCZBmli/GSSw9lTxP734+OVeYsyhDQjADBZ7x/errfWk8Clmjh7kGWw i9tg== X-Gm-Message-State: AOAM532i9HOfI0evHR119Hb7DXYkiRcEQW7QKUcTlVEFgb0pE+2DHloc X49lXSk2Cww2r5Ccw7xK2oTpdQDjTmk= X-Google-Smtp-Source: ABdhPJw0dt1r8tmpIq6vpd70+aREuxbKPz4CgRx3gCyyXfGmk4Ep2Xi3mU2EuHEclee+bOPWchtevw== X-Received: by 2002:a05:6a00:1487:b0:518:b952:889b with SMTP id v7-20020a056a00148700b00518b952889bmr29553647pfu.43.1653805086605; Sat, 28 May 2022 23:18:06 -0700 (PDT) Original-Received: from localhost ([49.205.87.32]) by smtp.gmail.com with ESMTPSA id i9-20020a17090332c900b0015e8d4eb23asm6625277plr.132.2022.05.28.23.18.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 May 2022 23:18:05 -0700 (PDT) In-Reply-To: <83ilpplbhr.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 28 May 2022 22:10:08 +0300") Original-Lines: 119 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:233288 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable [=E0=AE=9A=E0=AE=A9=E0=AE=BF =E0=AE=AE=E0=AF=87 28, 2022] Eli Zaretskii wro= te: >> From: Visuwesh >> Date: Sat, 28 May 2022 23:03:51 +0530 >>=20 >> 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. > > IMO, we shouldn't distinguish between the mouse and shift-selection > methods of defining the region. So this feature, if accepted, should > also treat both methods of defining the region the same. Considering shift-selection would be convenient as well. Please check attached patch. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-delete-selection-mode-Add-user-option-to-delete-temp.patch >From 49e09eadf09b1848ce3dbe109e557384c99ce94d Mon Sep 17 00:00:00 2001 From: Visuwesh Date: Sun, 29 May 2022 11:45:19 +0530 Subject: [PATCH] delete-selection-mode: Add user option to delete temporary regions only * lisp/delsel.el (delete-selection-temporary-regions-only): Add new user option. (delete-selection-pre-hook): Respect it. * doc/emacs/mark.texi (Using Region): Document the new user option. * etc/NEWS: Announce the new user option. (bug#55692) --- doc/emacs/mark.texi | 7 +++++-- etc/NEWS | 5 +++++ lisp/delsel.el | 12 ++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/doc/emacs/mark.texi b/doc/emacs/mark.texi index 91c44d527b..1b53c2c478 100644 --- a/doc/emacs/mark.texi +++ b/doc/emacs/mark.texi @@ -291,13 +291,16 @@ Using Region @cindex Delete Selection mode @cindex mode, Delete Selection @findex delete-selection-mode +@vindex delete-selection-temporary-regions-only By default, text insertion occurs normally even if the mark is active---for example, typing @kbd{a} inserts the character @samp{a}, then deactivates the mark. Delete Selection mode, a minor mode, modifies this behavior: if you enable that mode, then inserting text while the mark is active causes the text in the region to be deleted -first. To toggle Delete Selection mode on or off, type @kbd{M-x -delete-selection-mode}. +first. If you want to replace only temporary regions, set by +mouse-dragging or shift-selection, then change the variable +@code{delete-selection-temporary-regions-only} to @code{t}. To toggle +Delete Selection mode on or off, type @kbd{M-x delete-selection-mode}. @node Mark Ring @section The Mark Ring diff --git a/etc/NEWS b/etc/NEWS index 85a0ee44b9..3016c62db0 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -271,6 +271,11 @@ startup. Previously, these functions ignored * Changes in Emacs 29.1 ++++ +** New user option 'delete-selection-temporary-regions-only'. +When non-nil, 'delete-selection-mode' will only delete the temporary +regions (usually set by mouse-dragging or shift-selection). + +++ ** New user option 'switch-to-prev-buffer-skip-regexp'. This should be a regexp or a list of regexps; buffers whose names diff --git a/lisp/delsel.el b/lisp/delsel.el index f5fe7cf793..7ee41ff2a7 100644 --- a/lisp/delsel.el +++ b/lisp/delsel.el @@ -64,6 +64,14 @@ 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-temporary-regions-only nil + "Whether to delete only temporary regions. +When non-nil, typed text only replaces temporary regions (usually +set by mouse-dragging or shift-selection)." + :version "29.1" + :group 'editing-basics + :type 'boolean) + ;;;###autoload (defalias 'pending-delete-mode 'delete-selection-mode) @@ -251,6 +259,10 @@ 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-temporary-regions-only + (and (consp transient-mark-mode) + (eq (car transient-mark-mode) 'only)) + t) (not buffer-read-only)) (delete-selection-helper (and (symbolp this-command) (get this-command 'delete-selection))))) -- 2.33.1 --=-=-=--