From: Juri Linkov <juri@linkov.net>
To: Eli Zaretskii <eliz@gnu.org>
Cc: rgm@gnu.org, larsi@gnus.org, 9609@debbugs.gnu.org
Subject: bug#9609: Excessive transient region highlighting with highlight-nonselected-windows
Date: Thu, 03 Jun 2021 01:02:25 +0300 [thread overview]
Message-ID: <87lf7sc4cu.fsf@mail.linkov.net> (raw)
In-Reply-To: <83pmx4xudf.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 02 Jun 2021 16:34:52 +0300")
>> > > 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
next prev parent reply other threads:[~2021-06-02 22:02 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87lf7sc4cu.fsf@mail.linkov.net \
--to=juri@linkov.net \
--cc=9609@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=larsi@gnus.org \
--cc=rgm@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).