bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#55692: 29.0.50; delete-selection-mode: Replace region only if set us


From: Eli Zaretskii
Subject: bug#55692: 29.0.50; delete-selection-mode: Replace region only if set using the mouse
Date: Sun, 29 May 2022 09:52:05 +0300

> From: Visuwesh <visuweshm@gmail.com>
> Cc: 55692@debbugs.gnu.org
> Date: Sun, 29 May 2022 11:47:32 +0530
> 
> [சனி மே 28, 2022] Eli Zaretskii wrote:
> 
> > 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.

Thanks.

> +@vindex delete-selection-temporary-regions-only

I'd drop the "-only" part: it is not necessary, and makes the variable
name longer.

>    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.

> @@ -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?

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.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]