[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/bind-map d47be94d23 63/97: Don't try to bind keys that are
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/bind-map d47be94d23 63/97: Don't try to bind keys that are nil or "" |
Date: |
Thu, 20 Jan 2022 07:59:23 -0500 (EST) |
branch: elpa/bind-map
commit d47be94d236c819b5ca47d66551d23a0ee17ac33
Author: justbur <justin@burkett.cc>
Commit: justbur <justin@burkett.cc>
Don't try to bind keys that are nil or ""
---
bind-map.el | 28 ++++++++++++++++++----------
1 file changed, 18 insertions(+), 10 deletions(-)
diff --git a/bind-map.el b/bind-map.el
index 66f91a2013..77bf7a0a5d 100644
--- a/bind-map.el
+++ b/bind-map.el
@@ -153,6 +153,14 @@ when the major mode is an element of the cdr. See
(add-hook 'change-major-mode-after-body-hook
'bind-map-change-major-mode-after-body-hook)
+(defun bind-map-kbd-keys (keys)
+ "Apply `kbd' to KEYS filtering out nil and empty strings."
+ (let (res)
+ (dolist (key keys (nreverse res))
+ (when (and (stringp key)
+ (not (string= "" key)))
+ (push (kbd key) res)))))
+
;;;###autoload
(defmacro bind-map (map &rest args)
"Bind keymap MAP in multiple locations.
@@ -284,23 +292,23 @@ mode maps. Set up by bind-map.el." map))
(if (or minor-modes major-modes)
;; only bind keys in root-map
- `((dolist (key (list ,@keys))
- (define-key ,root-map (kbd key) ',prefix-cmd))
- (dolist (key (list ,@evil-keys))
+ `((dolist (key (bind-map-kbd-keys (list ,@keys)))
+ (define-key ,root-map key ',prefix-cmd))
+ (dolist (key (bind-map-kbd-keys (list ,@evil-keys)))
(dolist (state ',evil-states)
(define-key (evil-get-auxiliary-keymap ,root-map state t)
- (kbd key) ',prefix-cmd))))
+ key ',prefix-cmd))))
;; bind in global maps and possibly root-map
- `((dolist (key (list ,@keys))
+ `((dolist (key (bind-map-kbd-keys (list ,@keys)))
(when ,override-minor-modes
- (define-key ,root-map (kbd key) ',prefix-cmd))
- (global-set-key (kbd key) ',prefix-cmd))
- (dolist (key (list ,@evil-keys))
+ (define-key ,root-map key ',prefix-cmd))
+ (global-set-key key ',prefix-cmd))
+ (dolist (key (bind-map-kbd-keys (list ,@evil-keys)))
(dolist (state ',evil-states)
(when ,override-minor-modes
- (push (list ',override-mode state (kbd key) ',prefix-cmd)
+ (push (list ',override-mode state key ',prefix-cmd)
bind-map-evil-local-bindings))
- (evil-global-set-key state (kbd key) ',prefix-cmd)))))
+ (evil-global-set-key state key ',prefix-cmd)))))
(when evil-keys `((evil-normalize-keymaps))))))
(put 'bind-map 'lisp-indent-function 'defun)
- [nongnu] elpa/bind-map d7aee3c6ab 09/97: Note helper funcs in README, (continued)
- [nongnu] elpa/bind-map d7aee3c6ab 09/97: Note helper funcs in README, ELPA Syncer, 2022/01/20
- [nongnu] elpa/bind-map a8a2937ecc 38/97: Minor tweak to previous commit, ELPA Syncer, 2022/01/20
- [nongnu] elpa/bind-map faaa33d909 77/97: Prefer eval-after-load to require for evil funcs, ELPA Syncer, 2022/01/20
- [nongnu] elpa/bind-map 61fe55e097 17/97: Can't simply use cl-pushnew, ELPA Syncer, 2022/01/20
- [nongnu] elpa/bind-map 5508980148 69/97: Account for multiple declarations of the same map, ELPA Syncer, 2022/01/20
- [nongnu] elpa/bind-map b05ea98102 37/97: Add option to use local state maps, ELPA Syncer, 2022/01/20
- [nongnu] elpa/bind-map 7d20946692 04/97: Add autoloads, ELPA Syncer, 2022/01/20
- [nongnu] elpa/bind-map 7de08fe592 43/97: Move a defvar and reword docstring, ELPA Syncer, 2022/01/20
- [nongnu] elpa/bind-map bb7a8b2258 59/97: Remove declare-function from previous commit, ELPA Syncer, 2022/01/20
- [nongnu] elpa/bind-map 6d05297e3c 20/97: Add another example and more detail to README, ELPA Syncer, 2022/01/20
- [nongnu] elpa/bind-map d47be94d23 63/97: Don't try to bind keys that are nil or "",
ELPA Syncer <=
- [nongnu] elpa/bind-map ebc4c9fb11 34/97: Remove bind-map-kbd hack, ELPA Syncer, 2022/01/20
- [nongnu] elpa/bind-map 8ec4516db2 48/97: Remove use of evil-define-key, ELPA Syncer, 2022/01/20
- [nongnu] elpa/bind-map c182707793 41/97: Remove unnecessary helper functions and reorg, ELPA Syncer, 2022/01/20
- [nongnu] elpa/bind-map b0b9e18947 66/97: Revert last commit, ELPA Syncer, 2022/01/20
- [nongnu] elpa/bind-map f51d4b0c0d 79/97: Add bind-map-for-modes-derived, ELPA Syncer, 2022/01/20
- [nongnu] elpa/bind-map 21b7ba7eca 30/97: Fix some docstrings, ELPA Syncer, 2022/01/20
- [nongnu] elpa/bind-map cc1db8958c 64/97: Version 0.1, ELPA Syncer, 2022/01/20
- [nongnu] elpa/bind-map 988f14eb77 65/97: Use evil-define-minor-mode-key for minor-mode keys, ELPA Syncer, 2022/01/20
- [nongnu] elpa/bind-map 292794739c 71/97: Fix incorrect check of override mode in local hook, ELPA Syncer, 2022/01/20
- [nongnu] elpa/bind-map b187069313 22/97: Add short versions for single major/minor mode, ELPA Syncer, 2022/01/20