unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: Visuwesh <visuweshm@gmail.com>
Cc: 56662@debbugs.gnu.org
Subject: bug#56662: 29.0.50; Funny region highlights when highlight-nonselected-windows is t
Date: Wed, 20 Jul 2022 21:05:04 +0300	[thread overview]
Message-ID: <86wnc7bqy7.fsf@mail.linkov.net> (raw)
In-Reply-To: <87bktk585s.fsf@gmail.com> (Visuwesh's message of "Wed, 20 Jul 2022 17:05:11 +0530")

> If two windows show a single buffer, then the region highlighting is
> strange in the non-selected window.  It is not hard to reproduce,
>
>     1. emacs -Q
>     2. Visit a longish file.
>     3. C-x 3 and scroll up in any of the window.
>     4. M-: (setq highlight-nonselected-windows t) RET.
>     5. Create an active region and compare the highlighting.

This is a long-standing problem.  I used to use a workaround:
https://lists.gnu.org/archive/html/emacs-devel/2018-09/msg00716.html
But it doesn't work correctly anymore.  Then tried to use advice since
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.

#+begin_src emacs-lisp
(defvar-local mark-active-window nil)

(advice-add 'activate-mark :after
            (lambda (&rest _args)
              (setq mark-active-window (selected-window)))
            '((name . mark-active-window)))

(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))))

(add-hook 'pre-redisplay-functions #'redisplay--update-mark-active-window)
#+end_src

But still a 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.





      parent reply	other threads:[~2022-07-20 18:05 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-20 11:35 bug#56662: 29.0.50; Funny region highlights when highlight-nonselected-windows is t Visuwesh
2022-07-20 12:38 ` Eli Zaretskii
2022-07-20 12:43   ` Visuwesh
2022-07-20 12:48     ` Eli Zaretskii
2022-07-20 20:16       ` Kévin Le Gouguec
2022-07-21  6:22         ` Eli Zaretskii
2022-07-21 11:22           ` Visuwesh
2022-07-21 12:19             ` Eli Zaretskii
2022-07-21 12:32               ` Visuwesh
2022-07-21 12:39                 ` Eli Zaretskii
2022-07-21 14:35                   ` Visuwesh
2022-07-21 15:54                     ` Eli Zaretskii
2022-07-21 16:13                       ` Visuwesh
2022-07-21 16:34                         ` Eli Zaretskii
2022-07-21 17:00                           ` Visuwesh
2022-07-21 22:14                             ` Kévin Le Gouguec
2022-07-24 16:41                               ` Juri Linkov
2022-07-24 17:32                                 ` Eli Zaretskii
2022-07-23  7:09                             ` Lars Ingebrigtsen
2022-07-23  7:08             ` Lars Ingebrigtsen
2022-07-20 18:05 ` Juri Linkov [this message]

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=86wnc7bqy7.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=56662@debbugs.gnu.org \
    --cc=visuweshm@gmail.com \
    /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).