emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/bind-map faaa33d909 77/97: Prefer eval-after-load to requi


From: ELPA Syncer
Subject: [nongnu] elpa/bind-map faaa33d909 77/97: Prefer eval-after-load to require for evil funcs
Date: Thu, 20 Jan 2022 07:59:26 -0500 (EST)

branch: elpa/bind-map
commit faaa33d90989d43da71d56fe70e1176f6b6eeff8
Author: justbur <justin@burkett.cc>
Commit: justbur <justin@burkett.cc>

    Prefer eval-after-load to require for evil funcs
    
    Requiring could screw up someone trying to sequence their load order by
    loading evil unexpectedly early.
---
 bind-map.el | 53 +++++++++++++++++++++++++++++------------------------
 1 file changed, 29 insertions(+), 24 deletions(-)

diff --git a/bind-map.el b/bind-map.el
index 5b9908c9df..e64caeb882 100644
--- a/bind-map.el
+++ b/bind-map.el
@@ -187,8 +187,8 @@ the bindings on major and/or minor modes being active. The
 options are controlled through the keyword arguments ARGS, all of
 which are optional.
 
-The package evil is only required if one of the :evil-keys is
-specified.
+Keys for evil-mode are bound using `eval-after-load', so they
+will only take effect after evil is loaded.
 
 :keys \(KEY1 KEY2 ...\)
 
@@ -270,8 +270,6 @@ mode maps. Set up by bind-map.el." map))
     (append
      '(progn)
 
-     (when evil-keys '((require 'evil)))
-
      `((defvar ,map (make-sparse-keymap))
        (unless (keymapp ,map)
          (error "bind-map: %s is not a keymap" ',map))
@@ -310,30 +308,37 @@ mode maps. Set up by bind-map.el." map))
      (if (or minor-modes major-modes)
          ;; only bind keys in root-map
          `((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)
-               (when ',major-modes
-                 (define-key
-                   (evil-get-auxiliary-keymap ,root-map state t)
-                   key ',prefix-cmd))
-               (dolist (mode ',minor-modes)
-                 (when (fboundp 'evil-define-minor-mode-key)
-                   (evil-define-minor-mode-key
-                    state mode key ',prefix-cmd))))))
+             (define-key ,root-map key ',prefix-cmd)))
        ;; bind in global maps and possibly root-map
        `((dolist (key (bind-map-kbd-keys (list ,@keys)))
            (when ,override-minor-modes
              (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 key ',prefix-cmd)
-                     bind-map-evil-local-bindings))
-             (evil-global-set-key state key ',prefix-cmd)))))
-
-     (when evil-keys `((evil-normalize-keymaps))))))
+           (global-set-key key ',prefix-cmd))))
+
+     (when evil-keys
+       (if (or minor-modes major-modes)
+          `((eval-after-load 'evil
+              '(progn
+                 (dolist (key (bind-map-kbd-keys (list ,@evil-keys)))
+                   (dolist (state ',evil-states)
+                     (when ',major-modes
+                       (define-key
+                         (evil-get-auxiliary-keymap ,root-map state t)
+                         key ',prefix-cmd))
+                     (dolist (mode ',minor-modes)
+                       (when (fboundp 'evil-define-minor-mode-key)
+                         (evil-define-minor-mode-key
+                          state mode key ',prefix-cmd)))))
+                 (evil-normalize-keymaps))))
+        `((eval-after-load 'evil
+            '(progn
+               (dolist (key (bind-map-kbd-keys (list ,@evil-keys)))
+                 (dolist (state ',evil-states)
+                   (when ,override-minor-modes
+                     (push (list ',override-mode state key ',prefix-cmd)
+                           bind-map-evil-local-bindings))
+                   (evil-global-set-key state key ',prefix-cmd)))
+               (evil-normalize-keymaps)))))))))
 (put 'bind-map 'lisp-indent-function 'defun)
 
 ;;;###autoload



reply via email to

[Prev in Thread] Current Thread [Next in Thread]