[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/auto-dim-other-buffers 82626612bd 71/82: Handle window and
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/auto-dim-other-buffers 82626612bd 71/82: Handle window and buffer switching at the same time |
Date: |
Mon, 12 Dec 2022 20:58:46 -0500 (EST) |
branch: elpa/auto-dim-other-buffers
commit 82626612bd1c4c5f36d110f6bff3f93c33b4149e
Author: Michal Nazarewicz <mina86@mina86.com>
Commit: Michal Nazarewicz <mina86@mina86.com>
Handle window and buffer switching at the same time
When a buffer is killed or buried at the same time as when window is
changed, the buffer shown in the previously selected window may remain
undimmed in Emacs prior to version 27.
For example, having two windows run ‘M-x describe-function RET defun
RET’ (which will show help in one of the windows), navigate to the
window showing *Help* buffer and quit the help by pressing ‘q’. This
will select the other window and leave the new buffer in the remaining
window won’t be dimmed.
This happens because when we update state of buffers, we undim the
newly selected buffer and dim the old buffer. Unfortunately, the old
buffer is no longer the one shown in the old window so that latter
operation doesn’t do anything useful.
Change the code to keep track of the last window (just like it keeps
track of last buffer) even outside of adow-mode. With that new
information, whenever window changes, make sure that whatever is
displayed in the old window is dimmed.
Issue: https://github.com/mina86/auto-dim-other-buffers.el/issues/22
---
auto-dim-other-buffers.el | 54 ++++++++++++++++++++++++++++++-----------------
1 file changed, 35 insertions(+), 19 deletions(-)
diff --git a/auto-dim-other-buffers.el b/auto-dim-other-buffers.el
index e79bf1c0d6..bbacc203cd 100644
--- a/auto-dim-other-buffers.el
+++ b/auto-dim-other-buffers.el
@@ -2,7 +2,7 @@
;; Author: Michal Nazarewicz <mina86@mina86.com>
;; Maintainer: Michal Nazarewicz <mina86@mina86.com>
;; URL: https://github.com/mina86/auto-dim-other-buffers.el
-;; Version: 2.0.1
+;; Version: 2.0.2
;; This file is not part of GNU Emacs.
@@ -93,10 +93,9 @@ Depending on whether Emacs supports :filtered predicate, this
will or will not use it. See ‘adob--adow-mode’.")
(defvar adob--last-buffer nil
- "Last selected buffer which, i.e. buffer which is currently not dimmed.")
+ "Last selected buffer, i.e. buffer which is currently not dimmed.")
(defvar adob--last-window nil
- "Last selected buffer which, i.e. window which is currently not dimmed.
-This is only used in adow mode (i.e. if ‘adob--adow-mode’).")
+ "Last selected window, i.e. window which is currently not dimmed.")
(defun adob--never-dim-p (buffer)
"Return whether to never dim BUFFER.
@@ -170,9 +169,11 @@ Dim previously selected window if selection has changed."
(let* ((wnd (selected-window))
(buf (window-buffer wnd)))
- ;; If window has changed, update old and new window’s parameters.
- (when (and adob--adow-mode
- (not (eq wnd adob--last-window)))
+ (cond
+ ((eq wnd adob--last-window))
+ (adob--adow-mode
+ ;; adow-mode is active and window has changed. Update the adob--dim
+ ;; parameter accordingly.
(when (and (window-live-p adob--last-window)
(not (window-minibuffer-p adob--last-window)))
(set-window-parameter adob--last-window 'adob--dim t)
@@ -181,6 +182,20 @@ Dim previously selected window if selection has changed."
(unless (window-minibuffer-p adob--last-window)
(set-window-parameter adob--last-window 'adob--dim nil)
(force-window-update adob--last-window)))
+ (t
+ ;; Window has changed but adow-mode is not active. Make sure buffer
+ ;; displayed in the old window is dimmed. This is necessary because
+ ;; a command (e.g. ‘quite-window’) could change to a different window
+ ;; while at the same time changing buffer in the old window. In this
+ ;; scenario, we’re never dimming the buffer in the old window.
+ (and (window-live-p adob--last-window)
+ (not (window-minibuffer-p adob--last-window))
+ (let ((old-buf (window-buffer adob--last-window)))
+ (unless (or (eq old-buf buf)
+ (eq old-buf adob--last-buffer))
+ (adob--dim-buffer old-buf)
+ (force-window-update adob--last-window))))
+ (setq adob--last-window wnd)))
;; If buffer has changed, update their status.
(unless (eq buf adob--last-buffer)
@@ -235,16 +250,17 @@ Otherwise, if a new buffer is displayed somewhere, dim
it."
"Dim all buffers if `auto-dim-other-buffers-dim-on-focus-out'."
(cond ((not (and auto-dim-other-buffers-dim-on-focus-out
(buffer-live-p adob--last-buffer))))
- ((and (window-live-p adob--last-window)
- (not (window-minibuffer-p adob--last-window)))
- (set-window-parameter adob--last-window 'adob--dim t)
- (force-window-update adob--last-window)
- (setq adob--last-buffer nil
- adob--last-window nil))
- ((not (or adob--adow-mode
- (adob--never-dim-p adob--last-buffer)))
- (save-current-buffer (adob--dim-buffer adob--last-buffer))
- (setq adob--last-buffer nil))))
+ (adob--adow-mode
+ (when (and (window-live-p adob--last-window)
+ (not (window-minibuffer-p adob--last-window)))
+ (set-window-parameter adob--last-window 'adob--dim t)
+ (force-window-update adob--last-window)
+ (setq adob--last-buffer nil
+ adob--last-window nil)))
+ ((not (adob--never-dim-p adob--last-buffer))
+ (save-current-buffer (adob--dim-buffer adob--last-buffer))
+ (setq adob--last-buffer nil
+ adob--last-window nil))))
(defun adob--focus-change-hook ()
"Based on focus status of selected frame dim or undim selected buffer.
@@ -295,8 +311,8 @@ behaviour is where the mode gets its name from."
;; running in adow mode, don’t dim hidden buffers either (most notably
;; we care about Minibuffer and Echo Area buffers).
(progn
- (setq adob--last-buffer (window-buffer)
- adob--last-window (if adob--adow-mode (selected-window)))
+ (setq adob--last-window (selected-window)
+ adob--last-buffer (window-buffer adob--last-window))
(dolist (buffer (buffer-list))
(when (or adob--adow-mode
(not (or (eq buffer adob--last-buffer)
- [nongnu] elpa/auto-dim-other-buffers e20bc722d6 02/82: that didnt help..., (continued)
- [nongnu] elpa/auto-dim-other-buffers e20bc722d6 02/82: that didnt help..., ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers 244c979b67 25/82: after-change-major-mode-hook on next-error-hook, ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers 37085cf479 28/82: Consistently use “buffers” in function names, not “windows”., ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers 2424476114 18/82: fix some stuff, ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers db5411dd17 23/82: Fix compiler warning by defining the variable, ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers 02ae62c5ab 37/82: Remove pre command hook, ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers 8b909cb210 41/82: fix change major mode on next-error-hook, ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers d1ee176652 54/82: Update screenshot; make it animated, ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers ec74b4803a 56/82: Split ‘adob--dim-buffer’ into two no-argument functions, ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers 0c15c0d3a4 52/82: s/adob--ignore-buffer/adob--never-dim-p/, ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers 82626612bd 71/82: Handle window and buffer switching at the same time,
ELPA Syncer <=
- [nongnu] elpa/auto-dim-other-buffers 2a19931b27 80/82: Introduce ‘auto-dim-other-buffers-hide-face’ for hidden dimmed text, ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers f0d48d94c3 77/82: Introduce ‘auto-dim-other-buffers-never-dim-buffer-functions’, ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers 33b5f88b79 82/82: Correctly handle optional kill-all-local-variables argument in advice, ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers 9f768ddd9a 76/82: Debounce focus-change events, ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers 07d906f0f0 04/82: useless extra thing, ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers e473ef45ea 05/82: set buffer faces MUCH less often, ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers 7ed6580b7d 12/82: update sshot, ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers e93f115d32 09/82: comments and fix, ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers b236157a77 15/82: uhh, ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers 8f58e3f7fe 27/82: Use “adob--” as a prefix for private stuff., ELPA Syncer, 2022/12/12