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 efd617c999 60/82: Make sure current


From: ELPA Syncer
Subject: [nongnu] elpa/auto-dim-other-buffers efd617c999 60/82: Make sure current buffer is not dimmed when the mode is enabled
Date: Mon, 12 Dec 2022 20:58:44 -0500 (EST)

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

    Make sure current buffer is not dimmed when the mode is enabled
    
    Procedure for enabling the mode was to dim all buffers including the
    current one.  This left user in an unexpected state which normally
    should not occur.  (Switching buffers or windows would rectify it but
    that situation was nonetheless a bug).
    
    Fix the issue by making sure current buffer is not dimmed during
    mode’s initialisation.
---
 auto-dim-other-buffers.el | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/auto-dim-other-buffers.el b/auto-dim-other-buffers.el
index 0fe7f66344..8679d120a4 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.8.3
+;; Version: 1.9
 
 ;; This file is not part of GNU Emacs.
 
@@ -126,13 +126,15 @@ Currently only mini buffer and echo areas are ignored."
     (adob--undim-buffer)
     (setq adob--last-buffer (current-buffer))))
 
-(defun adob--dim-all-buffers ()
-  "Dim all buffers which are not to be ignored.
-Whether buffer should be ignored is determined by `adob--never-dim-p'
-function."
+(defun adob--dim-all-buffers (&optional except-for)
+  "Dim all buffers which except for EXCEPT-FOR and any ignored buffers.
+If EXCEPT-FOR is non-nil, it specifies buffer which should not be
+affected.  Similarly, any buffers for which `adob--never-dim-p'
+function returns non-nil won’t be touched either."
   (save-current-buffer
     (dolist (buffer (buffer-list))
-      (unless (adob--never-dim-p buffer)
+      (unless (or (eq buffer except-for)
+                  (adob--never-dim-p buffer))
         (set-buffer buffer)
         (adob--dim-buffer)))))
 
@@ -148,11 +150,11 @@ function."
 (define-minor-mode auto-dim-other-buffers-mode
   "Visually makes non-current buffers less prominent"
   :global t
-  (setq adob--last-buffer nil)
   (if auto-dim-other-buffers-mode
       (progn
-        (adob--dim-all-buffers)
+        (adob--dim-all-buffers (setq adob--last-buffer (current-buffer)))
         (adob--hooks 'add-hook))
+    (setq adob--last-buffer nil)
     (adob--hooks 'remove-hook)
     (save-current-buffer
       (dolist (buffer (buffer-list))



reply via email to

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