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: Visuwesh
Subject: bug#55692: 29.0.50; delete-selection-mode: Replace region only if set using the mouse
Date: Tue, 31 May 2022 16:14:55 +0530
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

[ஞாயிறு மே 29, 2022] Eli Zaretskii wrote:

>> From: Visuwesh <visuweshm@gmail.com>
>> 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?
>
> [...]
>
> If not, why not?
>

For some reason, it completely crossed my mind that I could check for
the null value of delete-selection-temporary-region explicitly, thanks
for pointing out.  The condition is now,

      (when (and delete-selection-mode (use-region-p)
                 (not buffer-read-only)
                 (or (null delete-selection-temporary-region)
                     (and delete-selection-temporary-region
                          (consp transient-mark-mode)
                          (eq (car transient-mark-mode) 'only))
                     (and (not (eq delete-selection-temporary-region 
'selection))
                          (eq transient-mark-mode 'lambda))))


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

Indeed, that is more clear.  Thanks for teaching.

The paragraph now says,

       By default, text insertion occurs normally even if the mark is
    active—for example, typing ‘a’ inserts the character ‘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.
    However, you can tune this behavior by customizing the
    ‘delete-selection-temporary-region’ option.  Its default value is ‘nil’,
    but you can set it to ‘t’, in which case only temporarily-active regions
    will be replaced: those which are set by dragging the mouse (*note
    Setting Mark) or by shift-selection (*note Shift Selection), as well
    as by ‘C-u C-x C-x’ when Transient Mark Mode is disabled.  You can
    further tune the behavior by setting ‘delete-selection-temporary-region’
    to ‘selection’: then temporary regions by ‘C-u C-x C-x’ won’t be
    replaced, only the ones activated by dragging the mouse or
    shift-selection.  To toggle Delete Selection mode on or off, type ‘M-x
    delete-selection-mode’.

Is this fine?

Improved patch attached.

Attachment: 0001-delete-selection-mode-Add-user-option-to-delete-temp.patch
Description: Text Data


reply via email to

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