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

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

[elpa] externals/embark ccb7e3a718 3/3: Merge pull request #587 from min


From: ELPA Syncer
Subject: [elpa] externals/embark ccb7e3a718 3/3: Merge pull request #587 from minad/keymap-fixes
Date: Mon, 30 Jan 2023 07:57:41 -0500 (EST)

branch: externals/embark
commit ccb7e3a718e43a8b056208ece4646d0b921668e5
Merge: 5d9fc9c562 40c4991be0
Author: Omar Antolín Camarena <omar.antolin@gmail.com>
Commit: GitHub <noreply@github.com>

    Merge pull request #587 from minad/keymap-fixes
    
    Keymap fixes
---
 README.org        |  76 ++++++++++++------------
 embark-consult.el |  54 +++++++++--------
 embark-org.el     | 175 +++++++++++++++++++++++++++---------------------------
 embark.el         |  22 +++----
 embark.texi       |  52 ++++++++--------
 5 files changed, 189 insertions(+), 190 deletions(-)

diff --git a/README.org b/README.org
index e22c489b9b..898bc691a9 100644
--- a/README.org
+++ b/README.org
@@ -388,23 +388,23 @@ Embark comes with the following indicators:
 - =embark-minimal-indicator=: shows a messages in the echo area or
   minibuffer prompt showing the current target and the types of all
   targets starting with the current one; this one is on by default.
-  
+
 - =embark-highlight-indicator=: highlights the target at point;
   also on by default.
-  
+
 - =embark-verbose-indicator=: displays a table of actions and their key
   bindings in a buffer; this is not on by default, in favor of the
   mixed indicator described next.
-  
+
 - =embark-mixed-indicator=: starts out by behaving as the minimal
   indicator but after a short delay acts as the verbose indicator;
   this is on by default.
-  
+
 - =embark-isearch-highlight-indicator=: this only does something when
   the current target is the symbol at point, in which case it
   lazily highlights all occurrences of that symbol in the current
   buffer, like isearch; also on by default.
-  
+
 Users of the popular [[https://github.com/justbur/emacs-which-key][which-key]] 
package may prefer to use the
 =embark-which-key-indicator= from the 
[[https://github.com/oantolin/embark/wiki/Additional-Configuration#use-which-key-like-a-key-menu-prompt][Embark
 wiki]]. Just copy its
 definition from the wiki into your configuration and customize the
@@ -633,24 +633,23 @@ For around-action hooks:
 
 ** Creating your own keymaps
 
-All internal keymaps are defined with a helper macro
-=embark-define-keymap= that you can use to define your own keymaps,
-whether they are for new categories in =embark-keymap-alist= or for any
-other purpose! For example a simple version of the file action keymap
+All internal keymaps are defined with the standard helper macro
+=defvar-keymap=. For example a simple version of the file action keymap
 could be defined as follows:
 
 #+BEGIN_SRC emacs-lisp
-  (embark-define-keymap embark-file-map
-    "Example keymap with a few file actions"
-    ("d" delete-file)
-    ("r" rename-file)
-    ("c" copy-file))
+  (defvar-keymap embark-file-map
+    :doc "Example keymap with a few file actions"
+    :parent embark-general-map
+    "d" #'delete-file
+    "r" #'rename-file
+    "c" #'copy-file)
 #+END_SRC
 
-Remember also that these action keymaps are perfectly normal Emacs
-keymaps, and do not need to be created with this helper macro. You
-can use the built-in =define-key=, or your favorite external package
-such as =bind-key= or =general.el= to manage them.
+These action keymaps are perfectly normal Emacs
+keymaps.  You may want to inherit from the =embark-general-map= if you
+want to access the default Embark actions. Note that =embark-collect=
+and =embark-export= are also made available via =embark-general-map=.
 
 ** Defining actions for new categories of targets
 
@@ -743,11 +742,12 @@ commands, instead of defining new ones.
  the kill-ring, which you get for free). Then this will do:
 
  #+begin_src emacs-lisp
-   (embark-define-keymap embark-tab-actions
-     "Keymap for actions for tab-bar tabs (when mentioned by name)."
-     ("s" tab-bar-select-tab-by-name)
-     ("r" tab-bar-rename-tab-by-name)
-     ("k" tab-bar-close-tab-by-name))
+   (defvar-keymap embark-tab-actions
+     :doc "Keymap for actions for tab-bar tabs (when mentioned by name)."
+     :parent embark-general-map
+     "s" #'tab-bar-select-tab-by-name
+     "r" #'tab-bar-rename-tab-by-name
+     "k" #'tab-bar-close-tab-by-name)
 
    (add-to-list 'embark-keymap-alist '(tab . embark-tab-actions))
  #+end_src
@@ -805,7 +805,7 @@ included in the list =embark-indicators=).
              (str (buffer-substring-no-properties beg end)))
         (save-match-data
           (when (string-match "wikipedia:\\([[:alnum:]_]+\\)" str)
-            `(url 
+            `(url
               ,(format "https://en.wikipedia.org/wiki/%s";
                        (match-string 1 str))
               ,beg . ,end))))))
