* bug#15960: 24.3.50; Provide a good way to tell when in `mouse-drag-track' (regression)
@ 2013-11-23 19:39 Drew Adams
2013-11-23 22:04 ` Stefan Monnier
0 siblings, 1 reply; 4+ messages in thread
From: Drew Adams @ 2013-11-23 19:39 UTC (permalink / raw)
To: 15960
I have code (library modeline-posn.el) that lets users optionally show
the active region size (highlighted) in the minibuffer, in place of the
buffer size.
My code did this, to test whether the region was active or the user
wants to allow an empty region to be highlighted:
(and transient-mark-mode mark-active
(or modelinepos-empty-region-flag
(/= (region-beginning) (region-end))))
With `modelinepos-empty-region-flag' non-nil, this made it easy for a
user to see when the active region is empty. (The mode-line size
indication is highlighted with face `region'.)
Emacs 24 changed things, so that this mode-line highlighting now
appeared immediately when you press `mouse-1', and did not wait until
you actually drag the mouse or release `mouse-1'.
This broke the user experience for this feature, because now each time
s?he clicked `mouse-1', without any dragging, a zero-size-region
indication showed in the mode line for as long as `mouse-1' was held
down during the click. IOW, an annoying flash.
Obviously that is no good, so I updated my code to try to test whether
we are inside `mouse-drag-track'. I found no clean and sure way to do
this, so I currently test `echo-keystrokes', which `mouse-drag-track'
binds to 0. This seems to work fine, but it is obviously indirect and
fragile.
The bug report is to request some clearer, cleaner, and surer way to
tell whether we are in `mouse-drag-track'.
This is the code I use now for the test:
(defun modelinepos-empty-region-p ()
"Return non-nil if region is active and empty.
But do not return non-nil if this is true but you are selecting with
the mouse. This is to prevent highlighting in the mode line whenever
you press `mouse-1' without dragging at least one character."
;; Fragile hack: Starting with Emacs 24, the region is considered
;; empty as soon as you press `mouse-1' (`down-mouse-1'). That causes
;; modeline highlighting each time you just click `mouse-1', i.e.,
;; without dragging it.
;;
;; The hack is to check whether `echo-keystrokes' is 0.
;; `mouse-drag-track' binds `echo-keystrokes' to 0, and that seems to
;; be the only way to tell whether we are in `mouse-drag-track'.
;; If the Emacs code for that changes then this might break.
(and transient-mark-mode mark-active
(or (if (> emacs-major-version 23)
(and (not (eq 0 echo-keystrokes))
modelinepos-empty-region-flag)
modelinepos-empty-region-flag)
(/= (region-beginning) (region-end)))))
In GNU Emacs 24.3.50.1 (i686-pc-mingw32)
of 2013-11-12 on LEG570
Windowing system distributor `Microsoft Corp.', version 6.1.7601
Configured using:
`configure --enable-checking 'CFLAGS=-O0 -g3' CPPFLAGS=-DGLYPH_DEBUG=1'
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#15960: 24.3.50; Provide a good way to tell when in `mouse-drag-track' (regression)
2013-11-23 19:39 bug#15960: 24.3.50; Provide a good way to tell when in `mouse-drag-track' (regression) Drew Adams
@ 2013-11-23 22:04 ` Stefan Monnier
2013-11-23 23:21 ` Drew Adams
0 siblings, 1 reply; 4+ messages in thread
From: Stefan Monnier @ 2013-11-23 22:04 UTC (permalink / raw)
To: Drew Adams; +Cc: 15960
> Emacs 24 changed things, so that this mode-line highlighting now
> appeared immediately when you press `mouse-1', and did not wait until
> you actually drag the mouse or release `mouse-1'.
Might simply be a bug. I suggest you focus on tracking why this is.
Stefan
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#15960: 24.3.50; Provide a good way to tell when in `mouse-drag-track' (regression)
2013-11-23 22:04 ` Stefan Monnier
@ 2013-11-23 23:21 ` Drew Adams
2013-11-24 0:42 ` Stefan Monnier
0 siblings, 1 reply; 4+ messages in thread
From: Drew Adams @ 2013-11-23 23:21 UTC (permalink / raw)
To: Stefan Monnier; +Cc: 15960
> > Emacs 24 changed things, so that this mode-line highlighting now
> > appeared immediately when you press `mouse-1', and did not wait
> > until you actually drag the mouse or release `mouse-1'.
>
> Might simply be a bug. I suggest you focus on tracking why this is.
It might. I have no objection to it being seen as a bug, and fixed.
But the behavior of the highlighting appearing now before you release
mouse-1 is a definite improvement. I would not wish to see that lost
because of the "fix". This just should not happen unless at least one
char is selected.
In any case, Chong Yidong (I think) changed the code considerably for
Emacs 24. It will take someone more knowledgable than I to figure it
out, let alone figure out just what was intended vs what might have
been accidental.
Providing a good, clean way to tell whether `mouse-drag-track' is in
progress (e.g. `mouse-tracking-p') would solve the problem I am
reporting. I would guess that it might also be useful more generally.
But if you don't see it that way and don't want to fix this, I'll
continue to rely on (eq 0 echo-keystrokes) as the test for this.
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#15960: 24.3.50; Provide a good way to tell when in `mouse-drag-track' (regression)
2013-11-23 23:21 ` Drew Adams
@ 2013-11-24 0:42 ` Stefan Monnier
0 siblings, 0 replies; 4+ messages in thread
From: Stefan Monnier @ 2013-11-24 0:42 UTC (permalink / raw)
To: Drew Adams; +Cc: 15960
> But the behavior of the highlighting appearing now before you release
> mouse-1 is a definite improvement. I would not wish to see that lost
> because of the "fix". This just should not happen unless at least one
> char is selected.
Sounds right. That's why I think it's just a bug/misfeature.
> Providing a good, clean way to tell whether `mouse-drag-track' is in
> progress (e.g. `mouse-tracking-p') would solve the problem I am
> reporting.
It would just give you a way to work around the problem. I'd much
rather fix it instead.
Stefan
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-11-24 0:42 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-23 19:39 bug#15960: 24.3.50; Provide a good way to tell when in `mouse-drag-track' (regression) Drew Adams
2013-11-23 22:04 ` Stefan Monnier
2013-11-23 23:21 ` Drew Adams
2013-11-24 0:42 ` Stefan Monnier
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.