[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/which-key d794c4a 51/51: Improve keymap-based-replaceme
From: |
Stefan Monnier |
Subject: |
[elpa] externals/which-key d794c4a 51/51: Improve keymap-based-replacement description in README |
Date: |
Tue, 8 Sep 2020 10:26:22 -0400 (EDT) |
branch: externals/which-key
commit d794c4a0afdf9b9f0a9df86a9797789c703591ee
Author: Justin Burkett <justin@burkett.cc>
Commit: Justin Burkett <justin@burkett.cc>
Improve keymap-based-replacement description in README
Ref #263
---
README.org | 31 +++++++++++++++++++------------
1 file changed, 19 insertions(+), 12 deletions(-)
diff --git a/README.org b/README.org
index 301849e..92745ff 100644
--- a/README.org
+++ b/README.org
@@ -263,27 +263,29 @@
**** Automatic ("keymap-based") replacement
A newer option is to set =which-key-enable-extended-define-key= which
- advises =define-key= to allow which-key to pre-process its arguments. The
- statement
+ advises =define-key= to allow which-key to pre-process its arguments. With
+ this option enabled, the statement
#+BEGIN_SRC emacs-lisp
- (define-key some-map "f" '("foo" . long-name-for-command-foo))
+ (define-key some-map "f" '("foo" . command-foo))
#+END_SRC
- is valid in Emacs. Setting this variable makes which-key automatically
- replace the corresponding command name with the text in the string. A nice
- example is in naming prefixes. The following binds "b" to =nil= and names
- the binding as a prefix.
+ will both bind the command =command-foo= to "f" in =some-map= and tell
+ which-key to use the string "foo" for this command. This also works with
+ naming prefixes if you use =nil= for the command. The following binds "b"
+ to =nil= and names the binding as a prefix.
#+BEGIN_SRC emacs-lisp
(define-key some-map "b" '("bar-prefix"))
#+END_SRC
If you do not want to enable the advise on =define-key=, you may also use
- =which-key-add-keymap-based-replacements=. The above examples can be
+ =which-key-add-keymap-based-replacements=. The first example can be
alternatively written as
#+BEGIN_SRC emacs-lisp
+ (define-key some-map "f" 'command-foo)
+ (define-key some-map "b" some-prefix-map)
(which-key-add-keymap-based-replacements some-map
"f" '("foo" . long-name-for-command-foo)
;; or
@@ -294,10 +296,15 @@
)
#+END_SRC
- Note that while the alternative methods below use
- =which-key-replacement-alist=, the "keymap-based" replacements store
- replacements in the keymaps themselves, so should avoid performance issues
- when =which-key-replacement-alist= becomes very large.
+ Note that =which-key-add-keymap-based-replacements= will not bind a
+ command, so =define-key= must still be used.
+
+ There are other methods of telling which-key to replace command names,
+ which are described next. The keymap-based replacements should be the most
+ performant since they use built-in functionality of emacs. However, the
+ alternatives can be more flexible in telling which-key how and when to
+ replace text. They can be used simultaneously, but which-key will give
+ precedence to the keymap-based replacement when it exists.
**** "Key-Based" replacement
Using this method, the description of a key is replaced using a string
that
- [elpa] externals/which-key fb2bc8f 06/51: Add which-key-persistent-popup-p variable (#213), (continued)
- [elpa] externals/which-key fb2bc8f 06/51: Add which-key-persistent-popup-p variable (#213), Stefan Monnier, 2020/09/08
- [elpa] externals/which-key ba03e7e 05/51: Add translation keymap support (#210), Stefan Monnier, 2020/09/08
- [elpa] externals/which-key 2cb5ceb 12/51: Fix paging in which-key-manual-update, Stefan Monnier, 2020/09/08
- [elpa] externals/which-key a256c4b 13/51: Use which-key-idle-secondary-delay value in manual updates, Stefan Monnier, 2020/09/08
- [elpa] externals/which-key a916c9a 15/51: Fix typos (#222), Stefan Monnier, 2020/09/08
- [elpa] externals/which-key 45bfcd3 22/51: Make which-key-show prefix mode-line work like top and bottom, Stefan Monnier, 2020/09/08
- [elpa] externals/which-key 1231016 29/51: More workflow fixes, Stefan Monnier, 2020/09/08
- [elpa] externals/which-key 7bc87e0 41/51: Test once a month, Stefan Monnier, 2020/09/08
- [elpa] externals/which-key ebb4e92 47/51: Add which-key-add-keymap-based-replacements, Stefan Monnier, 2020/09/08
- [elpa] externals/which-key e048b2a 48/51: Stop testing against v24.5, Stefan Monnier, 2020/09/08
- [elpa] externals/which-key d794c4a 51/51: Improve keymap-based-replacement description in README,
Stefan Monnier <=
- [elpa] externals/which-key cf8572a 07/51: which-key-persistent-popup-p -> which-key-persistent-popup, Stefan Monnier, 2020/09/08
- [elpa] externals/which-key 8554a9f 17/51: Generalize C-h commands to use help-char, Stefan Monnier, 2020/09/08
- [elpa] externals/which-key 5cec113 10/51: Announce which-key-manual-update, Stefan Monnier, 2020/09/08
- [elpa] externals/which-key dcb9820 16/51: Default to imprecise window fitting on terminal, Stefan Monnier, 2020/09/08
- [elpa] externals/which-key e554326 49/51: Remove testing badge from README, Stefan Monnier, 2020/09/08
- [elpa] externals/which-key db3d003 21/51: Add full keymap versions of show-{major, minor}-mode, Stefan Monnier, 2020/09/08
- [elpa] externals/which-key 8b49ae9 42/51: Fix last commit, Stefan Monnier, 2020/09/08
- [elpa] externals/which-key b11227b 23/51: Strip out advice in command docstrings, Stefan Monnier, 2020/09/08
- [elpa] externals/which-key 9ff54ff 37/51: Fix short windows being resized, Stefan Monnier, 2020/09/08
- [elpa] externals/which-key 9550707 40/51: Merge remote-tracking branch 'hlissner/patch-1', Stefan Monnier, 2020/09/08