emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/auto-dim-other-buffers 087baafa08 51/82: Move minibuffer


From: ELPA Syncer
Subject: [nongnu] elpa/auto-dim-other-buffers 087baafa08 51/82: Move minibuffer check to the beginning of ‘adob--buffer-list-update-hook’
Date: Mon, 12 Dec 2022 20:58:43 -0500 (EST)

branch: elpa/auto-dim-other-buffers
commit 087baafa0868dc24233845914c09398e6a3d35d5
Author: Michal Nazarewicz <mina86@mina86.com>
Commit: Michal Nazarewicz <mina86@mina86.com>

    Move minibuffer check to the beginning of ‘adob--buffer-list-update-hook’
    
    With ‘auto-dim-other-buffers-dim-on-switch-to-minibuffer’ option disabled,
    if user switches from buffer α to minibuffer and then to buffer β (e.g.
    by invoking ‘other-window’), buffer α will remain undimmed even though
    β becomes the current one.
    
    This is because ‘adob--last-buffer’ is updated to point to minibuffer
    even though α remains undimmed.
    
    Move the minibuffer check to the top of ‘adob--buffer-list-update-hook’
    function so that switching to minibuffer becomes a noöp, i.e. the code
    behaves as if the old buffer was still active.
    
    Fixes: https://github.com/mina86/auto-dim-other-buffers.el/issues/14
    Fixes: https://github.com/mina86/auto-dim-other-buffers.el/pull/15
---
 auto-dim-other-buffers.el | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/auto-dim-other-buffers.el b/auto-dim-other-buffers.el
index 540bd75330..02f0f3f8a0 100644
--- a/auto-dim-other-buffers.el
+++ b/auto-dim-other-buffers.el
@@ -8,7 +8,7 @@
 ;;     Michal Nazarewicz <mina86@mina86.com>
 ;; Maintainer: Michal Nazarewicz <mina86@mina86.com>
 ;; URL: https://github.com/mina86/auto-dim-other-buffers.el
-;; Version: 1.7
+;; Version: 1.8
 
 ;; This file is not part of GNU Emacs.
 
@@ -96,22 +96,18 @@ Currently only mini buffer and echo areas are ignored."
 (defun adob--buffer-list-update-hook ()
   "If buffer has changed, dim the last one and undim the new one."
   (let ((buf (window-buffer)))
-    ;; if we haven't switched buffers, do nothing
-    (unless (eq buf adob--last-buffer)
-      ;; first, try to dim the last buffer.  if it's nil, then the
-      ;; feature was just turned on and all buffers are already
-      ;; dimmed. if it's just killed, don't try to set its face.
+    (when (and
+           ;; Don’t do anything if buffer didn’t changed.
+           (not (eq buf adob--last-buffer))
+           ;; If so configured, don’t dim when switching to minibuffer.
+           (or auto-dim-other-buffers-dim-on-switch-to-minibuffer
+               (not (minibufferp buf))))
+      ;; Dim last buffer if it’s live and not ignored.
       (and (buffer-live-p adob--last-buffer)
            (not (adob--ignore-buffer adob--last-buffer))
-           ;; By default, dim last buffer on switch to any other buffer. But if
-           ;; option is nil, then don't dim last buffer on switch to minibuffer
-           ;; or echo area.
-           (or auto-dim-other-buffers-dim-on-switch-to-minibuffer
-               (not (or (minibufferp (current-buffer))
-                        (string-match "^ \\*Echo Area" (buffer-name 
(current-buffer))))))
            (with-current-buffer adob--last-buffer
              (adob--dim-buffer t)))
-      ;; now, restore the selected buffer, and undim it.
+      ;; Undim the new buffer.
       (with-current-buffer buf
         (adob--dim-buffer nil))
       (setq adob--last-buffer buf))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]