aboutsummaryrefslogtreecommitdiffstats
path: root/README.org
diff options
context:
space:
mode:
authorJustin Burkett2020-08-28 10:17:40 -0400
committerJustin Burkett2020-08-28 10:17:40 -0400
commitebb4e92b3ccab1d813346e24dccf9692850754db (patch)
treedabadbfd664482690440523b22452fb4c98e763f /README.org
parente48e190a75a0c176e1deac218b891e77792d6921 (diff)
downloademacs-ebb4e92b3ccab1d813346e24dccf9692850754db.tar.gz
emacs-ebb4e92b3ccab1d813346e24dccf9692850754db.zip
Add which-key-add-keymap-based-replacements
This is an alternative to advising define-key using which-key-enable-extended-define-key, but functions the same beneath the surface. Ref #226 #261
Diffstat (limited to 'README.org')
-rw-r--r--README.org28
1 files changed, 27 insertions, 1 deletions
diff --git a/README.org b/README.org
index cb31655237b..c335e457b30 100644
--- a/README.org
+++ b/README.org
@@ -4,6 +4,11 @@
4 4
5** Recent Changes 5** Recent Changes
6 6
7*** 2020-08-28: Added =which-key-add-keymap-based-replacements=
8 This function provides an alternative interface allowing replacements to be
9 stored directly in keymaps, allowing one to avoid using
10 =which-key-replacement-alist=, which may cause performance issues when it
11 gets very big.
7*** 2019-08-01: Added =which-key-show-early-on-C-h= 12*** 2019-08-01: Added =which-key-show-early-on-C-h=
8 Allows one to trigger =which-key= on demand, rather than automatically. See 13 Allows one to trigger =which-key= on demand, rather than automatically. See
9 the docstring and [[#manual-activation][Manual Activation]]. 14 the docstring and [[#manual-activation][Manual Activation]].
@@ -29,6 +34,7 @@
29** Table of Contents :TOC_3: 34** Table of Contents :TOC_3:
30- [[#which-key][which-key]] 35- [[#which-key][which-key]]
31 - [[#recent-changes][Recent Changes]] 36 - [[#recent-changes][Recent Changes]]
37 - [[#2020-08-28-added-which-key-add-keymap-based-replacements][2020-08-28: Added =which-key-add-keymap-based-replacements=]]
32 - [[#2019-08-01-added-which-key-show-early-on-c-h][2019-08-01: Added =which-key-show-early-on-C-h=]] 38 - [[#2019-08-01-added-which-key-show-early-on-c-h][2019-08-01: Added =which-key-show-early-on-C-h=]]
33 - [[#2017-12-13-added-which-key-enable-extended-define-key][2017-12-13: Added =which-key-enable-extended-define-key=]] 39 - [[#2017-12-13-added-which-key-enable-extended-define-key][2017-12-13: Added =which-key-enable-extended-define-key=]]
34 - [[#2017-11-13-added-which-key-show-major-mode][2017-11-13: Added =which-key-show-major-mode=]] 40 - [[#2017-11-13-added-which-key-show-major-mode][2017-11-13: Added =which-key-show-major-mode=]]
@@ -255,7 +261,7 @@
255 idea of behind each alist is that you specify a selection string in the 261 idea of behind each alist is that you specify a selection string in the
256 =car= of each cons cell and the replacement string in the =cdr=. 262 =car= of each cons cell and the replacement string in the =cdr=.
257 263
258**** Automatic 264**** Automatic ("keymap-based") replacement
259 A newer option is to set =which-key-enable-extended-define-key= which 265 A newer option is to set =which-key-enable-extended-define-key= which
260 advises =define-key= to allow which-key to pre-process its arguments. The 266 advises =define-key= to allow which-key to pre-process its arguments. The
261 statement 267 statement
@@ -273,6 +279,26 @@
273 (define-key some-map "b" '("bar-prefix")) 279 (define-key some-map "b" '("bar-prefix"))
274 #+END_SRC 280 #+END_SRC
275 281
282 If you do not want to enable the advise on =define-key=, you may also use
283 =which-key-add-keymap-based-replacements=. The above examples can be
284 alternatively written as
285
286 #+BEGIN_SRC emacs-lisp
287 (which-key-add-keymap-based-replacements some-map
288 "f" '("foo" . long-name-for-command-foo)
289 ;; or
290 ;; "f" "foo"
291 "b" '("bar-prefix")
292 ;; or
293 ;; "b" "bar-prefix"
294 )
295 #+END_SRC
296
297 Note that while the alternative methods below use
298 =which-key-replacement-alist=, the "keymap-based" replacements store
299 replacements in the keymaps themselves, so should avoid performance issues
300 when =which-key-replacement-alist= becomes very large.
301
276**** "Key-Based" replacement 302**** "Key-Based" replacement
277 Using this method, the description of a key is replaced using a string that 303 Using this method, the description of a key is replaced using a string that
278 you provide. Here's an example 304 you provide. Here's an example