* bug#9609: Excessive transient region highlighting with highlight-nonselected-windows
@ 2011-09-27 1:42 Glenn Morris
2021-06-02 7:48 ` Lars Ingebrigtsen
0 siblings, 1 reply; 9+ messages in thread
From: Glenn Morris @ 2011-09-27 1:42 UTC (permalink / raw)
To: 9609
Package: emacs
Version: 24.0.90
emacs -Q --eval '(progn (setq highlight-nonselected-windows t) (transient-mark-mode -1))' -f make-frame
Two frames open showing the *scratch* buffer, once frame has focus.
With the mouse, click on the "n" of "notes" in the focused frame. Do
not release the mouse. In the other frame, a region starting or ending
at "n" is now selected.
This does not happen in Emacs 23.3. How do I disable this selection of a
region in the non-selected frame?
(Obviously I can set highlight-nonselected-windows nil, but I want that
behaviour for regions I explicitly select.)
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#9609: Excessive transient region highlighting with highlight-nonselected-windows
2011-09-27 1:42 bug#9609: Excessive transient region highlighting with highlight-nonselected-windows Glenn Morris
@ 2021-06-02 7:48 ` Lars Ingebrigtsen
2021-06-02 12:43 ` Eli Zaretskii
0 siblings, 1 reply; 9+ messages in thread
From: Lars Ingebrigtsen @ 2021-06-02 7:48 UTC (permalink / raw)
To: Glenn Morris; +Cc: 9609
Glenn Morris <rgm@gnu.org> writes:
> emacs -Q --eval '(progn (setq highlight-nonselected-windows t) (transient-mark-mode -1))' -f make-frame
>
> Two frames open showing the *scratch* buffer, once frame has focus.
>
> With the mouse, click on the "n" of "notes" in the focused frame. Do
> not release the mouse. In the other frame, a region starting or ending
> at "n" is now selected.
I can confirm that this is still present in Emacs 28.
Pretty weird behaviour.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#9609: Excessive transient region highlighting with highlight-nonselected-windows
2021-06-02 7:48 ` Lars Ingebrigtsen
@ 2021-06-02 12:43 ` Eli Zaretskii
2021-06-02 13:34 ` Eli Zaretskii
0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2021-06-02 12:43 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: rgm, 9609
> From: Lars Ingebrigtsen <larsi@gnus.org>
> Date: Wed, 02 Jun 2021 09:48:05 +0200
> Cc: 9609@debbugs.gnu.org
>
> Glenn Morris <rgm@gnu.org> writes:
>
> > emacs -Q --eval '(progn (setq highlight-nonselected-windows t) (transient-mark-mode -1))' -f make-frame
> >
> > Two frames open showing the *scratch* buffer, once frame has focus.
> >
> > With the mouse, click on the "n" of "notes" in the focused frame. Do
> > not release the mouse. In the other frame, a region starting or ending
> > at "n" is now selected.
>
> I can confirm that this is still present in Emacs 28.
>
> Pretty weird behaviour.
Probably we decided that the mouse was dragged because the coordinates
in the other window are different. Or something like that.
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#9609: Excessive transient region highlighting with highlight-nonselected-windows
2021-06-02 12:43 ` Eli Zaretskii
@ 2021-06-02 13:34 ` Eli Zaretskii
2021-06-02 22:02 ` Juri Linkov
0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2021-06-02 13:34 UTC (permalink / raw)
To: larsi; +Cc: rgm, 9609
> Date: Wed, 02 Jun 2021 15:43:25 +0300
> From: Eli Zaretskii <eliz@gnu.org>
> Cc: rgm@gnu.org, 9609@debbugs.gnu.org
>
> > > emacs -Q --eval '(progn (setq highlight-nonselected-windows t) (transient-mark-mode -1))' -f make-frame
> > >
> > > Two frames open showing the *scratch* buffer, once frame has focus.
> > >
> > > With the mouse, click on the "n" of "notes" in the focused frame. Do
> > > not release the mouse. In the other frame, a region starting or ending
> > > at "n" is now selected.
> >
> > I can confirm that this is still present in Emacs 28.
> >
> > Pretty weird behaviour.
>
> Probably we decided that the mouse was dragged because the coordinates
> in the other window are different. Or something like that.
Btw, you don't need another frame to demonstrate the issue. You could
do this instead:
emacs -Q --eval '(progn (setq highlight-nonselected-windows t) (transient-mark-mode -1))'
C-x 2
Click and hold the mouse button on some character
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#9609: Excessive transient region highlighting with highlight-nonselected-windows
2021-06-02 13:34 ` Eli Zaretskii
@ 2021-06-02 22:02 ` Juri Linkov
2021-06-03 7:25 ` Eli Zaretskii
0 siblings, 1 reply; 9+ messages in thread
From: Juri Linkov @ 2021-06-02 22:02 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: rgm, larsi, 9609
>> > > emacs -Q --eval '(progn (setq highlight-nonselected-windows t) (transient-mark-mode -1))' -f make-frame
>> > >
>> > > Two frames open showing the *scratch* buffer, once frame has focus.
>> > >
>> > > With the mouse, click on the "n" of "notes" in the focused frame. Do
>> > > not release the mouse. In the other frame, a region starting or ending
>> > > at "n" is now selected.
>> >
>> > I can confirm that this is still present in Emacs 28.
>> >
>> > Pretty weird behaviour.
>>
>> Probably we decided that the mouse was dragged because the coordinates
>> in the other window are different. Or something like that.
>
> Btw, you don't need another frame to demonstrate the issue. You could
> do this instead:
>
> emacs -Q --eval '(progn (setq highlight-nonselected-windows t) (transient-mark-mode -1))'
> C-x 2
> Click and hold the mouse button on some character
The problem is that currently the mark is not window-local.
I tried such workaround, that fixes the above problem, but it has
other issues. A proper fix needs to be in some low-level function.
#+begin_src emacs-lisp
;; Make the mark buffer-and-window-local.
(defvar-local mark-active-window nil)
(add-hook 'activate-mark-hook (lambda () (setq mark-active-window (selected-window))))
(advice-add 'activate-mark :after
(lambda (&rest _args)
(setq mark-active-window (selected-window)))
'((name . mark-active-window)))
;; Can't use deactivate-mark-hook because when clicking mouse in another window
;; with the same buffer it calls both activate-mark and deactivate-mark,
;; but deactivate-mark checks if the region is active (region-active-p),
;; and doesn't advance further because mark-active was set to nil in the redisplay
;; hook below. OTOH, the advice is used unconditionally.
(add-hook 'deactivate-mark-hook (lambda () (setq mark-active-window nil)))
(advice-add 'deactivate-mark :after
(lambda (&rest _args)
(setq mark-active-window nil))
'((name . mark-active-window)))
(defun redisplay--update-mark-active-window (window)
(when mark-active-window
(setq mark-active (eq mark-active-window window))))
;; Problem: when compiled without optimization CFLAGS='-O0' then
;; quick region selection experiences lags that results in wrong selection.
;; Another problem is that in ‘follow-mode’ ‘set-mark-command’ messes up windows.
(add-hook 'pre-redisplay-functions #'redisplay--update-mark-active-window)
#+end_src
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#9609: Excessive transient region highlighting with highlight-nonselected-windows
2021-06-02 22:02 ` Juri Linkov
@ 2021-06-03 7:25 ` Eli Zaretskii
2021-06-03 20:20 ` Juri Linkov
0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2021-06-03 7:25 UTC (permalink / raw)
To: Juri Linkov; +Cc: rgm, larsi, 9609
> From: Juri Linkov <juri@linkov.net>
> Cc: larsi@gnus.org, rgm@gnu.org, 9609@debbugs.gnu.org
> Date: Thu, 03 Jun 2021 01:02:25 +0300
>
> > emacs -Q --eval '(progn (setq highlight-nonselected-windows t) (transient-mark-mode -1))'
> > C-x 2
> > Click and hold the mouse button on some character
>
> The problem is that currently the mark is not window-local.
But the region's overlay _is_ specific to the window where it is set.
Or are you saying it isn't the region that is highlighted in the other
window?
Btw, we could decide that we don't care about this quirk: it's a
pretty rare and obscure use case.
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#9609: Excessive transient region highlighting with highlight-nonselected-windows
2021-06-03 7:25 ` Eli Zaretskii
@ 2021-06-03 20:20 ` Juri Linkov
2021-06-04 9:18 ` martin rudalics
0 siblings, 1 reply; 9+ messages in thread
From: Juri Linkov @ 2021-06-03 20:20 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: rgm, larsi, 9609
>> > emacs -Q --eval '(progn (setq highlight-nonselected-windows t) (transient-mark-mode -1))'
>> > C-x 2
>> > Click and hold the mouse button on some character
>>
>> The problem is that currently the mark is not window-local.
>
> But the region's overlay _is_ specific to the window where it is set.
> Or are you saying it isn't the region that is highlighted in the other
> window?
The region is activated in both windows of the same buffer.
I thought the problem is here.
> Btw, we could decide that we don't care about this quirk: it's a
> pretty rare and obscure use case.
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#9609: Excessive transient region highlighting with highlight-nonselected-windows
2021-06-03 20:20 ` Juri Linkov
@ 2021-06-04 9:18 ` martin rudalics
2021-06-04 16:35 ` Juri Linkov
0 siblings, 1 reply; 9+ messages in thread
From: martin rudalics @ 2021-06-04 9:18 UTC (permalink / raw)
To: Juri Linkov, Eli Zaretskii; +Cc: rgm, larsi, 9609
>> But the region's overlay _is_ specific to the window where it is set.
>> Or are you saying it isn't the region that is highlighted in the other
>> window?
>
> The region is activated in both windows of the same buffer.
> I thought the problem is here.
What is the region in a non-selected window when point of that window's
buffer and point of that window differ?
martin
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#9609: Excessive transient region highlighting with highlight-nonselected-windows
2021-06-04 9:18 ` martin rudalics
@ 2021-06-04 16:35 ` Juri Linkov
0 siblings, 0 replies; 9+ messages in thread
From: Juri Linkov @ 2021-06-04 16:35 UTC (permalink / raw)
To: martin rudalics; +Cc: rgm, larsi, 9609
>>> But the region's overlay _is_ specific to the window where it is set.
>>> Or are you saying it isn't the region that is highlighted in the other
>>> window?
>>
>> The region is activated in both windows of the same buffer.
>> I thought the problem is here.
>
> What is the region in a non-selected window when point of that window's
> buffer and point of that window differ?
After setting the mark in the selected window,
the region is activated in the selected window between the mark and current point,
and also the region is activated in the non-selected window
between the same mark and window-point of the non-selected window.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2021-06-04 16:35 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-27 1:42 bug#9609: Excessive transient region highlighting with highlight-nonselected-windows Glenn Morris
2021-06-02 7:48 ` Lars Ingebrigtsen
2021-06-02 12:43 ` Eli Zaretskii
2021-06-02 13:34 ` Eli Zaretskii
2021-06-02 22:02 ` Juri Linkov
2021-06-03 7:25 ` Eli Zaretskii
2021-06-03 20:20 ` Juri Linkov
2021-06-04 9:18 ` martin rudalics
2021-06-04 16:35 ` Juri Linkov
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).