[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/bind-map 5508980148 69/97: Account for multiple declaratio
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/bind-map 5508980148 69/97: Account for multiple declarations of the same map |
Date: |
Thu, 20 Jan 2022 07:59:24 -0500 (EST) |
branch: elpa/bind-map
commit 5508980148a3146e15da2b3b43b5da2b029875cb
Author: justbur <justin@burkett.cc>
Commit: justbur <justin@burkett.cc>
Account for multiple declarations of the same map
Specifically, ensure that the major-mode activate variable has just one
list of associated major modes.
---
bind-map-tests.el | 13 +++++++++++++
bind-map.el | 15 +++++++++++++--
2 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/bind-map-tests.el b/bind-map-tests.el
index bbbd11efce..0974b50df5 100644
--- a/bind-map-tests.el
+++ b/bind-map-tests.el
@@ -73,3 +73,16 @@
(evil-normalize-keymaps)
(define-key tmpmap "a" "b")
(should (string= (key-binding "\C-aa") "b"))))
+
+(ert-deftest bind-map-multiple-declarations ()
+ (let ((tmpmap (make-sparse-keymap))
+ tmpmap-root-map
+ minor-mode-map-alist bind-map-major-modes-alist)
+ (bind-map tmpmap
+ :major-modes (mm1 mm2))
+ (bind-map tmpmap
+ :major-modes (mm3 mm4 mm5))
+ (bind-map tmpmap
+ :major-modes (mm6))
+ (should (equal (cdr (assq 'tmpmap-active bind-map-major-modes-alist))
+ '(mm1 mm2 mm3 mm4 mm5 mm6)))))
diff --git a/bind-map.el b/bind-map.el
index 4070d68864..a32269c457 100644
--- a/bind-map.el
+++ b/bind-map.el
@@ -153,6 +153,17 @@ 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-add-to-major-mode-list (activate-var major-mode-list)
+ "Add (ACTIVATE-VAR . MAJOR-MODE-LIST) to
+`bind-map-major-modes-alist'. If ACTIVATE-VAR is already a key,
+then append MAJOR-MODE-LIST to the existing cdr."
+ (let ((current (assq activate-var bind-map-major-modes-alist)))
+ (if current
+ (setcdr current (append (cdr current)
+ major-mode-list))
+ (push (cons activate-var major-mode-list)
+ bind-map-major-modes-alist))))
+
(defun bind-map-kbd-keys (keys)
"Apply `kbd' to KEYS filtering out nil and empty strings."
(let (res)
@@ -270,8 +281,8 @@ mode maps. Set up by bind-map.el." map))
(when major-modes
;; compiler warns about making a local var below the top-level
`((with-no-warnings (defvar-local ,active-var nil))
- (push (cons ',active-var ,root-map) minor-mode-map-alist)
- (push (cons ',active-var ',major-modes) bind-map-major-modes-alist)
+ (add-to-list 'minor-mode-map-alist (cons ',active-var ,root-map))
+ (bind-map-add-to-major-mode-list ',active-var ',major-modes)
;; call once in case we are already in the relevant major mode
(bind-map-change-major-mode-after-body-hook)))
- [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 <=
- [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, 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