[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/bind-map b05ea98102 37/97: Add option to use local state m
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/bind-map b05ea98102 37/97: Add option to use local state maps |
Date: |
Thu, 20 Jan 2022 07:59:14 -0500 (EST) |
branch: elpa/bind-map
commit b05ea9810209363943cfb946448236595d53520d
Author: justbur <justin@burkett.cc>
Commit: justbur <justin@burkett.cc>
Add option to use local state maps
These maps override nearly all evil maps, so this gives the evil keys
very high precedence.
---
bind-map.el | 50 +++++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 43 insertions(+), 7 deletions(-)
diff --git a/bind-map.el b/bind-map.el
index 3796a605a8..c9a27bfe7f 100644
--- a/bind-map.el
+++ b/bind-map.el
@@ -117,6 +117,12 @@ states.
Symbols representing the states to use for :evil-keys. If nil,
use `bind-map-default-evil-states'.
+:evil-use-local BOOL
+
+This places all evil bindings in the local state maps for evil.
+These maps have high precedence and will mask most other evil
+bindings.
+
:major-modes (MODE1 MODE2 ...)
If specified, the keys will only be bound when these major modes
@@ -142,6 +148,8 @@ Declare a prefix command for MAP named COMMAND-NAME."
(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)))
`(progn
@@ -182,8 +190,10 @@ Declare a prefix command for MAP named COMMAND-NAME."
(dolist (key (list ,@keys))
(global-set-key (kbd key) ',prefix-cmd))
(when ',evil-keys
- (bind-map-evil-define-key
- ',evil-states nil (list ,@evil-keys) ',prefix-cmd))))))
+ (bind-map-evil-global-define-key
+ ',evil-states (list ,@evil-keys) ',prefix-cmd
+ ;; ,evil-override-known-maps
+ ,evil-use-local))))))
(put 'bind-map 'lisp-indent-function 'defun)
;;;###autoload
@@ -236,11 +246,37 @@ STATES and KEYS."
(require 'evil)
(dolist (state states)
(dolist (key keys)
- (if map
- (eval
- `(evil-define-key ',state ',map (kbd ,key) ',def))
- (eval
- `(evil-global-set-key ',state (kbd ,key) ',def))))))
+ (eval `(evil-define-key ',state ',map (kbd ,key) ',def)))))
+
+(defvar bind-map-local-bindings '()
+ "Elements are (STATE KEY DEF) each corresponding to a binding
+to place in a local state map.")
+
+(defun bind-map-local-mode-hook ()
+ (dolist (entry bind-map-local-bindings)
+ (let ((map (intern (format "evil-%s-state-local-map" (car entry)))))
+ (when (symbol-value map)
+ (define-key (symbol-value map) (cadr entry) (caddr entry))))))
+(add-hook 'evil-local-mode-hook 'bind-map-local-mode-hook)
+
+(defun bind-map-evil-global-define-key
+ (states keys def &optional use-local)
+ "Version of `evil-define-key' that binds DEF across multiple
+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)
+ (eval `(evil-global-set-key ',state (kbd ,key) ',def))))))
;;;###autoload
(defun bind-map-set-keys (map key def &rest bindings)
- [nongnu] branch elpa/bind-map created (now 510a24138d), ELPA Syncer, 2022/01/20
- [nongnu] elpa/bind-map 6e19e536fc 03/97: Add link to evil-leader, ELPA Syncer, 2022/01/20
- [nongnu] elpa/bind-map f2f7dfefbd 07/97: Assume :keys and :evil-keys are lists, ELPA Syncer, 2022/01/20
- [nongnu] elpa/bind-map 3a2f1d8074 01/97: Initial commit, ELPA Syncer, 2022/01/20
- [nongnu] elpa/bind-map 115e0459bf 05/97: Bring back set-keys function, ELPA Syncer, 2022/01/20
- [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 <=
- [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, 2022/01/20
- [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