unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] update the behavior of highlight-nonselected-windows
@ 2015-03-31 11:53 Oleh Krehel
  2015-03-31 12:52 ` Stefan Monnier
  2015-03-31 12:59 ` Eli Zaretskii
  0 siblings, 2 replies; 3+ messages in thread
From: Oleh Krehel @ 2015-03-31 11:53 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 336 bytes --]

Hi all,

I like to use the `highlight-nonselected-windows' option, but it
becomes very annoying for the case when I have the same buffer in a
few windows.

Please check the attached patch. Maybe there's a better way to solve
the problem, or maybe this one is good enough. If there aren't
objections, I'll apply this one.

regards,
Oleh

[-- Attachment #2: 0001-Ignore-highlight-nonselected-windows-for-same-buffer.patch --]
[-- Type: text/x-patch, Size: 1482 bytes --]

From 6ba6216a5105a777f7e2f8128bcb9c0a77b6b2c4 Mon Sep 17 00:00:00 2001
From: Oleh Krehel <ohwoeowho@gmail.com>
Date: Tue, 31 Mar 2015 13:42:04 +0200
Subject: [PATCH] Ignore `highlight-nonselected-windows' for same buffer in two
 windows

* lisp/simple.el (redisplay--update-region-highlights): Update.

It looks really weird when the same buffer is opened in multiple
windows and `highlight-nonselected-windows' is t. Especially when the
mouse is pressed.
---
 lisp/simple.el | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/lisp/simple.el b/lisp/simple.el
index 5185607..ce6e24e 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -4955,7 +4955,13 @@ also checks the value of `use-empty-active-region'."
         (redisplay--update-region-highlight (selected-window))
       (unless (listp windows) (setq windows (window-list-1 nil nil t)))
       (if highlight-nonselected-windows
-          (mapc #'redisplay--update-region-highlight windows)
+          (mapc #'redisplay--update-region-highlight
+                (delq nil
+                      (mapcar (lambda (w)
+                                (unless (eq (window-buffer w)
+                                            (current-buffer))
+                                  w))
+                              windows)))
         (let ((msw (and (window-minibuffer-p) (minibuffer-selected-window))))
           (dolist (w windows)
             (if (or (eq w (selected-window)) (eq w msw))
-- 
1.8.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] update the behavior of highlight-nonselected-windows
  2015-03-31 11:53 [PATCH] update the behavior of highlight-nonselected-windows Oleh Krehel
@ 2015-03-31 12:52 ` Stefan Monnier
  2015-03-31 12:59 ` Eli Zaretskii
  1 sibling, 0 replies; 3+ messages in thread
From: Stefan Monnier @ 2015-03-31 12:52 UTC (permalink / raw)
  To: Oleh Krehel; +Cc: emacs-devel

> -          (mapc #'redisplay--update-region-highlight windows)
> +          (mapc #'redisplay--update-region-highlight
> +                (delq nil
> +                      (mapcar (lambda (w)
> +                                (unless (eq (window-buffer w)
> +                                            (current-buffer))
> +                                  w))
> +                              windows)))

I don't think depending on the value of `current-buffer' can be right.
More specifically, it will only do what (I think) you want in the case
where the buffer who's displayed in several windows (and has an active
region) happens to be the current buffer.

IIUC the problem that annoys you, it comes from the fact that the
region is defined to be "anything between point and mark" but point is
a per-window attribute while mark is a per-buffer attribute.

Maybe a way to solve this issue would be to keep track of the window in
which the mark was made active.  E.g. instead of setting mark-active to
t we'd set it to (selected-window).  And then we could change
redisplay--update-region-highlights to only highlight in the window
specified by mark-active.


        Stefan



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] update the behavior of highlight-nonselected-windows
  2015-03-31 11:53 [PATCH] update the behavior of highlight-nonselected-windows Oleh Krehel
  2015-03-31 12:52 ` Stefan Monnier
@ 2015-03-31 12:59 ` Eli Zaretskii
  1 sibling, 0 replies; 3+ messages in thread
From: Eli Zaretskii @ 2015-03-31 12:59 UTC (permalink / raw)
  To: Oleh Krehel; +Cc: emacs-devel

> Date: Tue, 31 Mar 2015 13:53:33 +0200
> From: Oleh Krehel <ohwoeowho@gmail.com>
> 
> I like to use the `highlight-nonselected-windows' option, but it
> becomes very annoying for the case when I have the same buffer in a
> few windows.
> 
> Please check the attached patch. Maybe there's a better way to solve
> the problem, or maybe this one is good enough. If there aren't
> objections, I'll apply this one.

Please don't redefine the semantics of the t value of
highlight-nonselected-windows.  That's an incompatible change.
Instead, please introduce a new value for the variable which would
have the effect you want, and leave t do what it does today.

(I agree with Stefan about the other comments.)

Thanks.



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-03-31 12:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-31 11:53 [PATCH] update the behavior of highlight-nonselected-windows Oleh Krehel
2015-03-31 12:52 ` Stefan Monnier
2015-03-31 12:59 ` Eli Zaretskii

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