[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/bind-map 5077cb72cb 39/97: Add :override-minor-modes optio
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/bind-map 5077cb72cb 39/97: Add :override-minor-modes option for :keys |
Date: |
Thu, 20 Jan 2022 07:59:15 -0500 (EST) |
branch: elpa/bind-map
commit 5077cb72cb1bb78fd086a5517dad728632bf0f68
Author: justbur <justin@burkett.cc>
Commit: justbur <justin@burkett.cc>
Add :override-minor-modes option for :keys
---
bind-map.el | 35 ++++++++++++++++++++---------------
1 file changed, 20 insertions(+), 15 deletions(-)
diff --git a/bind-map.el b/bind-map.el
index 6b156a2d2b..2152cb02ac 100644
--- a/bind-map.el
+++ b/bind-map.el
@@ -107,6 +107,13 @@ which are optional.
The keys to use for the leader binding. These are strings
suitable for use in `kbd'.
+:override-minor-modes BOOL
+
+If non nil, make keys in :keys override the minor-mode maps, by
+using `emulation-mode-map-alists' instead of `global-map'. If
+either :major-modes or :minor-modes is specified, this setting
+has no effect.
+
:evil-keys (KEY1 KEY2 ...)
Like :keys but these bindings are only active in certain evil
@@ -121,7 +128,8 @@ use `bind-map-default-evil-states'.
This places all evil bindings in the local state maps for evil.
These maps have high precedence and will mask most other evil
-bindings.
+bindings. If either :major-modes or :minor-modes is specified,
+this setting has no effect.
:major-modes (MODE1 MODE2 ...)
@@ -145,10 +153,10 @@ Declare a prefix command for MAP named COMMAND-NAME."
(prefix-cmd (or (plist-get args :prefix-cmd)
(intern (format "%s-prefix" map))))
(keys (plist-get args :keys))
+ (override-minor-modes (plist-get args :override-minor-modes))
(evil-keys (plist-get args :evil-keys))
(evil-states (or (plist-get args :evil-states)
bind-map-default-evil-states))
- ;; (evil-override-known-maps (plist-get args
:evil-override-known-maps))
(evil-use-local (plist-get args :evil-use-local))
(minor-modes (plist-get args :minor-modes))
(major-modes (plist-get args :major-modes)))
@@ -159,14 +167,13 @@ Declare a prefix command for MAP named COMMAND-NAME."
(defvar ,prefix-cmd nil)
(setq ,prefix-cmd ,map)
(setf (symbol-function ',prefix-cmd) ,map)
+ (defvar ,root-map (make-sparse-keymap))
(when ',minor-modes
- (defvar ,root-map (make-sparse-keymap))
(dolist (mode ',minor-modes)
(push (cons mode ,root-map) minor-mode-map-alist)))
(when ',major-modes
- (defvar ,root-map (make-sparse-keymap))
(defvar ,major-mode-list '())
;; compiler warns about making a local var below the top-level
(with-no-warnings
@@ -178,6 +185,11 @@ Declare a prefix command for MAP named COMMAND-NAME."
(setq ,activate (not (null (member major-mode ,major-mode-list)))))
(add-hook 'change-major-mode-after-body-hook ',activate-func))
+ (when (and ,override-minor-modes
+ (null ',major-modes)
+ (null ',minor-modes))
+ (add-to-list 'emulation-mode-map-alists (list (cons t ,root-map))))
+
(if (or ',minor-modes ',major-modes)
;;bind keys in root-map
(progn
@@ -188,12 +200,12 @@ Declare a prefix command for MAP named COMMAND-NAME."
',evil-states ,root-map (list ,@evil-keys) ',prefix-cmd)))
;;bind in global maps
(dolist (key (list ,@keys))
- (global-set-key (kbd key) ',prefix-cmd))
+ (if ,override-minor-modes
+ (define-key ,root-map (kbd key) ',prefix-cmd)
+ (global-set-key (kbd key) ',prefix-cmd)))
(when ',evil-keys
(bind-map-evil-global-define-key
- ',evil-states (list ,@evil-keys) ',prefix-cmd
- ;; ,evil-override-known-maps
- ,evil-use-local))))))
+ ',evil-states (list ,@evil-keys) ',prefix-cmd ,evil-use-local))))))
(put 'bind-map 'lisp-indent-function 'defun)
;;;###autoload
@@ -266,13 +278,6 @@ STATES and KEYS. USE-LOCAL will bind the keys in the local
state
maps which have higher precedence than most evil maps."
(require 'evil)
(dolist (key keys)
- ;; (when update-known-overriding
- ;; (eval-after-load 'ibuffer
- ;; `(evil-define-key 'normal ibuffer-mode-map (kbd ,key) ',def))
- ;; (eval-after-load 'dired
- ;; `(evil-define-key 'normal dired-mode-map (kbd ,key) ',def))
- ;; (dolist (map-cons evil-overriding-maps)
- ;; (define-key (symbol-value (car-safe map-cons)) key def)))
(dolist (state states)
(if use-local
(push (list state (kbd key) def) bind-map-local-bindings)
- [nongnu] elpa/bind-map 76b8e2ab6c 85/97: Add tests for inheritance, (continued)
- [nongnu] elpa/bind-map 76b8e2ab6c 85/97: Add tests for inheritance, ELPA Syncer, 2022/01/20
- [nongnu] elpa/bind-map 6ba28e31aa 83/97: Revert change to prefix-cmd handling, ELPA Syncer, 2022/01/20
- [nongnu] elpa/bind-map fe76f92777 91/97: Add default keys and default evil-keys, ELPA Syncer, 2022/01/20
- [nongnu] elpa/bind-map 26a3b5571d 88/97: Make return val consistent in bind-map, ELPA Syncer, 2022/01/20
- [nongnu] elpa/bind-map bf4181e3a4 95/97: Add types to defcustoms, ELPA Syncer, 2022/01/20
- [nongnu] elpa/bind-map 510a24138d 97/97: Merge pull request #6 from skangas/bump-version, ELPA Syncer, 2022/01/20
- [nongnu] elpa/bind-map 21f972e52d 08/97: Clarify some parts of README, ELPA Syncer, 2022/01/20
- [nongnu] elpa/bind-map d609a7d784 12/97: Add cl-lib requirement, ELPA Syncer, 2022/01/20
- [nongnu] elpa/bind-map 27ed3304d2 19/97: Revert one of the changes in the previous commit, ELPA Syncer, 2022/01/20
- [nongnu] elpa/bind-map 9f88b251f1 14/97: Fix typo, ELPA Syncer, 2022/01/20
- [nongnu] elpa/bind-map 5077cb72cb 39/97: Add :override-minor-modes option for :keys,
ELPA Syncer <=
- [nongnu] elpa/bind-map 07eef581ef 15/97: Add URL, ELPA Syncer, 2022/01/20
- [nongnu] elpa/bind-map ce4e8e7f64 21/97: Fix typos in docstrings, ELPA Syncer, 2022/01/20
- [nongnu] elpa/bind-map f46bf57d7f 52/97: Add major-mode test, ELPA Syncer, 2022/01/20
- [nongnu] elpa/bind-map e3fa3cc383 26/97: Fix compiler warning, ELPA Syncer, 2022/01/20
- [nongnu] elpa/bind-map 4489504e47 29/97: Check evil-keys before calling evil-define-*, ELPA Syncer, 2022/01/20
- [nongnu] elpa/bind-map fb234332ff 32/97: Signal error if supplied map is not a keymap, ELPA Syncer, 2022/01/20
- [nongnu] elpa/bind-map 3f6eba7b5b 56/97: Make sure active-var is bound before setting, ELPA Syncer, 2022/01/20
- [nongnu] elpa/bind-map 99236303f6 84/97: Rename bind-map-for-modes-derived, ELPA Syncer, 2022/01/20
- [nongnu] elpa/bind-map 96802ece2b 76/97: Increment version, ELPA Syncer, 2022/01/20
- [nongnu] elpa/bind-map 4ceb7deb3a 90/97: Remove messages from tests, ELPA Syncer, 2022/01/20