[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/window-commander 48db8fe39b 021/170: Add a reference im
From: |
ELPA Syncer |
Subject: |
[elpa] externals/window-commander 48db8fe39b 021/170: Add a reference implementation for a conditional display function |
Date: |
Wed, 28 Jun 2023 19:00:21 -0400 (EDT) |
branch: externals/window-commander
commit 48db8fe39bd506eb6280158daec5599f96ca398c
Author: Daniel Semyonov <cmstr@dsemy.com>
Commit: Daniel Semyonov <cmstr@dsemy.com>
Add a reference implementation for a conditional display function
* swsw.el (swsw--mode-line-display, swsw--mode-line-hide): New
functions performing operations common to both reference display
functions.
(swsw-mode-line-conditional-display-function): New reference
conditional display function.
---
swsw.el | 50 ++++++++++++++++++++++++++++++++++++--------------
1 file changed, 36 insertions(+), 14 deletions(-)
diff --git a/swsw.el b/swsw.el
index ca3d10d348..67afecf7d5 100644
--- a/swsw.el
+++ b/swsw.el
@@ -172,27 +172,49 @@ If set to `lighter', use the mode line lighter of
`swsw-mode'"
;;;; Display functions:
+(defun swsw--mode-line-display ()
+ "Display window IDs at the beginning of the mode line."
+ (setq-default mode-line-format
+ `((swsw-mode
+ (:eval (swsw-format-id (selected-window))))
+ ,@(assq-delete-all
+ `swsw-mode
+ (default-value `mode-line-format))))
+ (force-mode-line-update t))
+
+(defun swsw--mode-line-hide ()
+ "Remove window IDs from the beginning of the mode line."
+ (setq-default mode-line-format
+ (assq-delete-all
+ 'swsw-mode
+ (default-value 'mode-line-format)))
+ (force-mode-line-update t))
+
(defun swsw-mode-line-display-function (switch)
- "Display window IDs on the mode line if SWITCH is non-nil, and disable
displaying
-window IDs on the mode line if SWITCH is nil.
+ "Display window IDs on the mode line if SWITCH is non-nil, and disable
+displaying window IDs on the mode line if SWITCH is nil.
+
+This display function shows the window IDs at the beginning of the mode line,
+similarly to `ace-window-display-mode'.
+This display function respects `swsw-id-format'."
+ (if switch
+ (swsw--mode-line-display)
+ (swsw--mode-line-hide)))
+
+(defun swsw-mode-line-conditional-display-function (switch)
+ "Display window IDs on the mode line if SWITCH is non-nil and a window
+selection is in progress, and disable
+displaying window IDs on the mode line if SWITCH is nil.
This display function shows the window IDs at the beginning of the mode line,
similarly to `ace-window-display-mode'.
This display function respects `swsw-id-format'."
(if switch
(progn
- (force-mode-line-update t)
- (setq-default mode-line-format
- `((swsw-mode
- (:eval (swsw-format-id (selected-window))))
- ,@(assq-delete-all
- `swsw-mode
- (default-value `mode-line-format)))))
- (force-mode-line-update t)
- (setq-default mode-line-format
- (assq-delete-all
- 'swsw-mode
- (default-value 'mode-line-format)))))
+ (add-hook 'swsw-before-select-hook #'swsw--mode-line-display)
+ (add-hook 'swsw-after-select-hook #'swsw--mode-line-hide))
+ (remove-hook 'swsw-before-select-hook #'swsw--mode-line-display)
+ (remove-hook 'swsw-after-select-hook #'swsw--mode-line-hide)))
(provide 'swsw)
- [elpa] externals/window-commander 4a7ea31b37 036/170: * swsw.el (swsw-mode): Bind 'C-x o' to 'swsw-select', (continued)
- [elpa] externals/window-commander 4a7ea31b37 036/170: * swsw.el (swsw-mode): Bind 'C-x o' to 'swsw-select', ELPA Syncer, 2023/06/28
- [elpa] externals/window-commander 8044341fdb 040/170: ; Update README to no longer suggest binding 'C-x o' in 'swsw-mode-map', ELPA Syncer, 2023/06/28
- [elpa] externals/window-commander b0b55f010c 041/170: ; Improve the docstrings for the reference display functions, ELPA Syncer, 2023/06/28
- [elpa] externals/window-commander c0f5277538 045/170: ; Update the URL property of the package, ELPA Syncer, 2023/06/28
- [elpa] externals/window-commander 8fc0e7dfa7 046/170: ; Bump required emacs version to 26.1, ELPA Syncer, 2023/06/28
- [elpa] externals/window-commander 40f7a25f82 047/170: ; Add license information to the title page of the Info node, ELPA Syncer, 2023/06/28
- [elpa] externals/window-commander 83eb90586a 051/170: ; Alter comments and docstrings to comply with Emacs' conventions, ELPA Syncer, 2023/06/28
- [elpa] externals/window-commander 08b56d124c 015/170: Add support for multi-character IDs, ELPA Syncer, 2023/06/28
- [elpa] externals/window-commander 96809a6cae 019/170: Add the ability to change the way window IDs are displayed, ELPA Syncer, 2023/06/28
- [elpa] externals/window-commander 4c84ca310f 016/170: ; Update README to reflect recent changes, ELPA Syncer, 2023/06/28
- [elpa] externals/window-commander 48db8fe39b 021/170: Add a reference implementation for a conditional display function,
ELPA Syncer <=
- [elpa] externals/window-commander 8a8be23f1b 050/170: ; Include license information in created package archives, ELPA Syncer, 2023/06/28
- [elpa] externals/window-commander ec011dc3b9 053/170: ; Fix inconsistency in URL between swsw.el and swsw-pkg.el, ELPA Syncer, 2023/06/28
- [elpa] externals/window-commander 0a3edee2e5 055/170: ; Bump version to 1.1.1 and update NEWS file, ELPA Syncer, 2023/06/28
- [elpa] externals/window-commander 0b67d7bc00 056/170: * swsw.el (swsw-display-function): Define early only when byte-compiling, ELPA Syncer, 2023/06/28
- [elpa] externals/window-commander 5446df0f3e 059/170: * swsw.el (swsw--get-id-length): Fix the calculation of the ID length, ELPA Syncer, 2023/06/28
- [elpa] externals/window-commander 095091cf33 057/170: Handle cases where there are less than three tracked windows better, ELPA Syncer, 2023/06/28
- [elpa] externals/window-commander c2c579a3c9 061/170: Construct multi-character IDs without pre-computing all possible IDs, ELPA Syncer, 2023/06/28
- [elpa] externals/window-commander 7d82ffeef4 076/170: ; Small modifications to the NEWS file, ELPA Syncer, 2023/06/28
- [elpa] externals/window-commander d7fe615c3f 049/170: ; Fix inconsistency between requirements in swsw.el and swsw-pkg.el, ELPA Syncer, 2023/06/28
- [elpa] externals/window-commander cacbe44c08 058/170: ; Remove unnecessary ':group' keywords from 'defcustom' calls, ELPA Syncer, 2023/06/28