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

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

[elpa] externals/hydra 1e72f96a14 15/46: hydra.el (defhydra): Add :base-


From: Stefan Monnier
Subject: [elpa] externals/hydra 1e72f96a14 15/46: hydra.el (defhydra): Add :base-map option to body plist
Date: Tue, 25 Oct 2022 22:27:20 -0400 (EDT)

branch: externals/hydra
commit 1e72f96a1434ab43769c0fe374072d3a7b704683
Author: Oleh Krehel <ohwoeowho@gmail.com>
Commit: Oleh Krehel <ohwoeowho@gmail.com>

    hydra.el (defhydra): Add :base-map option to body plist
    
    * README.md: Update
    
    Example:
    
        (defhydra hydra-numbers (:base-map (make-sparse-keymap))
          "test"
          ("0" (message "zero"))
          ("1" (message "one")))
    
    Fixes #285
---
 README.md | 3 +++
 hydra.el  | 6 ++++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index aa3356924d..0e165019c1 100644
--- a/README.md
+++ b/README.md
@@ -326,6 +326,9 @@ instead of `define-key` you can use this option.
 The `:bind` key can be overridden by each head. This is useful if you want to 
have a few heads that
 are not bound outside the hydra.
 
+### `:base-map`
+Use this option if you want to override `hydra-base-map` for the current hydra.
+
 ## `awesome-docstring`
 
 This can be a simple string used to build the final hydra hint.  However, if 
you start it with a
diff --git a/hydra.el b/hydra.el
index 7d3689e4b3..e9259f138c 100644
--- a/hydra.el
+++ b/hydra.el
@@ -1182,11 +1182,13 @@ result of `defhydra'."
   (when (keywordp (car body))
     (setq body (cons nil (cons nil body))))
   (condition-case-unless-debug err
-      (let* ((keymap (copy-keymap hydra-base-map))
-             (keymap-name (intern (format "%S/keymap" name)))
+      (let* ((keymap-name (intern (format "%S/keymap" name)))
              (body-name (intern (format "%S/body" name)))
              (body-key (cadr body))
              (body-plist (cddr body))
+             (base-map (or (eval (plist-get body-plist :base-map))
+                           hydra-base-map))
+             (keymap (copy-keymap base-map))
              (body-map (or (car body)
                            (plist-get body-plist :bind)))
              (body-pre (plist-get body-plist :pre))



reply via email to

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