[Top][All Lists]

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

RE: [External] : Re: Fix for `use-region-p' problem [was: Elisp test f

From: Drew Adams
Subject: RE: [External] : Re: Fix for `use-region-p' problem [was: Elisp test for whether `mouse-1' is pressed?]
Date: Tue, 9 Nov 2021 16:17:01 +0000

> Oh, I think I get it now. So I did the following experiment:
>   (setq my-timer
>         (run-with-timer 0 0.05
>                         (lambda()
>                           (message "%s  REG=%s"
>                                    (current-time-string)
>                                    (use-region-p)))))

Cool.  Thanks for trying, and looking into it.

> Now while the above is running, when I click with mouse-1, REG
> says "nil" /until/ I move the mouse far enough that the region
> is at least one char wide: then REG says t. If I go back to the
> starting point (while keeping mouse-1 down all the time), REG
> says nil again.

That's exactly right.  That's the point of the fix.

I know that you're talking about using that recipe
_without_ the fix.  And you're right, in what you say.

But only when option `use-empty-active-region' is nil.

The point of the fix is for the behavior you see to be
used even if that option is non-nil.

Why?  Because a click (down&up) always DEactivates the
region.  A click is a single action, from a user point
of view, even though it's realized using two events.

There really is no way, normally, to get an empty
active region with the mouse - other than keeping
mouse-1 pressed.

The aim of the fix I proposed is this: if you turn on
`use-empty-active-region'.  The region won't be
considered empty when mouse-1 is still pressed and at
the same position.

> I'm not a heavy mouse user (TBH, I'm a reluctant mouse user),

Many are in the same boat.  And that might be an
additional reason that this (admittedly corner) case
wasn't taken into account before.

> but the above behaviour looks reasonable to me.

It's the right behavior for both values of
`use-empty-active-region', IMO.  That's the point.

If you happen to agree then there are two of us... ;-)

> > Event `down-mouse-1' (button-down) activates the region,
> This doesn't happen for me. I've to drag the mouse a bit for
> the region to become active (a bit: one char width, as far as
> I can discern).

It does happen - see the code.  It's just that your
recipe to test it uses `use-region-p' (without the
fix), and your value of `use-empty-active-region' is
nil.  Set that option to t and then try your recipe

> I haven't tried with -Q, but I would, if you think that
> might shed more light on the topic.

(I used emacs -Q with Emacs 27.)

> > and event `mouse-1' (button-up) either (1) leaves it
> > activated, if the positions of down & up differ, or (2)
> > deactivates it, if those positions are the same.  (See
> > function `mouse-drag-track' for details.)
> I think we're seeing different things, so there might
> still be a gap between what I think I've understood
> and what I've actually understood :)

I think the gap is just `use-empty-active-region'.
Set it to t and try your recipe.

That option is for users to tell Emacs how to handle
an active empty region.  IMO it shouldn't recognize
the momentary active empty region that is manifested
during a mouse-1 click (down&up at the same location).

That's really all there is to what I'm saying/proposing.

reply via email to

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