@@ -853,7 +853,7 @@ included in the list =embark-indicators=).
   prompt, which would almost never be sensible. Also consider this as
   a warning to structure your own action commands so that if they use
   =y-or-n-p=, they do so only after the prompting for the target.
-  
+
   Here is a simple example illustrating the various ways of reading
   input from the user mentioned above. Bind the following commands to
   the =embark-symbol-map= to be used as actions, then put the point on
@@ -863,27 +863,27 @@ included in the list =embark-indicators=).
     (defun example-action-command1 ()
       (interactive)
       (message "The input was `%s'." (read-from-minibuffer "Input: ")))
-    
+
     (defun example-action-command2 (arg input1 input2)
       (interactive "P\nsInput 1: \nsInput 2: ")
       (message "The first input %swas `%s', and the second was `%s'."
                (if arg "truly " "")
                input1
                input2))
-    
+
     (defun example-action-command3 ()
       (interactive)
       (message "Your selection was `%s'."
                (completing-read "Select: " '("E" "M" "B" "A" "R" "K"))))
-    
+
     (defun example-action-command4 ()
       (interactive)
       (message "I don't prompt you for input and thus ignore the target!"))
-    
-    (define-key embark-symbol-map "X1" #'example-action-command1)
-    (define-key embark-symbol-map "X2" #'example-action-command2)
-    (define-key embark-symbol-map "X3" #'example-action-command3)
-    (define-key embark-symbol-map "X4" #'example-action-command4)
+
+    (keymap-set embark-symbol-map "X 1" #'example-action-command1)
+    (keymap-set embark-symbol-map "X 2" #'example-action-command2)
+    (keymap-set embark-symbol-map "X 3" #'example-action-command3)
+    (keymap-set embark-symbol-map "X 4" #'example-action-command4)
   #+end_src
 
   Also note that if you are using the key bindings to call actions,
@@ -893,9 +893,9 @@ included in the list =embark-indicators=).
   This ability to pass prefix arguments to actions is useful for some
   actions in the default configuration, such as
   =embark-shell-command-on-buffer=.
-  
+
 ** Non-interactive functions as actions
-   
+
   Alternatively, Embark does support one other type of action: a
   non-interactive function of a single argument. The target is passed
   as argument to the function. For example:
@@ -904,7 +904,7 @@ included in the list =embark-indicators=).
     (defun example-action-function (target)
       (message "The target was `%s'." target))
 
-    (define-key embark-symbol-map "X4" #'example-action-function)
+    (keymap-set embark-symbol-map "X 4" #'example-action-function)
   #+end_src
 
   Note that normally binding non-interactive functions in a keymap is
@@ -923,7 +923,7 @@ included in the list =embark-indicators=).
      no text properties. For certain advanced uses you may want the
      action to receive a string /with/ some text properties, or even a
      non-string target.
-  
+
 * Embark, Marginalia and Consult
 
 Embark cooperates well with the 
[[https://github.com/minad/marginalia][Marginalia]] and 
[[https://github.com/minad/consult][Consult]] packages.
@@ -1043,7 +1043,7 @@ behavior of Consult commands when used as Embark actions 
are:
 - =consult-imenu= will search for the target and take you directly to
   the location if it matches a unique imenu entry, otherwise it will
   leave the minibuffer open so you can navigate among the matches.
-   
+
 * Resources
 
 If you want to learn more about how others have used Embark here are
diff --git a/embark-consult.el b/embark-consult.el
index c28212be89..56a99d5018 100644
--- a/embark-consult.el
+++ b/embark-consult.el
@@ -7,7 +7,7 @@
 ;; Keywords: convenience
 ;; Version: 0.6
 ;; Homepage: https://github.com/oantolin/embark
-;; Package-Requires: ((emacs "27.1") (embark "0.17") (consult "0.17"))
+;; Package-Requires: ((emacs "27.1") (embark "0.20") (consult "0.17"))
 
 ;; This program is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
@@ -24,7 +24,7 @@
 
 ;;; Commentary:
 
-;; This package provides integration between Embark and Consult. The package
+;; This package provides integration between Embark and Consult.  The package
 ;; will be loaded automatically by Embark.
 
 ;; Some of the functionality here was previously contained in Embark
@@ -45,7 +45,7 @@
 ;; Additionally this package contains some functionality that has
 ;; never been in Embark: access to Consult preview from auto-updating
 ;; Embark Collect buffer that is associated to an active minibuffer
-;; for a Consult command. For information on Consult preview, see
+;; for a Consult command.  For information on Consult preview, see
 ;; Consult's info manual or its readme on GitHub.
 
 ;; If you always want the minor mode enabled whenever it possible use:
@@ -55,7 +55,7 @@
 ;; If you don't want the minor mode automatically on and prefer to
 ;; trigger the consult previews manually use this instead:
 
-;; (define-key embark-collect-mode-map (kbd "C-j")
+;; (keymap-set embark-collect-mode-map "C-j"
 ;;   #'consult-preview-at-point)
 
 ;;; Code:
@@ -160,10 +160,10 @@ This function is meant to be added to 
`embark-collect-mode-hook'."
 (defvar wgrep-header/footer-parser)
 (declare-function wgrep-setup "ext:wgrep")
 
-(embark-define-keymap embark-consult-revert-map
-  "A keymap with a binding for revert-buffer."
+(defvar-keymap embark-consult-revert-map
+  :doc "A keymap with a binding for revert-buffer."
   :parent nil
-  ("g" revert-buffer))
+  "g" #'revert-buffer)
 
 (defun embark-consult-export-grep (lines)
   "Create a grep mode buffer listing LINES."
@@ -276,6 +276,7 @@ This function is meant to be added to 
`embark-collect-mode-hook'."
 ;;; Support for consult-man and consult-info
 
 (defun embark-consult-man (cand)
+  "Default action override for `consult-man', open CAND man page."
   (man (get-text-property 0 'consult-man cand)))
 
 (setf (alist-get 'consult-man embark-default-action-overrides)
@@ -284,6 +285,7 @@ This function is meant to be added to 
`embark-collect-mode-hook'."
 (declare-function consult-info--action "ext:consult-info")
 
 (defun embark-consult-info (cand)
+  "Default action override for `consult-info', open CAND info manual."
   (consult-info--action cand)
   (pulse-momentary-highlight-one-line (point)))
 
@@ -295,28 +297,28 @@ This function is meant to be added to 
`embark-collect-mode-hook'."
 
 ;;; Bindings for consult commands in embark keymaps
 
-(define-key embark-become-file+buffer-map "Cb" #'consult-buffer)
-(define-key embark-become-file+buffer-map "C4b" #'consult-buffer-other-window)
+(keymap-set embark-become-file+buffer-map "C b" #'consult-buffer)
+(keymap-set embark-become-file+buffer-map "C 4 b" 
#'consult-buffer-other-window)
 
 ;;; Support for Consult search commands
 
-(embark-define-keymap embark-consult-sync-search-map
-  "Keymap for Consult sync search commands"
+(defvar-keymap embark-consult-sync-search-map
+  :doc "Keymap for Consult sync search commands"
   :parent nil
-  ("o" consult-outline)
-  ("i" 'consult-imenu)
-  ("I" 'consult-imenu-multi)
-  ("l" consult-line)
-  ("L" consult-line-multi))
-
-(embark-define-keymap embark-consult-async-search-map
-  "Keymap for Consult async search commands"
+  "o" #'consult-outline
+  "i" 'consult-imenu
+  "I" 'consult-imenu-multi
+  "l" #'consult-line
+  "L" #'consult-line-multi)
+
+(defvar-keymap embark-consult-async-search-map
+  :doc "Keymap for Consult async search commands"
   :parent nil
-  ("g" consult-grep)
-  ("r" consult-ripgrep)
-  ("G" consult-git-grep)
-  ("f" consult-find)
-  ("F" consult-locate))
+  "g" #'consult-grep
+  "r" #'consult-ripgrep
+  "G" #'consult-git-grep
+  "f" #'consult-find
+  "F" #'consult-locate)
 
 (defvar embark-consult-search-map
   (keymap-canonicalize
@@ -325,12 +327,12 @@ This function is meant to be added to 
`embark-collect-mode-hook'."
   "Keymap for all Consult search commands.")
 
 (fset 'embark-consult-sync-search-map embark-consult-sync-search-map)
-(define-key embark-become-match-map "C" 'embark-consult-sync-search-map)
+(keymap-set embark-become-match-map "C" 'embark-consult-sync-search-map)
 
 (cl-pushnew 'embark-consult-async-search-map embark-become-keymaps)
 
 (fset 'embark-consult-search-map embark-consult-search-map)
-(define-key embark-general-map "C" 'embark-consult-search-map)
+(keymap-set embark-general-map "C" 'embark-consult-search-map)
 
 (map-keymap
  (lambda (_key cmd)
diff --git a/embark-org.el b/embark-org.el
index e6580d1678..dc265e9832 100644
--- a/embark-org.el
+++ b/embark-org.el
@@ -2,13 +2,6 @@
 
 ;; Copyright (C) 2022  Free Software Foundation, Inc.
 
-;; Author: Omar Antolín Camarena <omar@matem.unam.mx>
-;; Maintainer: Omar Antolín Camarena <omar@matem.unam.mx>
-;; Keywords: convenience
-;; Version: 0.2
-;; Homepage: https://github.com/oantolin/embark
-;; Package-Requires: ((emacs "27.1"))
-
 ;; This program is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
 ;; the Free Software Foundation, either version 3 of the License, or
@@ -143,7 +136,7 @@
 (add-to-list 'embark-pre-action-hooks
              '(embark-org-copy-as-markdown embark--mark-target))
 
-(define-key embark-region-map "M" #'embark-org-copy-as-markdown) ; good idea?
+(keymap-set embark-region-map "M" #'embark-org-copy-as-markdown) ; good idea?
 
 ;;; Tables
 
@@ -154,29 +147,31 @@
 (push 'embark--ignore-target
       (alist-get 'org-table-edit-field embark-target-injection-hooks))
 
-(embark-define-keymap embark-org-table-cell-map
-  "Keymap for actions the current cells, column or row of an Org table."
+(defvar-keymap embark-org-table-cell-map
+  :doc "Keymap for actions the current cells, column or row of an Org table."
+  :parent embark-general-map
   ;; TODO: default action?
-  ("<up>"    org-table-move-cell-up)
-  ("<down>"  org-table-move-cell-down)
-  ("<left>"  org-table-move-cell-left)
-  ("<right>" org-table-move-cell-right)
-  ("=" org-table-eval-formula)
-  ("e" org-table-edit-field)
-  ("g" org-table-recalculate))
-
-(embark-define-keymap embark-org-table-map
-  "Keymap for actions on entire Org table."
+  "<up>"    #'org-table-move-cell-up
+  "<down>"  #'org-table-move-cell-down
+  "<left>"  #'org-table-move-cell-left
+  "<right>" #'org-table-move-cell-right
+  "=" #'org-table-eval-formula
+  "e" #'org-table-edit-field
+  "g" #'org-table-recalculate)
+
+(defvar-keymap embark-org-table-map
+  :doc "Keymap for actions on entire Org table."
+  :parent embark-general-map
   ;; TODO: default action?
-  ("=" org-table-edit-formulas)
-  ("s" org-table-sort-lines)
-  ("t" org-table-transpose-table-at-point)
-  ("c" org-table-convert)
-  ("f" org-table-follow-field-mode)
-  ("y" org-table-paste-rectangle)
-  ("d" org-table-toggle-formula-debugger)
-  ("i" org-table-iterate)
-  ("e" org-table-export))
+  "=" #'org-table-edit-formulas
+  "s" #'org-table-sort-lines
+  "t" #'org-table-transpose-table-at-point
+  "c" #'org-table-convert
+  "f" #'org-table-follow-field-mode
+  "y" #'org-table-paste-rectangle
+  "d" #'org-table-toggle-formula-debugger
+  "i" #'org-table-iterate
+  "e" #'org-table-export)
 
 (push 'embark--ignore-target            ; prompts for file name
       (alist-get 'org-table-export embark-target-injection-hooks))
@@ -285,40 +280,41 @@ what part or in what format the link is copied."
 (embark-org-define-link-copier target target "'s target")
 
 (defalias 'embark-org-copy-link-inner-target #'kill-new
-  "Copy 'inner part' of the Org link at point's target.
+  "Copy inner part of the Org link at point's target.
 For mailto and elisp links, the inner part is the portion of the
-target after 'mailto:' or 'elisp:'.
+target after `mailto:' or `elisp:'.
 
 For file links the inner part is the file name, without the
-'file:' prefix and without '::' suffix (used for line numbers,
+`file:' prefix and without `::' suffix (used for line numbers,
 IDs or search terms).
 
-For URLs the inner part is the whole target including the 'http:'
-or 'https:' prefix.  For any other type of link the inner part is
+For URLs the inner part is the whole target including the `http:'
+or `https:' prefix.  For any other type of link the inner part is
 also the whole target.")
 
-(embark-define-keymap embark-org-link-copy-map
-  "Keymap for different ways to copy Org links to the kill-ring.
+(defvar-keymap embark-org-link-copy-map
+  :doc "Keymap for different ways to copy Org links to the kill-ring.
 
 You should bind w in this map to your most frequently used link
 copying function.  The default is for w to copy the \"inner
 target\" (see `embark-org-copy-link-inner-target'); which is also
 bound to i."
   :parent nil
-  ("w" embark-org-copy-link-inner-target)
-  ("f" embark-org-copy-link-in-full)
-  ("d" embark-org-copy-link-description)
-  ("t" embark-org-copy-link-target)
-  ("i" embark-org-copy-link-inner-target)
-  ("m" embark-org-copy-as-markdown))
+  "w" #'embark-org-copy-link-inner-target
+  "f" #'embark-org-copy-link-in-full
+  "d" #'embark-org-copy-link-description
+  "t" #'embark-org-copy-link-target
+  "i" #'embark-org-copy-link-inner-target
+  "m" #'embark-org-copy-as-markdown)
 
 (fset 'embark-org-link-copy-map embark-org-link-copy-map)
 
-(embark-define-keymap embark-org-link-map
-  "Keymap for actions on Org links."
-  ("RET" org-open-at-point)
-  ("'" org-insert-link)
-  ("w" 'embark-org-link-copy-map))
+(defvar-keymap embark-org-link-map
+  :doc "Keymap for actions on Org links."
+  :parent embark-general-map
+  "RET" #'org-open-at-point
+  "'" #'org-insert-link
+  "w" #'embark-org-link-copy-map)
 
 ;; The reason for this is left as an exercise to the reader.
 ;; Solution: Na ryvfc gnetrg znl cebzcg gur hfre sbe fbzrguvat!
@@ -341,17 +337,18 @@ bound to i."
 
 ;;; Source blocks and babel calls
 
-(embark-define-keymap embark-org-src-block-map
-  "Keymap for actions on Org source blocks."
-  ("RET" org-babel-execute-src-block)
-  ("c" org-babel-check-src-block)
-  ("k" org-babel-remove-result-one-or-many)
-  ("p" org-babel-previous-src-block)
-  ("n" org-babel-next-src-block)
-  ("t" org-babel-tangle)
-  ("s" org-babel-switch-to-session)
-  ("l" org-babel-load-in-session)
-  ("'" org-edit-special))
+(defvar-keymap embark-org-src-block-map
+  :doc "Keymap for actions on Org source blocks."
+  :parent embark-general-map
+  "RET" #'org-babel-execute-src-block
+  "c" #'org-babel-check-src-block
+  "k" #'org-babel-remove-result-one-or-many
+  "p" #'org-babel-previous-src-block
+  "n" #'org-babel-next-src-block
+  "t" #'org-babel-tangle
+  "s" #'org-babel-switch-to-session
+  "l" #'org-babel-load-in-session
+  "'" #'org-edit-special)
 
 (dolist (motion '(org-babel-next-src-blockorg-babel-previous-src-block))
   (add-to-list 'embark-repeat-actions motion))
@@ -360,19 +357,20 @@ bound to i."
 
 ;;; List items
 
-(embark-define-keymap embark-org-item-map
-  "Keymap for actions on Org list items."
-  ("RET" org-toggle-checkbox)
-  ("c" org-toggle-checkbox)
-  ("t" org-toggle-item)
-  ("n" org-next-item)
-  ("p" org-previous-item)
-  ("<left>" org-outdent-item)
-  ("<right>" org-indent-item)
-  ("<up>" org-move-item-up)
-  ("<down>" org-move-item-down)
-  (">" org-indent-item-tree)
-  ("<" org-outdent-item-tree))
+(defvar-keymap embark-org-item-map
+  :doc "Keymap for actions on Org list items."
+  :parent embark-general-map
+  "RET" #'org-toggle-checkbox
+  "c" #'org-toggle-checkbox
+  "t" #'org-toggle-item
+  "n" #'org-next-item
+  "p" #'org-previous-item
+  "<left>" #'org-outdent-item
+  "<right>" #'org-indent-item
+  "<up>" #'org-move-item-up
+  "<down>" #'org-move-item-down
+  ">" #'org-indent-item-tree
+  "<" #'org-outdent-item-tree)
 
 (dolist (cmd '(org-toggle-checkbox
                org-toggle-item
@@ -390,14 +388,15 @@ bound to i."
 
 ;;; Org plain lists
 
-(embark-define-keymap embark-org-plain-list-map
-  "Keymap for actions on plain Org lists."
-  ("RET" org-list-repair)
-  ("r" org-list-repair)
-  ("s" org-sort-list)
-  ("b" org-cycle-list-bullet)
-  ("t" org-list-make-subtree)
-  ("c" org-toggle-checkbox))
+(defvar-keymap embark-org-plain-list-map
+  :doc "Keymap for actions on plain Org lists."
+  :parent embark-general-map
+  "RET" #'org-list-repair
+  "r" #'org-list-repair
+  "s" #'org-sort-list
+  "b" #'org-cycle-list-bullet
+  "t" #'org-list-make-subtree
+  "c" #'org-toggle-checkbox)
 
 (add-to-list 'embark-repeat-actions 'org-cycle-list-bullet)
 
@@ -405,6 +404,9 @@ bound to i."
 
 (cl-defun embark-org--toggle-checkboxes
     (&rest rest &key run type &allow-other-keys)
+  "Around action hook for `org-toggle-checkbox'.
+See `embark-around-action-hooks' for the keyword arguments RUN and TYPE.
+REST are the remaining arguments."
   (apply (if (eq type 'org-plain-list) #'embark--mark-target run)
          :type type
          rest))
@@ -414,16 +416,17 @@ bound to i."
 
 ;;; "Encode" region using Org export in place
 
-(embark-define-keymap embark-org-export-in-place-map
-  "Keymap for actions which replace the region by an exported version."
-  ("m" org-md-convert-region-to-md)
-  ("h" org-html-convert-region-to-html)
-  ("a" org-ascii-convert-region-to-ascii)
-  ("l" org-latex-convert-region-to-latex))
+(defvar-keymap embark-org-export-in-place-map
+  :doc "Keymap for actions which replace the region by an exported version."
+  :parent embark-general-map
+  "m" #'org-md-convert-region-to-md
+  "h" #'org-html-convert-region-to-html
+  "a" #'org-ascii-convert-region-to-ascii
+  "l" #'org-latex-convert-region-to-latex)
 
 (fset 'embark-org-export-in-place-map embark-org-export-in-place-map)
 
-(define-key embark-encode-map "o" 'embark-org-export-in-place-map)
+(keymap-set embark-encode-map "o" 'embark-org-export-in-place-map)
 
 (provide 'embark-org)
 ;;; embark-org.el ends here
diff --git a/embark.el b/embark.el
index 4ab6a98892..9cee8675af 100644
--- a/embark.el
+++ b/embark.el
@@ -7,7 +7,7 @@
 ;; Keywords: convenience
 ;; Version: 0.20
 ;; Homepage: https://github.com/oantolin/embark
-;; Package-Requires: ((emacs "26.1") (compat "29.1.3.0"))
+;; Package-Requires: ((emacs "27.1") (compat "29.1.3.0"))
 
 ;; This file is part of GNU Emacs.
 
@@ -1273,7 +1273,7 @@ UPDATE function is passed to it."
             (minibuffer-with-setup-hook
                 (lambda ()
                   (let ((map (make-sparse-keymap)))
-                    (define-key map (kbd "M-q")
+                    (define-key map "\M-q"
                                 (lambda ()
                                   (interactive)
                                   (with-current-buffer buf
@@ -1917,7 +1917,7 @@ minibuffer before executing the action."
                                 (set--this-command-keys
                                  (if (characterp last-command-event)
                                      (string last-command-event)
-                                   (kbd "RET"))))
+                                  "\r")))
                               (setq this-command action)
                               (embark--run-around-action-hooks
                                action target quit)))
@@ -2058,7 +2058,7 @@ keymap for the given type."
       (alist-get type embark-default-action-overrides)
       (alist-get t embark-default-action-overrides)
       embark--command
-      (lookup-key (embark--raw-action-keymap type) (kbd "RET"))))
+      (lookup-key (embark--raw-action-keymap type) "\r")))
 
 (defun embark--rotate (list k)
   "Rotate LIST by K elements and return the rotated list."
@@ -2778,13 +2778,9 @@ If NESTED is non-nil subkeymaps are not flattened."
   "n" #'forward-button
   "p" #'backward-button
   "}" 'outline-next-heading
-  "{" 'outline-previous-heading)
-
-(define-key embark-collect-mode-map
-  [remap forward-paragraph] 'outline-next-heading)
-
-(define-key embark-collect-mode-map
-    [remap backward-paragraph] 'outline-previous-heading)
+  "{" 'outline-previous-heading
+  "<remap> <forward-paragraph>" 'outline-next-heading
+  "<remap> <backward-paragraph>" 'outline-previous-heading)
 
 (defconst embark-collect--outline-string (string #x210000)
   "Special string used for outine headings in Embark Collect buffers.
@@ -4347,12 +4343,12 @@ This simply calls RUN with the REST of its arguments 
inside
   :doc "Embark become keymap for files and buffers."
   :parent embark-meta-map
   "f" #'find-file
-  "4f" #'find-file-other-window
+  "4 f" #'find-file-other-window
   "." #'find-file-at-point
   "p" #'project-find-file
   "r" #'recentf-open-files
   "b" #'switch-to-buffer
-  "4b" #'switch-to-buffer-other-window
+  "4 b" #'switch-to-buffer-other-window
   "l" #'locate
   "L" #'find-library
   "v" #'vc-dir)
diff --git a/embark.texi b/embark.texi
index 5d355139bf..b89bb7d6b0 100644
--- a/embark.texi
+++ b/embark.texi
@@ -790,24 +790,23 @@ available for users.
 @node Creating your own keymaps
 @section Creating your own keymaps
 
-All internal keymaps are defined with a helper macro
-@samp{embark-define-keymap} that you can use to define your own keymaps,
-whether they are for new categories in @samp{embark-keymap-alist} or for any
-other purpose! For example a simple version of the file action keymap
+All internal keymaps are defined with the standard helper macro
+@samp{defvar-keymap}. For example a simple version of the file action keymap
 could be defined as follows:
 
 @lisp
-(embark-define-keymap embark-file-map
-  "Example keymap with a few file actions"
-  ("d" delete-file)
-  ("r" rename-file)
-  ("c" copy-file))
+(defvar-keymap embark-file-map
+  :doc "Example keymap with a few file actions"
+  :parent embark-general-map
+  "d" #'delete-file
+  "r" #'rename-file
+  "c" #'copy-file)
 @end lisp
 
-Remember also that these action keymaps are perfectly normal Emacs
-keymaps, and do not need to be created with this helper macro. You
-can use the built-in @samp{define-key}, or your favorite external package
-such as @samp{bind-key} or @samp{general.el} to manage them.
+These action keymaps are perfectly normal Emacs
+keymaps.  You may want to inherit from the @samp{embark-general-map} if you
+want to access the default Embark actions. Note that @samp{embark-collect}
+and @samp{embark-export} are also made available via @samp{embark-general-map}.
 
 @node Defining actions for new categories of targets
 @section Defining actions for new categories of targets
@@ -912,11 +911,12 @@ Let's say we want to offer select, rename and close 
actions for tabs
 the kill-ring, which you get for free). Then this will do:
 
 @lisp
-(embark-define-keymap embark-tab-actions
-  "Keymap for actions for tab-bar tabs (when mentioned by name)."
-  ("s" tab-bar-select-tab-by-name)
-  ("r" tab-bar-rename-tab-by-name)
-  ("k" tab-bar-close-tab-by-name))
+(defvar-keymap embark-tab-actions
+  :doc "Keymap for actions for tab-bar tabs (when mentioned by name)."
+  :parent embark-general-map
+  "s" #'tab-bar-select-tab-by-name
+  "r" #'tab-bar-rename-tab-by-name
+  "k" #'tab-bar-close-tab-by-name)
 
 (add-to-list 'embark-keymap-alist '(tab . embark-tab-actions))
 @end lisp
@@ -928,18 +928,15 @@ without confirmation is dangerous? You have a couple of 
options:
 @item
 You can keep using the @samp{tab-bar-close-tab-by-name} command, but have
 Embark ask you for confirmation:
-@end enumerate
 @lisp
 (push #'embark--confirm
       (alist-get 'tab-bar-close-tab-by-name
                  embark-pre-action-hooks))
 @end lisp
 
-@enumerate
 @item
 You can write your own command that prompts for confirmation and
 use that instead of @samp{tab-bar-close-tab-by-name} in the above keymap:
-@end enumerate
 @lisp
 (defun my-confirm-close-tab-by-name (tab)
   (interactive "sTab to close: ")
@@ -952,6 +949,7 @@ independently of Embark. Using it from @samp{M-x} leaves 
something to be
 desired, though, since you don't get completion for the tab names.
 You can fix this if you wish as described in the previous section.
 @end enumerate
+@end enumerate
 
 @node New target example in regular buffers - short Wikipedia links
 @subsection New target example in regular buffers - short Wikipedia links
@@ -982,7 +980,7 @@ included in the list @samp{embark-indicators}).
            (str (buffer-substring-no-properties beg end)))
       (save-match-data
         (when (string-match "wikipedia:\\([[:alnum:]_]+\\)" str)
-          `(url 
+          `(url
             ,(format "https://en.wikipedia.org/wiki/%s";
                      (match-string 1 str))
             ,beg . ,end))))))
@@ -1058,10 +1056,10 @@ some symbol and run them with @samp{embark-act}:
   (interactive)
   (message "I don't prompt you for input and thus ignore the target!"))
 
-(define-key embark-symbol-map "X1" #'example-action-command1)
-(define-key embark-symbol-map "X2" #'example-action-command2)
-(define-key embark-symbol-map "X3" #'example-action-command3)
-(define-key embark-symbol-map "X4" #'example-action-command4)
+(keymap-set embark-symbol-map "X 1" #'example-action-command1)
+(keymap-set embark-symbol-map "X 2" #'example-action-command2)
+(keymap-set embark-symbol-map "X 3" #'example-action-command3)
+(keymap-set embark-symbol-map "X 4" #'example-action-command4)
 @end lisp
 
 Also note that if you are using the key bindings to call actions,
@@ -1087,7 +1085,7 @@ as argument to the function. For example:
 (defun example-action-function (target)
   (message "The target was `%s'." target))
 
-(define-key embark-symbol-map "X4" #'example-action-function)
+(keymap-set embark-symbol-map "X 4" #'example-action-function)
 @end lisp
 
 Note that normally binding non-interactive functions in a keymap is



reply via email to

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