[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/auto-dim-other-buffers 62c936d502 78/82: Fix buffer undimm
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/auto-dim-other-buffers 62c936d502 78/82: Fix buffer undimming when local variables are killed |
Date: |
Mon, 12 Dec 2022 20:58:47 -0500 (EST) |
branch: elpa/auto-dim-other-buffers
commit 62c936d502f35d168b9e59a66c994d74a62ad2cf
Author: Michal Nazarewicz <mina86@mina86.com>
Commit: Michal Nazarewicz <mina86@mina86.com>
Fix buffer undimming when local variables are killed
The ‘kill-all-local-variables’ function kills all local variables and
face remapping. This is a problem because adob is never notified of
the face remapping being removed. If the buffer is not selected but
visible the result is that it becomes undimmed.
To reproduce the issue evaluate from a buffer using ‘eval-last-sexp’
(C-x C-e) or equivalent. Do not use interactive ‘eval-expression’.
(with-current-buffer (get-buffer "*adob-test*")
(kill-all-local-variables))
Now set up at lest two windows one of which showing ‘*adob-test*’
buffer. Select another window (‘*adob-test*’ should dim) and evaluate
the above again. The test buffer should remain dimmed but becomes
undimmed even though it’s not the selected window.
There’s no hook that is called after the removal of face remapping and
marking ‘face-remapping-alist’ as a ‘permanent-local’ doesn’t sound
like a good idea so to fix the issue I’ve ended up adding an advice
around the ‘kill-all-local-variables’ function.
---
auto-dim-other-buffers.el | 25 +++++++++++++++++++++----
1 file changed, 21 insertions(+), 4 deletions(-)
diff --git a/auto-dim-other-buffers.el b/auto-dim-other-buffers.el
index 79f22bdea1..f7fc4a5036 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.4
+;; Version: 2.0.5
;; This file is not part of GNU Emacs.
@@ -116,6 +116,7 @@ dimmed. In addition to that, outside of adow-mode (see
(defvar-local adob--face-mode-remapping nil
"Current face remapping cookie for `auto-dim-other-buffers-mode'.")
+(put 'adob--face-mode-remapping 'permanent-local nil)
(defun adob--remap-face (buffer object)
"Make sure face remapping is active in BUFFER unless its never-dim.
@@ -142,6 +143,17 @@ Return non-nil if remapping has been added to BUFFER."
(force-window-update object)
wants)))
+(defun adob--kill-all-local-variables-advice (kill)
+ "Restores face remapping after killing all local variables.
+This is intended as an advice around ‘kill-all-local-variables’
+function which removes all buffer face remapping which is
+something we don’t want."
+ (unless (prog1 (not adob--face-mode-remapping)
+ (funcall kill))
+ (setq adob--face-mode-remapping
+ (face-remap-add-relative 'default adob--remap-face))
+ nil))
+
(defun adob--unmap-face (buffer object)
"Make sure face remapping is inactive in BUFFER.
@@ -364,9 +376,14 @@ behaviour is where the mode gets its name from."
(save-current-buffer
(if auto-dim-other-buffers-mode
- ;; Dim all except for selected buffer.
- (adob--initialize)
-
+ (progn
+ (advice-add #'kill-all-local-variables :around
+ #'adob--kill-all-local-variables-advice)
+ ;; Dim all except for selected buffer.
+ (adob--initialize))
+
+ (advice-remove #'kill-all-local-variables
+ #'adob--kill-all-local-variables-advice)
;; Clean up by removing all face remaps.
(setq adob--last-buffer nil
adob--last-window nil)
- [nongnu] elpa/auto-dim-other-buffers 7f332de332 17/82: oops, (continued)
- [nongnu] elpa/auto-dim-other-buffers 7f332de332 17/82: oops, ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers 7502775f38 29/82: Use a shorter lighter for the mode., ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers b1562a1200 38/82: Wrap `adob--dim-all-buffers' into a lambda when adding as a hook, ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers b599ff6db9 57/82: Better clean up when disabling the mode; remove arg from dim-all-buffers, ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers 53dd9b68fb 59/82: Ignore all hidden buffers, ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers 6c8804c7d2 58/82: Remove mode’s lighter, ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers b3999f9728 48/82: Fix missing closing paren, ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers 0fba90826b 69/82: Sneakily link to phrxmd’s video demonstrating the mode, ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers 774fe859f8 64/82: Fix ‘auto-dim-other-buffers-dim-on-switch-to-minibuffer’ behaviour, ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers f712de72d4 67/82: Optimise ‘never dim’ check, ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers 62c936d502 78/82: Fix buffer undimming when local variables are killed,
ELPA Syncer <=