[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/auto-dim-other-buffers 31c13e7ed8 45/82: Use ‘window-buff
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/auto-dim-other-buffers 31c13e7ed8 45/82: Use ‘window-buffer’ instead of ‘current-buffer’ |
Date: |
Mon, 12 Dec 2022 20:58:42 -0500 (EST) |
branch: elpa/auto-dim-other-buffers
commit 31c13e7ed87dd862c73b836d11c127164edb1458
Author: Michal Nazarewicz <mina86@mina86.com>
Commit: Michal Nazarewicz <mina86@mina86.com>
Use ‘window-buffer’ instead of ‘current-buffer’
Current buffer is not the one that user sees and commands are sent to but
rather it’s a buffer shown in ‘selected-window’. ‘window-buffer’ returns
that.
Fixes: https://github.com/mina86/auto-dim-other-buffers.el/issues/10
---
auto-dim-other-buffers.el | 36 ++++++++++++++++--------------------
1 file changed, 16 insertions(+), 20 deletions(-)
diff --git a/auto-dim-other-buffers.el b/auto-dim-other-buffers.el
index ad987bd7c4..64593876e7 100644
--- a/auto-dim-other-buffers.el
+++ b/auto-dim-other-buffers.el
@@ -64,7 +64,7 @@
:group 'auto-dim-other-buffers)
(defvar adob--last-buffer nil
- "Buffer we were before command finished.")
+ "Selected buffer before command finished.")
(defun adob--ignore-buffer (buffer)
"Return whether to ignore BUFFER and do not affect its state.
@@ -88,22 +88,20 @@ Currently only mini buffer and echo areas are ignored."
(defun adob--post-command-hook ()
"If buffer has changed, dim the last one and undim the new one."
- ;; if we haven't switched buffers, do nothing
- (unless (eq (current-buffer) 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.
- (and (buffer-live-p adob--last-buffer)
- (not (adob--ignore-buffer adob--last-buffer))
- (with-current-buffer adob--last-buffer
- (adob--dim-buffer t)))
- ;; now, restore the current buffer, and undim it.
- (adob--dim-buffer nil)
- (setq adob--last-buffer (current-buffer))))
-
-(defun adob--after-change-major-mode-hook ()
- "Dim or undim a new buffer if a new window, like help window, has popped up."
- (adob--dim-buffer (not (eq (current-buffer) (window-buffer)))))
+ (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.
+ (and (buffer-live-p adob--last-buffer)
+ (not (adob--ignore-buffer adob--last-buffer))
+ (with-current-buffer adob--last-buffer
+ (adob--dim-buffer t)))
+ ;; now, restore the selected buffer, and undim it.
+ (with-current-buffer buf
+ (adob--dim-buffer nil))
+ (setq adob--last-buffer buf))))
(defun adob--focus-out-hook ()
"Dim all buffers if `auto-dim-other-buffers-dim-on-focus-out'."
@@ -131,9 +129,7 @@ function."
(dolist (args
'((post-command-hook adob--post-command-hook)
(focus-out-hook adob--focus-out-hook)
- (focus-in-hook adob--focus-in-hook)
- (after-change-major-mode-hook adob--after-change-major-mode-hook)
- (next-error-hook adob--after-change-major-mode-hook)))
+ (focus-in-hook adob--focus-in-hook)))
(apply callback args)))
;;;###autoload
- [nongnu] elpa/auto-dim-other-buffers 4cc1e1bb08 55/82: Add version of the dim face for light background, (continued)
- [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
- [nongnu] elpa/auto-dim-other-buffers af8eec9ec2 62/82: Prefer ‘window-buffer’ to ‘current-buffer’, ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers 4d6e644340 03/82: customizable face, ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers d2039c43af 08/82: upgrade the version based on how efficient it is now :D, ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers 5c793ea235 14/82: better readme, ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers 0bf0800bb8 07/82: dont try to set face on dead buffers, ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers d4f5508b4e 30/82: Bumped version to 1.5 and updated docstrings and comments., ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers 475321c845 35/82: Refactor `adob--dim-buffer' to check `dim' only once, ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers b797afadb4 44/82: s/it’s/its/, ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers 31c13e7ed8 45/82: Use ‘window-buffer’ instead of ‘current-buffer’,
ELPA Syncer <=
- [nongnu] elpa/auto-dim-other-buffers 90f6a6f0fb 49/82: Bump Version in comment, ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers 53652211c1 53/82: Add MELPA badge to README, ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers bc36211be2 63/82: Dim buffers appearing in non-selected windows, ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers 69d369e884 75/82: Fix minor typos and small refactor making use of ‘dolist`, ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers e20bc722d6 02/82: that didnt help..., ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers 244c979b67 25/82: after-change-major-mode-hook on next-error-hook, ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers 37085cf479 28/82: Consistently use “buffers” in function names, not “windows”., ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers 2424476114 18/82: fix some stuff, ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers db5411dd17 23/82: Fix compiler warning by defining the variable, ELPA Syncer, 2022/12/12
- [nongnu] elpa/auto-dim-other-buffers 02ae62c5ab 37/82: Remove pre command hook, ELPA Syncer, 2022/12/12