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 20:10:16 +0300 Message-ID: <83r14cjmdj.fsf@gnu.org> References: <87zgj1v9xc.fsf@gmail.com> <83ilpplbhr.fsf@gnu.org> <8735gs9819.fsf@gmail.com> <837d64ltka.fsf@gnu.org> <87y1yk7o9f.fsf@gmail.com> <831qwclnf0.fsf@gnu.org> <87mtf075ky.fsf@gmail.com> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7563"; 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 19:11:21 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 1nvMRl-0001qJ-Ny for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 29 May 2022 19:11:21 +0200 Original-Received: from localhost ([::1]:39538 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nvMRk-0004NJ-8i for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 29 May 2022 13:11:20 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42422) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nvMRU-0004N3-9d for bug-gnu-emacs@gnu.org; Sun, 29 May 2022 13:11:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:47861) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nvMRS-0006Vx-K8 for bug-gnu-emacs@gnu.org; Sun, 29 May 2022 13:11:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nvMRS-0001AK-GC for bug-gnu-emacs@gnu.org; Sun, 29 May 2022 13:11: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 17:11: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.16538442324440 (code B ref 55692); Sun, 29 May 2022 17:11:02 +0000 Original-Received: (at 55692) by debbugs.gnu.org; 29 May 2022 17:10:32 +0000 Original-Received: from localhost ([127.0.0.1]:41758 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nvMQx-00019Y-S9 for submit@debbugs.gnu.org; Sun, 29 May 2022 13:10:32 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:48838) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nvMQv-00019I-Ej for 55692@debbugs.gnu.org; Sun, 29 May 2022 13:10:30 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:49960) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nvMQp-0006LV-UX; Sun, 29 May 2022 13:10:24 -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=A/fgmhqoGoEybh4bD0wpbqAaXdLnN0rdURqoUzzSZHk=; b=jtLaDu0+iup1 1F5PWF6OkeyZRJk5EtMuS+K4cHAzvMRGMCm1dj93/WCJ5k2HgZgsXJR+XL3vdX4eVYfUHVUmKUSgD +p4sP/H1PQgDLcoJ5ibUux3gY4tCoY1oRKLNQFW59mt5AVwbfzGBX6MquUZQ/mNxpwKZkYg8OH9E4 4qDGfbkcZj30oEpAW628YjR0beI0WCnPhEkiQMPddrwK9hPl9++vFngQknALn0xg81vDmPZ+/ScAa cOKIaY4NsBUjM9X25PP8B6BhnwAX0lmO2Asyh17oI1EovjJdB1d+ZsAI22xYFKrR2e2lYEb+tFpOZ HIRnk4PIjlTmcJ2ZYoT6yg==; Original-Received: from [87.69.77.57] (port=4938 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 1nvMQp-0007sT-Ci; Sun, 29 May 2022 13:10:23 -0400 In-Reply-To: <87mtf075ky.fsf@gmail.com> (message from Visuwesh on Sun, 29 May 2022 20:23:49 +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:233337 Archived-At: > From: Visuwesh > Cc: 55692@debbugs.gnu.org > Date: Sun, 29 May 2022 20:23:49 +0530 > > >> 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. > > I don't think I fully understood what you meant but I took a shot at it > anyway. Please review updated patch. Well, that uses double negation, which IME is a sign that it can be clarified. Is the following condition correct? (when (and delete-selection-mode (use-region-p) (not buffer-read-only) (or (null delete-selection-temporary-region) (and (eq delete-selection-temporary-region 'selection) (consp transient-mark-mode) (eq (car transient-mark-mode) 'only)) (and delete-selection-temporary-region (or (eq transient-mark-mode 'lambda) (and (consp transient-mark-mode) (eq (car transient-mark-mode) 'only)))))) If not, why not? > -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 (@pxref{Setting Mark}) or @kbd{C-u > +C-x C-x}, then change the variable > +@code{delete-selection-temporary-region} to @code{t}. But if you do > +not want to consider the region made active by @kbd{C-u C-x C-x} > +(@pxref{Disabled Transient Mark}), then set the variable to > +@code{selection}. To toggle Delete Selection mode on or off, type > +@kbd{M-x delete-selection-mode}. This text is now too complex and thus confusing. (You can only keep using that style for boolean options.) I would rephrase: Normally, inserting text deletes any active region, replacing it with the text you insert. However, you can tune this behavior by customizing the @code{delete-selection-temporary-region} option. Its default value is @code{nil}, but you can set it to @code{t}, in which case only temporarily-active regions will be replaced: those which are set by dragging the mouse (@pxref{Setting Mark}) or by shift-selection (@pxref{Shift Selection}), as well as by @kbd{C-u C-x C-x} when Transient Mark mode is disabled. You can further tune the behavior by setting @code{delete-selection-temporary-region} to @code{selection}: then temporary regions activated by @kbd{C-u C-x C-x} won't be replaced, only the ones activated by dragging the mouse or shift-selection. OK?