From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#56662: 29.0.50; Funny region highlights when highlight-nonselected-windows is t Date: Wed, 20 Jul 2022 21:05:04 +0300 Organization: LINKOV.NET Message-ID: <86wnc7bqy7.fsf@mail.linkov.net> References: <87bktk585s.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40384"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) Cc: 56662@debbugs.gnu.org To: Visuwesh Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jul 20 20:09:12 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oEE8G-000AJ1-Mj for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 20 Jul 2022 20:09:12 +0200 Original-Received: from localhost ([::1]:55848 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oEE8E-0001F0-Te for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 20 Jul 2022 14:09:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45424) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oEE87-0001Dt-6K for bug-gnu-emacs@gnu.org; Wed, 20 Jul 2022 14:09:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:32832) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oEE86-0007Nu-UQ for bug-gnu-emacs@gnu.org; Wed, 20 Jul 2022 14:09:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oEE86-00030l-RB for bug-gnu-emacs@gnu.org; Wed, 20 Jul 2022 14:09:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 20 Jul 2022 18:09:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 56662 X-GNU-PR-Package: emacs Original-Received: via spool by 56662-submit@debbugs.gnu.org id=B56662.165834050711516 (code B ref 56662); Wed, 20 Jul 2022 18:09:02 +0000 Original-Received: (at 56662) by debbugs.gnu.org; 20 Jul 2022 18:08:27 +0000 Original-Received: from localhost ([127.0.0.1]:58822 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oEE7X-0002zg-27 for submit@debbugs.gnu.org; Wed, 20 Jul 2022 14:08:27 -0400 Original-Received: from relay9-d.mail.gandi.net ([217.70.183.199]:38189) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oEE7T-0002zD-Dt for 56662@debbugs.gnu.org; Wed, 20 Jul 2022 14:08:25 -0400 Original-Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id 9B0DBFF805; Wed, 20 Jul 2022 18:08:14 +0000 (UTC) In-Reply-To: <87bktk585s.fsf@gmail.com> (Visuwesh's message of "Wed, 20 Jul 2022 17:05:11 +0530") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:237517 Archived-At: > 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.