[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/swsw 4a7ea31b37 036/146: * swsw.el (swsw-mode): Bind 'C-x
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/swsw 4a7ea31b37 036/146: * swsw.el (swsw-mode): Bind 'C-x o' to 'swsw-select' |
Date: |
Wed, 25 May 2022 02:59:41 -0400 (EDT) |
branch: elpa/swsw
commit 4a7ea31b37170a2d5e56bd36640786887ab343f8
Author: Daniel Semyonov <cmstr@dsemy.com>
Commit: Daniel Semyonov <cmstr@dsemy.com>
* swsw.el (swsw-mode): Bind 'C-x o' to 'swsw-select'
---
swsw.el | 59 +++++++++++++++++++++++++++--------------------------------
1 file changed, 27 insertions(+), 32 deletions(-)
diff --git a/swsw.el b/swsw.el
index 631bfecb5b..a4d67aa4c3 100644
--- a/swsw.el
+++ b/swsw.el
@@ -28,31 +28,25 @@
;;
;; Usage:
;;
-;; Enable `swsw-mode' and (optionally) bind `swsw-select' to a key:
+;; Enable `swsw-mode':
;;
;; (swsw-mode)
-;; (define-key swsw-mode-map "C-x o" #'swsw-select)
;;
;; For use-package users:
;;
;; (use-package swsw
-;; :demand ; :bind keyword causes loading to defer.
-;; :bind
-;; (:map swsw-mode-map
-;; ("C-x o" . swsw-select))
;; :config
;; (swsw-mode))
;;
;; When swsw-mode is active:
;; - A window ID is displayed using a mode line lighter or a display function
(see
;; `swsw-display-function').
-;; - A single (predefined) character CHAR corresponds to the minibuffer (see
+;; - A single (predefined) character corresponds to the minibuffer (see
;; `swsw-minibuffer-id').
;; - Window IDs are assigned to all windows on all frames (by default, see
;; `swsw-scope').
;;
-;; C-x o RET ID (if bound) or M-x swsw-select RET ID switches focus to the
window
-;; which corresponds to ID.
+;; C-x o ID switches focus to the window which corresponds to ID.
;;
;; You can customize `swsw-mode' using the customize interface:
;;
@@ -179,29 +173,6 @@ If set to `lighter', use the mode line lighter of
`swsw-mode'"
(format swsw-id-format
(reverse (apply #'string (window-parameter window 'swsw-id)))))
-;;;###autoload
-(define-minor-mode swsw-mode
- "Minor mode for selecting windows by their ID."
- :global t
- :lighter (:eval (when (eq swsw-display-function 'lighter)
- (swsw-format-id (selected-window))))
- :keymap (make-sparse-keymap)
- (if swsw-mode
- (progn
- (swsw-update)
- (unless (eq swsw-display-function 'lighter)
- (funcall swsw-display-function t))
- (add-hook 'window-configuration-change-hook #'swsw-update)
- (add-hook 'minibuffer-setup-hook #'swsw-update)
- (add-hook 'minibuffer-exit-hook #'swsw-update)
- (add-hook 'after-delete-frame-functions #'swsw-update))
- (unless (eq swsw-display-function 'lighter)
- (funcall swsw-display-function nil))
- (remove-hook 'window-configuration-change-hook #'swsw-update)
- (remove-hook 'minibuffer-setup-hook #'swsw-update)
- (remove-hook 'minibuffer-exit-hook #'swsw-update)
- (remove-hook 'after-delete-frame-functions #'swsw-update)))
-
(defun swsw--read-id (len)
"Read a window ID of length LEN using `read-char'."
(let ((acc 1) id)
@@ -227,6 +198,30 @@ If set to `lighter', use the mode line lighter of
`swsw-mode'"
(select-window window)))
(other-window 1)))
+;;;###autoload
+(define-minor-mode swsw-mode
+ "Minor mode for selecting windows by their ID."
+ :global t
+ :lighter
+ (:eval (when (eq swsw-display-function 'lighter)
+ (swsw-format-id (selected-window))))
+ :keymap '(keymap (?\C-x . (keymap (?o . swsw-select))))
+ (if swsw-mode
+ (progn
+ (swsw-update)
+ (unless (eq swsw-display-function 'lighter)
+ (funcall swsw-display-function t))
+ (add-hook 'window-configuration-change-hook #'swsw-update)
+ (add-hook 'minibuffer-setup-hook #'swsw-update)
+ (add-hook 'minibuffer-exit-hook #'swsw-update)
+ (add-hook 'after-delete-frame-functions #'swsw-update))
+ (unless (eq swsw-display-function 'lighter)
+ (funcall swsw-display-function nil))
+ (remove-hook 'window-configuration-change-hook #'swsw-update)
+ (remove-hook 'minibuffer-setup-hook #'swsw-update)
+ (remove-hook 'minibuffer-exit-hook #'swsw-update)
+ (remove-hook 'after-delete-frame-functions #'swsw-update)))
+
;;;; Display functions:
(defun swsw--mode-line-display ()
- [nongnu] elpa/swsw 5e77d34dfa 054/146: ; Modify installation section of the README file and Info node, (continued)
- [nongnu] elpa/swsw 5e77d34dfa 054/146: ; Modify installation section of the README file and Info node, ELPA Syncer, 2022/05/25
- [nongnu] elpa/swsw cacd11a1b7 072/146: Prevent setting 'swsw-minibuffer-id' to a member of 'swsw-id-chars', ELPA Syncer, 2022/05/25
- [nongnu] elpa/swsw dd65e7c8af 139/146: ; Update copyright years, ELPA Syncer, 2022/05/25
- [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 <=
- [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, 2022/05/25
- [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