branch: elpa/auto-dim-other-buffers commit 6ebff3681fcae32ea3c762a1741ec62c3aa1180f Author: Michal Nazarewicz <min...@mina86.com> Commit: Michal Nazarewicz <min...@mina86.com>
Don’t dim already dimmed buffer ‘face-remap-add-relative’ may be a rather expensive operation. This becomes a problem in ‘adob--focus-out-hook’ which dims *all* existing buffers. Change ‘adob--dim-buffer’ so that it does not needlessly dim already dimmed buffer. This fixes https://github.com/mina86/auto-dim-other-buffers.el/issues/13 --- auto-dim-other-buffers.el | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/auto-dim-other-buffers.el b/auto-dim-other-buffers.el index 64593876e7..53b202aaff 100644 --- a/auto-dim-other-buffers.el +++ b/auto-dim-other-buffers.el @@ -74,17 +74,20 @@ Currently only mini buffer and echo areas are ignored." (string-match "^ \\*Echo Area" (buffer-name buffer)))) ;; current remapping cookie for adob -(defvar-local adob--face-mode-remapping nil) +(defvar-local adob--face-mode-remapping nil + "Current remapping cookie for `auto-dim-other-buffers-mode'.") (defun adob--dim-buffer (dim) "Dim (if DIM is non-nil) or undim (otherwise) current buffer." - (if dim - (setq adob--face-mode-remapping - (face-remap-add-relative 'default 'auto-dim-other-buffers-face)) - (when adob--face-mode-remapping - (face-remap-remove-relative adob--face-mode-remapping) - (setq adob--face-mode-remapping nil))) - (force-window-update (current-buffer))) + (when (cond ((and dim (not adob--face-mode-remapping)) + (setq adob--face-mode-remapping + (face-remap-add-relative 'default + 'auto-dim-other-buffers-face))) + ((and (not dim) adob--face-mode-remapping) + (face-remap-remove-relative adob--face-mode-remapping) + (setq adob--face-mode-remapping nil) + t)) + (force-window-update (current-buffer))) (defun adob--post-command-hook () "If buffer has changed, dim the last one and undim the new one."