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

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

[elpa] externals/embark b224505 1/2: Add embark-help-key, remove embark-


From: ELPA Syncer
Subject: [elpa] externals/embark b224505 1/2: Add embark-help-key, remove embark-keymap-help from embark-meta-map
Date: Tue, 9 Nov 2021 09:57:21 -0500 (EST)

branch: externals/embark
commit b224505c530fad9a791a66b9c2616d940397a816
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    Add embark-help-key, remove embark-keymap-help from embark-meta-map
    
    Treat the help key specially such that it is always available when
    acting with the keymap prompter, even if the action keymap does
    not contain such a binding. This special treatment is needed to
    ensure that the Embark help is always available. It is possible
    to disable the help binding by setting embark-help-key=nil. The
    embark-cycle-key has a similar treatment and is always available.
---
 embark.el | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/embark.el b/embark.el
index d3eef43..46ca0ae 100644
--- a/embark.el
+++ b/embark.el
@@ -216,6 +216,13 @@ This is the key representation accepted by `define-key'."
 If the key is set to nil it defaults to the global binding of
 `embark-act'.  The key must be either a string or a vector.  This
 is the key representation accepted by `define-key'."
+  :type '(choice key-sequence (const :tag "Use embark-act key" nil)))
+
+(defcustom embark-help-key "\C-h"
+  "Key used for help.
+
+The key must be either nil, a string or a vector.  This
+is the key representation accepted by `define-key'."
   :type '(choice key-sequence (const :tag "None" nil)))
 
 (defcustom embark-keybinding-repeat
@@ -889,6 +896,8 @@ If CYCLE is non-nil bind `embark-cycle'."
      (define-key map [13] (embark--default-action type))
      (when-let ((cycle-key (and cycle (embark--cycle-key))))
        (define-key map cycle-key #'embark-cycle))
+     (when embark-help-key
+       (define-key map embark-help-key #'embark-keymap-help))
      map)
    (symbol-value (or (alist-get type embark-keymap-alist)
                      (alist-get t embark-keymap-alist)))))
@@ -1960,11 +1969,14 @@ See `embark-act' for the meaning of the prefix ARG."
 
 (defun embark--become-keymap ()
   "Return keymap of commands to become for current command."
-  (make-composed-keymap
-   (cl-loop for keymap-name in embark-become-keymaps
-            for keymap = (symbol-value keymap-name)
-            when (where-is-internal embark--command (list keymap))
-            collect keymap)))
+  (let ((map (make-composed-keymap
+              (cl-loop for keymap-name in embark-become-keymaps
+                       for keymap = (symbol-value keymap-name)
+                       when (where-is-internal embark--command (list keymap))
+                       collect keymap))))
+    (when embark-help-key
+      (define-key map embark-help-key #'embark-keymap-help))
+    map))
 
 ;;;###autoload
 (defun embark-become (&optional full)
@@ -3323,7 +3335,6 @@ and leaves the point to the left of it."
 (embark-define-keymap embark-meta-map
   "Keymap for non-action Embark functions."
   :parent nil
-  ("C-h" embark-keymap-help)
   ("-" negative-argument)
   ("0" digit-argument)
   ("1" digit-argument)



reply via email to

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