[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/swsw 48db8fe39b 021/146: Add a reference implementation fo
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/swsw 48db8fe39b 021/146: Add a reference implementation for a conditional display function |
Date: |
Wed, 25 May 2022 02:59:39 -0400 (EDT) |
branch: elpa/swsw
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)
- [nongnu] elpa/swsw ac8efcbbd1 007/146: Assign a unique ID to an active minibuffer, (continued)
- [nongnu] elpa/swsw ac8efcbbd1 007/146: Assign a unique ID to an active minibuffer, ELPA Syncer, 2022/05/25
- [nongnu] elpa/swsw 08b56d124c 015/146: Add support for multi-character IDs, ELPA Syncer, 2022/05/25
- [nongnu] elpa/swsw 185861a2e9 010/146: Use a lighter for 'swsw-mode', ELPA Syncer, 2022/05/25
- [nongnu] elpa/swsw 6a9b3544c9 002/146: ; Fix 'git clone' example command in README file, ELPA Syncer, 2022/05/25
- [nongnu] elpa/swsw 15e188aa17 009/146: Fix some edge cases related to the minibuffer, ELPA Syncer, 2022/05/25
- [nongnu] elpa/swsw 0aef3311c6 014/146: ; Bump to version 0.3, ELPA Syncer, 2022/05/25
- [nongnu] elpa/swsw 9873ff1bd2 020/146: * swsw.el (swsw-select): Add before and after hooks., ELPA Syncer, 2022/05/25
- [nongnu] elpa/swsw 4a7ea31b37 036/146: * swsw.el (swsw-mode): Bind 'C-x o' to 'swsw-select', ELPA Syncer, 2022/05/25
- [nongnu] elpa/swsw 63e295f599 025/146: Add a user option to customize the scope of window tracking, ELPA Syncer, 2022/05/25
- [nongnu] elpa/swsw 721d0208f7 026/146: Update the window list after deleting a frame, ELPA Syncer, 2022/05/25
- [nongnu] elpa/swsw 48db8fe39b 021/146: Add a reference implementation for a conditional display function,
ELPA Syncer <=
- [nongnu] elpa/swsw 4c84ca310f 016/146: ; Update README to reflect recent changes, ELPA Syncer, 2022/05/25
- [nongnu] elpa/swsw a816f208e9 005/146: Simplify the format of 'swsw-window-list', ELPA Syncer, 2022/05/25
- [nongnu] elpa/swsw f9a901c809 004/146: * swsw.el (swsw-id-chars-base): Remove erroneous quote, ELPA Syncer, 2022/05/25
- [nongnu] elpa/swsw 96809a6cae 019/146: Add the ability to change the way window IDs are displayed, ELPA Syncer, 2022/05/25
- [nongnu] elpa/swsw c08a9b1e58 024/146: ; Fix a docstring, ELPA Syncer, 2022/05/25
- [nongnu] elpa/swsw b6277eb31f 037/146: ; Indicate that version 1.1 is still in development in the NEWS file, ELPA Syncer, 2022/05/25
- [nongnu] elpa/swsw a5b25e075f 032/146: Allow setting the scope to the selected frame, ELPA Syncer, 2022/05/25
- [nongnu] elpa/swsw 082e03382e 033/146: * swsw.el (swsw-select): Ensure 'swsw-after-select-hook' runs., ELPA Syncer, 2022/05/25
- [nongnu] elpa/swsw 40f7a25f82 047/146: ; Add license information to the title page of the Info node, ELPA Syncer, 2022/05/25
- [nongnu] elpa/swsw 3a9848deac 042/146: Add an Info node for the package, ELPA Syncer, 2022/05/25