branch: externals/which-key commit c47c72d1fe0d2e15482eee4af1bff2881bbe218e Author: Justin Burkett <jus...@burkett.cc> Commit: Justin Burkett <jus...@burkett.cc>
Cleanup whitespace in README --- README.org | 150 ++++++++++++++++++++++++++++++------------------------------- 1 file changed, 75 insertions(+), 75 deletions(-) diff --git a/README.org b/README.org index c9992da..a413344 100644 --- a/README.org +++ b/README.org @@ -1,6 +1,6 @@ -* which-key +* which-key [[http://melpa.org/#/which-key][http://melpa.org/packages/which-key-badge.svg]] [[http://stable.melpa.org/#/which-key][file:http://stable.melpa.org/packages/which-key-badge.svg]] [[https://travis-ci.org/justbur/emacs-which-key][file:https://travis-ci.org/justbur/emacs-which-key.svg?branch=master]] - + ** Recent Changes *** 2019-07-31: Added =which-key-manual-update= @@ -24,7 +24,7 @@ different face. Screenshots of what the popup will look like are included below. =which-key= started as a rewrite of [[https://github.com/kai2nenobu/guide-key][guide-key-mode]], but the feature sets have diverged to a certain extent. - + ** Table of Contents :TOC_3: - [[#which-key][which-key]] - [[#recent-changes][Recent Changes]] @@ -63,7 +63,7 @@ After setting up [[http://melpa.org][MELPA]] as a repository, use =M-x package-install which-key= or your preferred method. You will need to call =which-key-mode= to enable the minor mode of course. - + *** Manually Add which-key.el to your =load-path= and require. Something like #+BEGIN_SRC emacs-lisp @@ -71,66 +71,66 @@ (require 'which-key) (which-key-mode) #+END_SRC - + ** Initial Setup No further setup is required if you are happy with the default setup. To try other options, there are 3 choices of default configs that are preconfigured (then customize to your liking). The main choice is where you want the which-key buffer to display. Screenshots of the default options are shown in the next sections. - + In each case, we show as many key bindings as we can fit in the buffer within the constraints. The constraints are determined by several factors, including your Emacs settings, the size of the current Emacs frame, and the which-key settings, most of which are described below. - + There are many substitution abilities included, which are quite flexible (ability to use regexp for example). This makes which-key very customizable. - + *** Side Window Bottom Option Popup side window on bottom. This is the current default. To restore this setup use - + #+BEGIN_SRC emacs-lisp (which-key-setup-side-window-bottom) #+END_SRC - + [[./img/which-key-bottom.png]] - + *** Side Window Right Option Popup side window on right. For defaults use - + #+BEGIN_SRC emacs-lisp (which-key-setup-side-window-right) #+END_SRC - + Note the defaults are fairly conservative and will tend to not display on narrower frames. If you get a message saying which-key can't display the keys, try making your frame wider or adjusting the defaults related to the maximum width (see =M-x customize-group which-key=). - + [[./img/which-key-right.png]] - + *** Side Window Right then Bottom This is a combination of the previous two choices. It will try to use the right side, but if there is no room it will switch to using the bottom, which is usually easier to fit keys into. This setting can be helpful if the size of the Emacs frame changes frequently, which might be the case if you are using a dynamic/tiling window manager. - + #+BEGIN_SRC emacs-lisp (which-key-setup-side-window-right-bottom) #+END_SRC - + *** Minibuffer Option Take over the minibuffer. For the recommended configuration use - + #+BEGIN_SRC emacs-lisp (which-key-setup-minibuffer) #+END_SRC - + [[./img/which-key-minibuffer.png]] - + Note the maximum height of the minibuffer is controlled through the built-in variable =max-mini-window-height=. Also, the paging commands do not work reliably with the minibuffer option. Use the side window on the bottom @@ -162,7 +162,7 @@ - =which-key-show-next-page= is the command used for paging. - =which-key-undo= can be used to undo the last keypress when in the middle of a key sequence. - + ** Special Features and Configuration Options There are more options than the ones described here. All of the configurable variables are available through =M-x customize-group which-key=. @@ -181,24 +181,24 @@ #+END_SRC Show keys in a side window. This popup type has further options: #+BEGIN_SRC emacs-lisp - ;; location of which-key window. valid values: top, bottom, left, right, + ;; location of which-key window. valid values: top, bottom, left, right, ;; or a list of any of the two. If it's a list, which-key will always try ;; the first location first. It will go to the second location if there is ;; not enough room to display any keys in the first location (setq which-key-side-window-location 'bottom) - + ;; max width of which-key window, when displayed at left or right. ;; valid values: number of columns (integer), or percentage out of current ;; frame's width (float larger than 0 and smaller than 1) (setq which-key-side-window-max-width 0.33) - + ;; max height of which-key window, when displayed at top or bottom. ;; valid values: number of lines (integer), or percentage out of current ;; frame's height (float larger than 0 and smaller than 1) (setq which-key-side-window-max-height 0.25) #+END_SRC **** frame - + #+BEGIN_SRC emacs-lisp (setq which-key-popup-type 'frame) #+END_SRC @@ -208,11 +208,11 @@ #+BEGIN_SRC emacs-lisp ;; max width of which-key frame: number of columns (an integer) (setq which-key-frame-max-width 60) - + ;; max height of which-key frame: number of lines (an integer) (setq which-key-frame-max-height 20) #+END_SRC - + **** custom Write your own display functions! This requires you to write three functions, =which-key-custom-popup-max-dimensions-function=, @@ -220,8 +220,8 @@ =which-key-custom-hide-popup-function=. Refer to the documentation for those variables for more information, but here is a working example (this is the current implementation of side-window bottom). - - + + #+BEGIN_SRC emacs-lisp (setq which-key-popup-type 'custom) (defun which-key-custom-popup-max-dimensions-function (ignore) @@ -243,14 +243,14 @@ (when (buffer-live-p which-key--buffer) (quit-windows-on which-key--buffer))) #+END_SRC - + *** Custom String Replacement Options #+NAME: #custom-string-replacement-options You can customize the way the keys show in the buffer using three different replacement methods, each of which corresponds replacement alist. The basic idea of behind each alist is that you specify a selection string in the =car= of each cons cell and the replacement string in the =cdr=. - + **** Automatic 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 @@ -272,70 +272,70 @@ **** "Key-Based" replacement Using this method, the description of a key is replaced using a string that you provide. Here's an example - + #+BEGIN_SRC emacs-lisp (which-key-add-key-based-replacements "C-x C-f" "find files") #+END_SRC - + where the first string is the key combination whose description you want to replace, in a form suitable for =kbd=. For that key combination, which-key overwrites the description with the second string, "find files". In the second type of entry you can restrict the replacements to a major-mode. For example, - + #+BEGIN_SRC emacs-lisp (which-key-add-major-mode-key-based-replacements 'org-mode "C-c C-c" "Org C-c C-c" "C-c C-a" "Org Attach") #+END_SRC - + Here the first entry is the major-mode followed by a list of the first type of entries. In case the same key combination is listed under a major-mode and by itself, the major-mode version takes precedence. - + **** Key and Description replacement - + The second and third methods target the text used for the keys and the descriptions directly. The relevant variable is =which-key-replacement-alist=. Here's an example of one of the default key replacements - + #+BEGIN_SRC emacs-lisp (push '(("<\\([[:alnum:]-]+\\)>" . nil) . ("\\1" . nil)) which-key-replacement-alist) #+END_SRC - + Each element of the outer cons cell is a cons cell of the form =(KEY . BINDING)=. The =car= of the outer cons determines how to match key bindings while the =cdr= determines how those matches are replaced. See the docstring of =which-key-replacement-alist= for more information. - + The next example shows how to replace the description. - + #+BEGIN_SRC emacs-lisp (push '((nil . "left") . (nil . "lft")) which-key-replacement-alist) #+END_SRC - + Here is an example of using key replacement to include Unicode characters in the results. Unfortunately, using Unicode characters may upset the alignment of the which-key buffer, because Unicode characters can have different widths even in a monospace font and alignment is based on character width. - + #+BEGIN_SRC emacs-lisp (add-to-list 'which-key-replacement-alist '(("TAB" . nil) . ("↹" . nil)) (add-to-list 'which-key-replacement-alist '(("RET" . nil) . ("⏎" . nil)) (add-to-list 'which-key-replacement-alist '(("DEL" . nil) . ("⇤" . nil)) (add-to-list 'which-key-replacement-alist '(("SPC" . nil) . ("␣" . nil)) #+END_SRC - + The =cdr= may also be a function that receives a =cons= of the form =(KEY . BINDING)= and produces a =cons= of the same form. This allows for interesting ideas like this one suggested by [[https://github.com/pdcawley][@pdcawley]] in [[https://github.com/justbur/emacs-which-key/pull/147][PR #147]]. - + #+BEGIN_SRC emacs-lisp - (push (cons '(nil . "paredit-mode") + (push (cons '(nil . "paredit-mode") (lambda (kb) (cons (car kb) (if paredit-mode @@ -343,19 +343,19 @@ "[ ] paredit-mode")))) which-key-replacement-alist) #+END_SRC - - The box will be checked if =paredit-mode= is currently active. - + + The box will be checked if =paredit-mode= is currently active. + *** Sorting Options By default the output is sorted by the key in a custom order. The default order is to sort lexicographically within each "class" of key, where the classes and their order are - + =Special (SPC, TAB, ...) < Single Character (ASCII) (a, ...) < Modifier (C-, M-, ...) < Other= - + You can control the order by setting this variable. This also shows the other available options. - + #+BEGIN_SRC emacs-lisp ;; default (setq which-key-sort-order 'which-key-key-order) @@ -368,9 +368,9 @@ ;; sort based on the key description ignoring case ;; (setq which-key-sort-order 'which-key-description-order) #+END_SRC - + *** Paging Options - + There are at least several prefixes that have many keys bound to them, like =C-x=. which-key displays as many keys as it can given your settings, but for these prefixes this may not be enough. The paging feature gives you the @@ -378,7 +378,7 @@ allow you to cycle through the pages without changing the key sequence you were in the middle of typing. There are two slightly different ways of doing this. - + **** Method 1 (default): Using C-h (or =help-char=) This is the easiest way, and is turned on by default. Use #+BEGIN_SRC emacs-lisp @@ -392,38 +392,38 @@ get a list of commands that follow =C-x=. This uses which-key instead to show those keys, and unlike the Emacs default saves the incomplete prefix that you just entered so that the next keystroke can complete the command. - + The commands are: - Cycle through the pages forward with =n= (or =C-n=) - Cycle backwards with =p= (or =C-p=) - Undo the last entered key (!) with =u= (or =C-u=) - Call the default command bound to =C-h=, usually =describe-prefix-bindings=, with =h= (or =C-h=) - + This is especially useful for those who like =helm-descbinds= but also want to use =C-h= as their which-key paging key. - + Note =C-h= is by default equivalent to =?= in this context. - + **** Method 2: Bind your own keys - + Essentially, all you need to do for a prefix like =C-x= is the following which will bind =<f5>= to the relevant command. - + #+BEGIN_SRC emacs-lisp (define-key which-key-mode-map (kbd "C-x <f5>") 'which-key-C-h-dispatch) #+END_SRC - - This is completely equivalent to - + + This is completely equivalent to + #+BEGIN_SRC emacs-lisp (setq which-key-paging-prefixes '("C-x")) (setq which-key-paging-key "<f5>") #+END_SRC - + where the latter are provided for convenience if you have a lot of prefixes. - + *** Face Customization Options The faces that which-key uses are | Face | Applied To | Default Definition | @@ -435,32 +435,32 @@ | =which-key-group-description-face= | Command groups (i.e, keymaps) | =:inherit font-lock-keyword-face= | | =which-key-command-description-face= | Commands not in local-map | =:inherit font-lock-function-name-face= | | =which-key-local-map-description-face= | Commands in local-map | =:inherit which-key-command-description-face= | - + The last two deserve some explanation. A command lives in one of many possible keymaps. You can distinguish between local maps, which depend on the buffer you are in, which modes are active, etc., and the global map which applies everywhere. It might be useful for you to distinguish between the two. One way to do this is to remove the default face from =which-key-command-description-face= like this - + #+BEGIN_SRC emacs-lisp (set-face-attribute 'which-key-command-description-face nil :inherit nil) #+END_SRC - + another is to make the local map keys appear in bold - + #+BEGIN_SRC emacs-lisp (set-face-attribute 'which-key-local-map-description-face nil :weight 'bold) #+END_SRC - + You can also use =M-x customize-face= to customize any of the above faces to your liking. - + *** Other Options #+NAME: #other-options The options below are also available through customize. Their defaults are shown. - + #+BEGIN_SRC emacs-lisp ;; Set the time delay (in seconds) for the which-key popup to appear. A value of ;; zero might cause issues so a non-zero value is recommended. @@ -517,7 +517,7 @@ before which-key and through =which-key-show-operator-state-maps= which needs to be enabled explicitly because it is more of a hack. The former allows for the inner and outer text object maps to show, while the latter - shows motions as well. + shows motions as well. *** God-mode Call =(which-key-enable-god-mode-support)= after loading god-mode to enable support for god-mode key sequences. This is new and experimental, so please @@ -528,7 +528,7 @@ several windows. #+CAPTION: which-key in a frame with 3 horizontal splits [[./img/which-key-right-split.png]] - + #+CAPTION: which-key in a frame with 2 vertical splits [[./img/which-key-bottom-split.png]] ** Known Issues