From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii 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 12:04:51 +0300 Message-ID: <831qwclnf0.fsf@gnu.org> References: <87zgj1v9xc.fsf@gmail.com> <83ilpplbhr.fsf@gnu.org> <8735gs9819.fsf@gmail.com> <837d64ltka.fsf@gnu.org> <87y1yk7o9f.fsf@gmail.com> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35449"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 55692@debbugs.gnu.org To: Visuwesh Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun May 29 11:06:54 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 1nvEsv-00095x-UC for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 29 May 2022 11:06:54 +0200 Original-Received: from localhost ([::1]:53302 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nvEsu-0001uM-Fx for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 29 May 2022 05:06:52 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41832) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nvEs7-0001r0-FX for bug-gnu-emacs@gnu.org; Sun, 29 May 2022 05:06:06 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:45480) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nvEs6-0005Eo-62 for bug-gnu-emacs@gnu.org; Sun, 29 May 2022 05:06:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nvEs6-0000Og-1P for bug-gnu-emacs@gnu.org; Sun, 29 May 2022 05:06:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 29 May 2022 09:06:01 +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.16538151061440 (code B ref 55692); Sun, 29 May 2022 09:06:01 +0000 Original-Received: (at 55692) by debbugs.gnu.org; 29 May 2022 09:05:06 +0000 Original-Received: from localhost ([127.0.0.1]:39372 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nvErC-0000N9-1g for submit@debbugs.gnu.org; Sun, 29 May 2022 05:05:06 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:48296) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nvEr6-0000MV-IZ for 55692@debbugs.gnu.org; Sun, 29 May 2022 05:05:04 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:43688) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nvEr1-0004o3-9h; Sun, 29 May 2022 05:04:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=Fzhmtc9nFhkX9i0exz9ttFdcrN+NuBscnt7X5G26Btg=; b=V1wUteBP2nZG vrtEwMZxmz8WK5uJfC9LyprV7c0ZTBFU6j7oVje93OUD8tJhMtMJHTjUETNngyapZ9+t93rkTtNCg UkGdATglqddwrDwS0n1ZPKnAURh/tIkT+ifjRrZi24MjmFy0Ek4B83hXakXXQTr/01NCiaqoZn1mh U6fnRN+ew4pdKickm5r+bhVw7w1ykX7UeFs94nB4vUUTW8HqdhhAqsDpHDRbxAAMg+aTJcu5iL6+L qyC0OLWQNjQbetVfPRhLkI2O9YLtbMilhrp7Au9PArPwTdvm41dMGs/9hw3s+8/VVl60JPfCsB0xw +CgEL6NaBQNPdTqyLUoG1g==; Original-Received: from [87.69.77.57] (port=2722 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nvEqy-0006QV-CP; Sun, 29 May 2022 05:04:55 -0400 In-Reply-To: <87y1yk7o9f.fsf@gmail.com> (message from Visuwesh on Sun, 29 May 2022 13:40:20 +0530) 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:233296 Archived-At: > From: Visuwesh > Cc: 55692@debbugs.gnu.org > Date: Sun, 29 May 2022 13:40:20 +0530 > > >> 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 > > > > There should be cross-references here to where these methods are > > described in the manual. > > > > These methods as in "mouse-dragging" or "shift-selection". I'm afraid I > don't fully understand what you mean. I mean to add @xref or @pxref to the places in the manual where mouse selection and shift-selection are described. Those places are, respectively, the nodes "Setting Mark" and "Shift Selection". > >> @@ -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) > > > > I wonder whether we should also optionally allow replacing text in > > regions activated by "C-u C-x C-x" when transient-mark-mode is off. > > Those cause transient-mark-mode to have the value 'lambda', not > > '(only...)'. So maybe the new defcustom should be a tristate, not a > > boolean? > > > > Sure, that could be useful. But I have transient-mark-mode turned on > always so I can't comment much on it. However, what would the third > state be? Some symbol. > When the defcustom is t, we could have it check for '(only . ...)' > and the value 'lambda', no? Yes, we could have: . nil - always replace the region . t - replace region from mouse, shift-selection, and "C-u C-x C-x" . selection - only replace region from mouse and shift-selection > > Also, can we have the above condition in a more elegant form? In > > general, whenever you have something like > > > > (if SOMETHING foo t) > > > > it begs to be rewritten so the "t" part is not needed, because 'if' > > itself already returns a boolean value. > > Sure. I will factor out the condition into a separate function. Is > that more elegant? No, that's overkill. I meant that if you need an 'if' to return t or something else, you could instead make it return nil or something else, as in (if SOMETHING foo) and reverse the condition. But if you still don't understand, just forget this comment.