[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/auto-dim-other-buffers cfab476572 36/82: Move hooks adding
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/auto-dim-other-buffers cfab476572 36/82: Move hooks adding/removing to separate function |
Date: |
Mon, 12 Dec 2022 20:58:41 -0500 (EST) |
branch: elpa/auto-dim-other-buffers
commit cfab4765728a8ca74c0c82a78df0dfecc7791228
Author: Michal Nazarewicz <mina86@mina86.com>
Commit: Michal Nazarewicz <mina86@mina86.com>
Move hooks adding/removing to separate function
Both `turn-on-auto-dim-other-buffers' and `turn-off-…' had the full
list of hooks that adob used. Change those function so that the list
is now in a separate function – `adob--hooks' – which adds or removes
the hooks depending on the argument.
---
auto-dim-other-buffers.el | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/auto-dim-other-buffers.el b/auto-dim-other-buffers.el
index d29b567e71..120e7d20fe 100644
--- a/auto-dim-other-buffers.el
+++ b/auto-dim-other-buffers.el
@@ -114,27 +114,27 @@ function."
(set-buffer buffer)
(adob--dim-buffer dim)))))
+(defun adob--hooks (callback)
+ "Add (if CALLBACK is `add-hook') or remove (if `remove-hook') adob hooks."
+ (dolist (args
+ '((pre-command-hook adob--pre-command-hook)
+ (post-command-hook adob--post-command-hook)
+ (focus-out-hook adob--dim-all-buffers)
+ (focus-in-hook adob--after-change-major-mode-hook)
+ (after-change-major-mode-hook adob--after-change-major-mode-hook)
+ (next-error-hook 'adob--after-change-major-mode-hook)))
+ (apply callback args)))
+
(defun turn-off-auto-dim-other-buffers ()
"Turn `auto-dim-other-buffers-mode' off."
- (remove-hook 'pre-command-hook 'adob--pre-command-hook)
- (remove-hook 'post-command-hook 'adob--post-command-hook)
- (remove-hook 'focus-out-hook 'adob--dim-all-buffers)
- (remove-hook 'focus-in-hook 'adob--after-change-major-mode-hook)
- (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--hooks 'remove-hook)
(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 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)
- (add-hook 'focus-in-hook 'adob--after-change-major-mode-hook)
- (add-hook 'after-change-major-mode-hook 'adob--after-change-major-mode-hook)
- (add-hook 'next-error-hook 'adob--after-change-major-mode-hook))
+ (adob--hooks 'add-hook))
;;;###autoload
(define-minor-mode auto-dim-other-buffers-mode
- [nongnu] elpa/auto-dim-other-buffers 16db9f4942 06/82: MUCH more efficient: only changes faces for 2 buffers max, and only when necessary, (continued)
- [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, 2022/12/12
- [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 <=
- [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
- [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