[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/embark 40c4991be0 2/3: Update texi
From: |
ELPA Syncer |
Subject: |
[elpa] externals/embark 40c4991be0 2/3: Update texi |
Date: |
Mon, 30 Jan 2023 07:57:41 -0500 (EST) |
branch: externals/embark
commit 40c4991be02b5543c3583a8498055687d9b8eee3
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
Update texi
---
embark.texi | 52 +++++++++++++++++++++++++---------------------------
1 file changed, 25 insertions(+), 27 deletions(-)
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