[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/auto-dim-other-buffers e64bdbdb0a 34/82: Use `face-remap-a
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/auto-dim-other-buffers e64bdbdb0a 34/82: Use `face-remap-add-relative' to not interfere with `buffer-face-mode' |
Date: |
Mon, 12 Dec 2022 20:58:41 -0500 (EST) |
branch: elpa/auto-dim-other-buffers
commit e64bdbdb0a680c32f794d5e0234711569c22f170
Author: Anders Johansson <mejlaandersj@gmail.com>
Commit: Michal Nazarewicz <mina86@mina86.com>
Use `face-remap-add-relative' to not interfere with `buffer-face-mode'
`buffer-face-set' overrides and disables any faces used by
`buffer-face-mode' (or derived mode like `variable-pitch-mode').
Using `face-remap-(add|remove)-relative' allows us to add the
`auto-dim-other-buffers-face' alongside any faces used by
`buffer-face-mode'.
[mina86@mina86.com: checkdoc'ed, untabified and renamed
`adob-face-mode-remapping' to `adob--face-mode-remapping']
---
auto-dim-other-buffers.el | 40 +++++++++++++++++++++-------------------
1 file changed, 21 insertions(+), 19 deletions(-)
diff --git a/auto-dim-other-buffers.el b/auto-dim-other-buffers.el
index 28b8dfbc99..1df1bfb741 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.5
+;; Version: 1.6
;; This file is not part of GNU Emacs.
@@ -68,6 +68,18 @@ Currently only mini buffer and echo areas are ignored."
(minibufferp buffer)
(string-match "^ \\*Echo Area" (buffer-name buffer))))
+;; current remapping cookie for adob
+(defvar-local adob--face-mode-remapping nil)
+
+(defun adob--dim-buffer (dim)
+ "Dim (if DIM is non-nil) or undim (otherwise) current buffer."
+ (when (and (not dim) adob--face-mode-remapping)
+ (face-remap-remove-relative adob--face-mode-remapping))
+ (when dim
+ (setq adob--face-mode-remapping
+ (face-remap-add-relative 'default 'auto-dim-other-buffers-face)))
+ (force-window-update (current-buffer)))
+
(defun adob--pre-command-hook ()
"Record current buffer before the command is run."
(setq adob--last-buffer (current-buffer)))
@@ -83,33 +95,23 @@ Currently only mini buffer and echo areas are ignored."
(and (buffer-live-p adob--last-buffer)
(not (adob--ignore-buffer adob--last-buffer))
(with-current-buffer adob--last-buffer
- (buffer-face-set 'auto-dim-other-buffers-face)))
-
+ (adob--dim-buffer t)))
;; now, restore the current buffer, and undim it.
- (buffer-face-set nil)))
+ (adob--dim-buffer nil)))
(defun adob--after-change-major-mode-hook ()
"Dim or undim a new buffer if a new window, like help window, has popped up."
- (buffer-face-set (unless (eq (current-buffer) (window-buffer))
- 'auto-dim-other-buffers-face)))
+ (adob--dim-buffer (not (eq (current-buffer) (window-buffer)))))
-(defun adob--set-face-on-all-buffers (face)
- "Set FACE on all buffers which are not to be ignored.
+(defun adob--dim-all-buffers (dim)
+ "Dim (if DIM is non-nil) or undim all buffers which are not to be ignored.
Whether buffer should be ignored is determined by `adob--ignore-buffer'
function."
(save-current-buffer
(dolist (buffer (buffer-list))
(unless (adob--ignore-buffer buffer)
(set-buffer buffer)
- (buffer-face-set face)))))
-
-(defun adob--undim-all-buffers ()
- "Undim all buffers."
- (adob--set-face-on-all-buffers nil))
-
-(defun adob--dim-all-buffers ()
- "Dim all buffers."
- (adob--set-face-on-all-buffers 'auto-dim-other-buffers-face))
+ (adob--dim-buffer dim)))))
(defun turn-off-auto-dim-other-buffers ()
"Turn `auto-dim-other-buffers-mode' off."
@@ -120,12 +122,12 @@ function."
(remove-hook 'after-change-major-mode-hook
'adob--after-change-major-mode-hook)
(remove-hook 'next-error-hook 'adob--after-change-major-mode-hook)
- (adob--undim-all-buffers))
+ (adob--dim-all-buffers nil))
(defun turn-on-auto-dim-other-buffers ()
"Turn `auto-dim-other-buffers-mode' on."
(setq adob--last-buffer nil)
- (adob--dim-all-buffers)
+ (adob--dim-all-buffers t)
(add-hook 'pre-command-hook 'adob--pre-command-hook)
(add-hook 'post-command-hook 'adob--post-command-hook)
(add-hook 'focus-out-hook 'adob--dim-all-buffers)
- [nongnu] branch elpa/auto-dim-other-buffers created (now 33b5f88b79), ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers 890051374f 01/82: first, ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers 16db9f4942 06/82: MUCH more efficient: only changes faces for 2 buffers max, and only when necessary, ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers e7fcc5336c 13/82: less ceremonial readme?, ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers 6804fde17b 11/82: screenshot, ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers fb7ea24922 26/82: dimming/undimming when gaining/losing app focus, ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers e64bdbdb0a 34/82: Use `face-remap-add-relative' to not interfere with `buffer-face-mode',
ELPA Syncer <=
- [nongnu] elpa/auto-dim-other-buffers 6ebff3681f 46/82: Don’t dim already dimmed buffer, ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers e85510688d 19/82: duh, ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers c80b367dd0 22/82: Leave echo area alone, ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers bea02696f0 21/82: Use save-current-buffer and with-current-buffer, ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers a969ff4e0e 16/82: minor mode, ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers cfab476572 36/82: Move hooks adding/removing to separate function, ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers cedb4c4895 47/82: Use ‘buffer-list-update-hook’ instead of ‘post-command-hook’, ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers 44b8965cff 32/82: Specify the license, GPL-3.0+ is used., ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers 4cc1e1bb08 55/82: Add version of the dim face for light background, ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers 8d7ef78b4a 65/82: Prefer ‘after-focus-change-function’, ELPA Syncer, 2022/12/12