[elpa] master a86cf29: Declare any search started with `el-search-this-sexp' single-buffer
branch: master commit a86cf29abfc00cde2537d5495182954d242b4ff7 Author: Michael Heerdegen Commit: Michael Heerdegen Declare any search started with `el-search-this-sexp' single-buffer * el-search/el-search.el (el-search-this-sexp): Do it. --- packages/el-search/el-search.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/el-search/el-search.el b/packages/el-search/el-search.el index 40517cc..348b124 100644 --- a/packages/el-search/el-search.el +++ b/packages/el-search/el-search.el @@ -7,7 +7,7 @@ ;; Created: 29 Jul 2015 ;; Keywords: lisp ;; Compatibility: GNU Emacs 25 -;; Version: 1.4.0.16 +;; Version: 1.4.0.17 ;; Package-Requires: ((emacs "25") (stream "2.2.4")) @@ -2314,7 +2314,8 @@ Use the normal search commands to seize the search." `',sexp (let ((current-buffer (current-buffer))) (lambda () (stream (list current-buffer - 'from-here) + 'from-here + (lambda (search) (setf (alist-get 'is-single-buffer (el-search-object-properties search)) t))) (el-search--next-buffer el-search--current-search) (setf (el-search-head-position (el-search-object-head el-search--current-search)) (copy-marker (point)))
[elpa] master 95d4df5: * el-search/el-search.el: Add two more autoload cookies
branch: master commit 95d4df5afdd161fb5fccbae2363c9254015df17d Author: Michael Heerdegen Commit: Michael Heerdegen * el-search/el-search.el: Add two more autoload cookies (el-search-pattern-backwards, el-search-this-sexp): Add autoload cookie. --- packages/el-search/el-search.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/el-search/el-search.el b/packages/el-search/el-search.el index e4070ab..40517cc 100644 --- a/packages/el-search/el-search.el +++ b/packages/el-search/el-search.el @@ -7,7 +7,7 @@ ;; Created: 29 Jul 2015 ;; Keywords: lisp ;; Compatibility: GNU Emacs 25 -;; Version: 1.4.0.15 +;; Version: 1.4.0.16 ;; Package-Requires: ((emacs "25") (stream "2.2.4")) @@ -2206,6 +2206,7 @@ With prefix arg, restart the current search." (setq el-search--success nil)) (el-search-continue-search)) +;;;###autoload (defun el-search-pattern-backwards (pattern) "Search the current buffer backwards for matches of PATTERN." (declare (interactive-only t)) @@ -2286,6 +2287,7 @@ With prefix arg, restart the current search." (define-obsolete-function-alias 'el-search-previous-match 'el-search-pattern-backwards "since el-search-1.3") +;;;###autoload (defun el-search-this-sexp (sexp) "Prepare to el-search the `sexp-at-point'.
[elpa] master 4b0acdd: New option value ask-multi for `el-search-auto-save-buffers'
branch: master commit 4b0acdd3d97e029ab3ab384a00ec28b5bc2aebf2 Author: Michael Heerdegen Commit: Michael Heerdegen New option value ask-multi for `el-search-auto-save-buffers' This should be a bit more convenient than 'ask in practice. * el-search/el-search.el (el-search-auto-save-buffers): Add new value 'ask-multi. (el-search--search-and-replace-pattern): Do the right thing for the new value. * el-search/NEWS: New file, start filling it. --- packages/el-search/NEWS | 11 +++ packages/el-search/el-search.el | 33 - 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/packages/el-search/NEWS b/packages/el-search/NEWS new file mode 100644 index 000..973abf2 --- /dev/null +++ b/packages/el-search/NEWS @@ -0,0 +1,11 @@ +Some of the user visible news were: + +Version: 1.4.0.15 + + The new option value 'ask-multi for el-search-auto-save-buffers, + which is also the new default, makes el-search only prompt for + whether to save buffers for multi-buffer query-replace sessions. + For single buffer sessions, no prompt, and you can/should save + yourself. I find that behavior slightly more convenient than 'ask + in most cases. + diff --git a/packages/el-search/el-search.el b/packages/el-search/el-search.el index 106e126..e4070ab 100644 --- a/packages/el-search/el-search.el +++ b/packages/el-search/el-search.el @@ -7,7 +7,7 @@ ;; Created: 29 Jul 2015 ;; Keywords: lisp ;; Compatibility: GNU Emacs 25 -;; Version: 1.4.0.14 +;; Version: 1.4.0.15 ;; Package-Requires: ((emacs "25") (stream "2.2.4")) @@ -376,7 +376,11 @@ ;; ;; - There could be something much better than pp to format the ;; replacement, or pp should be improved. - +;; +;; +;; NEWS: +;; +;; Please see the NEWS file in this directory. @@ -448,21 +452,25 @@ tested. " :type '(choice (repeat :tag "Regexps for ignored directories" regexp) (const :tag "No ignored directories" nil))) -(defcustom el-search-auto-save-buffers 'ask +(defcustom el-search-auto-save-buffers 'ask-multi "Whether to automatically save modified buffers. When non-nil, save modified file buffers when query-replace is finished there. If the non-nil value is the symbol ask, ask for confirmation for -each buffer. You can still let all following buffers -automatically be saved or left unsaved from the prompt. +each modified file buffer. You can still let all following +buffers automatically be saved or left unsaved from the prompt. + +ask-multi is like ask, but don't ask and don't save for +single-buffer sessions. Save automatically for any other non-nil value. -The default value is ask." +The default value is ask-multi." :type '(choice (const :tag "Off" nil) (const :tag "On" t) - (const :tag "Ask" ask))) + (const :tag "Ask" ask) + (const :tag "Ask when multibuffer" ask-multi))) (defvar el-search-read-expression-map (let ((map (make-sparse-keymap))) @@ -3147,8 +3155,15 @@ Toggle splicing mode (\\[describe-function] el-search-query-replace for details) (progn (cl-incf nbr-changed-buffers) (when (pcase el-search-auto-save-buffers - ((or 'nil (guard (not buffer-file-name))) nil) - ('ask + ((or 'nil +(guard (not buffer-file-name))) +nil) + ((and 'ask-multi + (guard (alist-get 'is-single-buffer + (el-search-object-properties + el-search--current-search +nil) + ((or 'ask 'ask-multi) (if save-all-answered (cdr save-all-answered) (pcase (car (read-multiple-choice
[elpa] master 7559a79 20/21: Version 3.1.0
branch: master commit 7559a79e95aada65601f7413a1c3f08bfa34557b Author: Justin Burkett Commit: Justin Burkett Version 3.1.0 --- which-key.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/which-key.el b/which-key.el index cb6da90..f973c19 100644 --- a/which-key.el +++ b/which-key.el @@ -5,7 +5,7 @@ ;; Author: Justin Burkett ;; Maintainer: Justin Burkett ;; URL: https://github.com/justbur/emacs-which-key -;; Version: 3.0.2 +;; Version: 3.1.0 ;; Keywords: ;; Package-Requires: ((emacs "24.4"))
[elpa] master cd8d24d 17/21: Define which-key--current-key-list before using it
branch: master commit cd8d24d02479d510e20a2854f23a770fa9c9516f Author: Jonas Bernoulli Commit: Jonas Bernoulli Define which-key--current-key-list before using it Actually move the definition of the caller which-key--pseudo-key instead. --- which-key.el | 18 +- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/which-key.el b/which-key.el index d0d11a6..d28f4a2 100644 --- a/which-key.el +++ b/which-key.el @@ -1334,15 +1334,6 @@ local bindings coming first. Within these categories order using (defsubst which-key--butlast-string (str) (mapconcat #'identity (butlast (split-string str)) " ")) -(defun which-key--pseudo-key (key &optional use-current-prefix) - "Replace the last key in the sequence KEY by a special symbol -in order for which-key to allow looking up a description for the key." - (let* ((seq (listify-key-sequence key)) - (final (intern (format "which-key-%s" (key-description (last seq)) -(if use-current-prefix -(vconcat (which-key--current-key-list) (list final)) - (vconcat (butlast seq) (list final) - (defun which-key--get-replacements (key-binding &optional use-major-mode) (let ((alist (or (and use-major-mode (cdr-safe @@ -1422,6 +1413,15 @@ which are strings. KEY is of the form produced by `key-binding'." map (kbd (which-key--current-key-string (car keydesc (intern (cdr keydesc) +(defun which-key--pseudo-key (key &optional use-current-prefix) + "Replace the last key in the sequence KEY by a special symbol +in order for which-key to allow looking up a description for the key." + (let* ((seq (listify-key-sequence key)) + (final (intern (format "which-key-%s" (key-description (last seq)) +(if use-current-prefix +(vconcat (which-key--current-key-list) (list final)) + (vconcat (butlast seq) (list final) + (defun which-key--maybe-get-prefix-title (keys) "KEYS is a string produced by `key-description'. A title is possibly returned using
[elpa] master f516b84 09/21: Add which-key-enable-extended-define-key customization option
branch: master commit f516b84eab1e307d3ffaa181324dca12c3951936 Author: Justin Burkett Commit: Justin Burkett Add which-key-enable-extended-define-key customization option Adds supporting which-key--process-define-key-args. The docstring for the option is Advise `define-key' to make which-key aware of definitions of the form (define-key KEYMAP KEY '("DESCRIPTION" . DEF)) With the advice, this definition will have the side effect of creating a replacement in `which-key-replacement-alist' that replaces DEF with DESCRIPTION when the key sequence ends in KEY. Using a cons cell like this is a valid definition for `define-key'. All this does is to make which-key aware of it. Since many higher level keybinding functions use `define-key' internally, this will affect most if not all of those as well. This variable must be set before loading which-key. --- which-key.el | 36 1 file changed, 36 insertions(+) diff --git a/which-key.el b/which-key.el index e0c0356..22bed08 100644 --- a/which-key.el +++ b/which-key.el @@ -476,6 +476,24 @@ it." :group 'which-key :type 'boolean) +(defcustom which-key-enable-extended-define-key nil + "Advise `define-key' to make which-key aware of definitions of the form + + \(define-key KEYMAP KEY '(\"DESCRIPTION\" . DEF)) + +With the advice, this definition will have the side effect of +creating a replacement in `which-key-replacement-alist' that +replaces DEF with DESCRIPTION when the key sequence ends in +KEY. Using a cons cell like this is a valid definition for +`define-key'. All this does is to make which-key aware of it. + +Since many higher level keybinding functions use `define-key' +internally, this will affect most if not all of those as well. + +This variable must be set before loading which-key." + :group 'which-key + :type 'boolean) + ;; Hooks (defcustom which-key-init-buffer-hook '() "Hook run when which-key buffer is initialized." @@ -890,6 +908,24 @@ If AT-ROOT is non-nil the binding is also placed at the root of MAP." (which-key-define-key-recursively df key def t))) map)) +(defun which-key--process-define-key-args (keymap key def) + "When DEF takes the form (\"DESCRIPTION\". DEF), add an entry +to `which-key-replacement-alist' so that this binding is replaced +in which-key with DESCRIPTION. This function is meant to be used +as :before advice for `define-key'." + (when (and (consp def) + (stringp (car def)) + (symbolp (cdr def)) + (cdr def)) +(let ((key-desc (regexp-quote (key-description key + (push (cons (cons (format "%s\\'" key-desc) +(format "\\`%s\\'" (symbol-name (cdr def + (cons nil (car def))) +which-key-replacement-alist + +(when which-key-enable-extended-define-key + (advice-add #'define-key :before #'which-key--process-define-key-args)) + ;;; Functions for computing window sizes (defun which-key--text-width-to-total (text-width)
[elpa] master 555c5c1 13/21: Demote errors in which-key--process-define-key-args
branch: master commit 555c5c1da8942b24d457578d0fc23564de07fb17 Author: Justin Burkett Commit: Justin Burkett Demote errors in which-key--process-define-key-args --- which-key.el | 19 ++- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/which-key.el b/which-key.el index 15b599a..fdef15b 100644 --- a/which-key.el +++ b/which-key.el @@ -913,15 +913,16 @@ If AT-ROOT is non-nil the binding is also placed at the root of MAP." to `which-key-replacement-alist' so that this binding is replaced in which-key with DESCRIPTION. This function is meant to be used as :before advice for `define-key'." - (when (and (consp def) - (stringp (car def)) - (symbolp (cdr def))) -(let ((key-desc (regexp-quote (key-description key - (push (cons (cons (format "%s\\'" key-desc) -(when (cdr def) - (format "\\`%s\\'" (symbol-name (cdr def) - (cons nil (car def))) -which-key-replacement-alist + (with-demoted-errors "Which-key extended define-key error: %s" +(when (and (consp def) + (stringp (car def)) + (symbolp (cdr def))) + (let ((key-desc (regexp-quote (key-description key +(push (cons (cons (format "%s\\'" key-desc) + (when (cdr def) +(format "\\`%s\\'" (symbol-name (cdr def) +(cons nil (car def))) + which-key-replacement-alist) (when which-key-enable-extended-define-key (advice-add #'define-key :before #'which-key--process-define-key-args))
[elpa] master 1694c6d 15/21: Improve which-key--process-define-key-args
branch: master commit 1694c6d1790236bce691eacbff00dae5dfa2c24f Author: Justin Burkett Commit: Justin Burkett Improve which-key--process-define-key-args Specify Prefix Command as an explicit match string to cut down on false positives. --- which-key.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/which-key.el b/which-key.el index fdef15b..1523c00 100644 --- a/which-key.el +++ b/which-key.el @@ -919,8 +919,9 @@ as :before advice for `define-key'." (symbolp (cdr def))) (let ((key-desc (regexp-quote (key-description key (push (cons (cons (format "%s\\'" key-desc) - (when (cdr def) -(format "\\`%s\\'" (symbol-name (cdr def) + (format "\\`%s\\'" (if (cdr def) + (symbol-name (cdr def)) + "Prefix Command"))) (cons nil (car def))) which-key-replacement-alist)
[elpa] master 2934852 05/21: Mention which-key-show-major-mode in README
branch: master commit 29348528d28a76857149d03b9554583856286448 Author: Justin Burkett Commit: Justin Burkett Mention which-key-show-major-mode in README --- README.org | 68 +- 1 file changed, 32 insertions(+), 36 deletions(-) diff --git a/README.org b/README.org index ac8b97f..256abb8 100644 --- a/README.org +++ b/README.org @@ -2,14 +2,8 @@ [[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 -*** 2016-12-20: Added =which-key-max-display-columns= -Allows control over the number of columns in the popup. See [[#other-options][Other Options]]. -*** 2016-11-21: Replacement list changes -The alists controlling the replacement of key binding descriptions was -simplified to use one centralized alist, =which-key-replacement-alist=. This -change also allows for some new features compared to the old method. The other -alists are deprecated. See [[#custom-string-replacement-options][Custom String Replacement Options]]. - +*** 2017-11-13: Added =which-key-show-major-mode= +Shows active bindings in current major-mode map. ** Introduction =which-key= is a minor mode for Emacs that displays the key bindings following your currently entered incomplete command (a prefix) in a popup. For example, @@ -21,34 +15,33 @@ 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]] - - [[#2016-12-20-added-which-key-max-display-columns][2016-12-20: Added =which-key-max-display-columns=]] - - [[#2016-11-21-replacement-list-changes][2016-11-21: Replacement list changes]] - - [[#introduction][Introduction]] - - [[#install][Install]] - - [[#melpa][MELPA]] - - [[#manually][Manually]] - - [[#initial-setup][Initial Setup]] - - [[#side-window-bottom-option][Side Window Bottom Option]] - - [[#side-window-right-option][Side Window Right Option]] - - [[#side-window-right-then-bottom][Side Window Right then Bottom]] - - [[#minibuffer-option][Minibuffer Option]] - - [[#additional-commands][Additional Commands]] - - [[#special-features-and-configuration-options][Special Features and Configuration Options]] - - [[#popup-type-options][Popup Type Options]] - - [[#custom-string-replacement-options][Custom String Replacement Options]] - - [[#sorting-options][Sorting Options]] - - [[#paging-options][Paging Options]] - - [[#face-customization-options][Face Customization Options]] - - [[#other-options][Other Options]] - - [[#support-for-third-party-libraries][Support for Third-Party Libraries]] - - [[#key-chord][Key-chord]] - - [[#evil-operators][Evil operators]] - - [[#god-mode][God-mode]] - - [[#more-examples][More Examples]] - - [[#nice-display-with-split-frame][Nice Display with Split Frame]] - - [[#thanks][Thanks]] +- [[#which-key][which-key]] + - [[#recent-changes][Recent Changes]] +- [[#2017-11-13-added-which-key-show-major-mode][2017-11-13: Added =which-key-show-major-mode=]] + - [[#introduction][Introduction]] + - [[#install][Install]] +- [[#melpa][MELPA]] +- [[#manually][Manually]] + - [[#initial-setup][Initial Setup]] +- [[#side-window-bottom-option][Side Window Bottom Option]] +- [[#side-window-right-option][Side Window Right Option]] +- [[#side-window-right-then-bottom][Side Window Right then Bottom]] +- [[#minibuffer-option][Minibuffer Option]] + - [[#additional-commands][Additional Commands]] + - [[#special-features-and-configuration-options][Special Features and Configuration Options]] +- [[#popup-type-options][Popup Type Options]] +- [[#custom-string-replacement-options][Custom String Replacement Options]] +- [[#sorting-options][Sorting Options]] +- [[#paging-options][Paging Options]] +- [[#face-customization-options][Face Customization Options]] +- [[#other-options][Other Options]] + - [[#support-for-third-party-libraries][Support for Third-Party Libraries]] +- [[#key-chord][Key-chord]] +- [[#evil-operators][Evil operators]] +- [[#god-mode][God-mode]] + - [[#more-examples][More Examples]] +- [[#nice-display-with-split-frame][Nice Display with Split Frame]] + - [[#thanks][Thanks]] ** Install *** MELPA @@ -128,6 +121,9 @@ variable =max-mini-window-height=. ** Additional Commands - =which-key-show-top-level= will show most key bindings without a prefix. It is most and not all, because many are probably not interesting to most u
[elpa] master 159f0f9 07/21: Add notes about paging commands not working with minibuffer
branch: master commit 159f0f9b78753574a1892ae3e47c8c1938965ea9 Author: Justin Burkett Commit: Justin Burkett Add notes about paging commands not working with minibuffer --- README.org | 4 +++- which-key.el | 5 - 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.org b/README.org index 9ad7cb1..edde2a4 100644 --- a/README.org +++ b/README.org @@ -118,7 +118,9 @@ [[./img/which-key-minibuffer.png]] Note the maximum height of the minibuffer is controlled through the built-in -variable =max-mini-window-height=. +variable =max-mini-window-height=. Also, the paging commands do not work +reliably with the minibuffer option. Use the side window on the bottom +option if you need paging. ** Additional Commands - =which-key-show-top-level= will show most key bindings without a prefix. It diff --git a/which-key.el b/which-key.el index 348f50d..79f7aff 100644 --- a/which-key.el +++ b/which-key.el @@ -778,7 +778,10 @@ bottom." ;;;###autoload (defun which-key-setup-minibuffer () - "Apply suggested settings for minibuffer." + "Apply suggested settings for minibuffer. +Do not use this setup if you use the paging commands. Instead use +`which-key-setup-side-window-bottom', which is nearly identical +but more functional." (interactive) (which-key--setup-echo-keystrokes) (setq which-key-popup-type 'minibuffer
[elpa] master 56b0fc8 21/21: Merge commit '7559a79e95aada65601f7413a1c3f08bfa34557b'
branch: master commit 56b0fc8b4a5b4f89ea2ab3e6317f035d6f6f40f7 Merge: a86cf29 7559a79 Author: Justin Burkett Commit: Justin Burkett Merge commit '7559a79e95aada65601f7413a1c3f08bfa34557b' --- packages/which-key/.travis.yml | 27 +- packages/which-key/Makefile | 6 +- packages/which-key/README.org | 787 +--- packages/which-key/which-key.el | 184 +++--- 4 files changed, 562 insertions(+), 442 deletions(-) diff --git a/packages/which-key/.travis.yml b/packages/which-key/.travis.yml index b22aa13..918e5f1 100644 --- a/packages/which-key/.travis.yml +++ b/packages/which-key/.travis.yml @@ -1,29 +1,24 @@ -language: generic -sudo: false - -branches: - only: -- master - -before_install: - - curl -fsSkL https://gist.github.com/rejeep/ebcd57c3af83b049833b/raw > x.sh && source ./x.sh - - evm install $EVM_EMACS --use --skip - - cask - +# language: emacs-lisp env: - - EVM_EMACS=emacs-24.3-travis - EVM_EMACS=emacs-24.4-travis - EVM_EMACS=emacs-24.5-travis - EVM_EMACS=emacs-25.1-travis - EVM_EMACS=emacs-25.2-travis + - EVM_EMACS=emacs-25.3-travis - EVM_EMACS=emacs-git-snapshot-travis +before_install: + - git clone https://github.com/rejeep/evm.git $HOME/.evm + - export PATH="$HOME/.evm/bin:$PATH" + - export PATH="$HOME/.cask/bin:$PATH" + - evm config path /tmp + - evm install $EVM_EMACS --use --skip + - curl -fsSkL https://raw.github.com/cask/cask/master/go | python + matrix: fast_finish: true allow_failures: -env: - - EVM_EMACS=emacs-24.3-travis - - EVM_EMACS=emacs-git-snapshot-travis +- env: EVM_EMACS=emacs-git-snapshot-travis script: - emacs --version diff --git a/packages/which-key/Makefile b/packages/which-key/Makefile index facb1f8..a60edf6 100644 --- a/packages/which-key/Makefile +++ b/packages/which-key/Makefile @@ -1,15 +1,15 @@ .PHONY : test -EMACS ?= emacs +emacs ?= emacs CASK ?= cask LOADPATH = -L . ELPA_DIR = \ - .cask/$(shell $(EMACS) -Q --batch --eval '(princ emacs-version)')/elpa + .cask/$(shell $(emacs) -Q --batch --eval '(princ emacs-version)')/elpa test: elpa - $(CASK) exec $(EMACS) -Q -batch $(LOADPATH) \ + $(CASK) exec $(emacs) -Q -batch $(LOADPATH) \ -l which-key-tests.el -f ert-run-tests-batch-and-exit elpa: $(ELPA_DIR) diff --git a/packages/which-key/README.org b/packages/which-key/README.org index ac8b97f..2567e44 100644 --- a/packages/which-key/README.org +++ b/packages/which-key/README.org @@ -1,453 +1,486 @@ -* 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]] +* 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 -*** 2016-12-20: Added =which-key-max-display-columns= -Allows control over the number of columns in the popup. See [[#other-options][Other Options]]. -*** 2016-11-21: Replacement list changes -The alists controlling the replacement of key binding descriptions was -simplified to use one centralized alist, =which-key-replacement-alist=. This -change also allows for some new features compared to the old method. The other -alists are deprecated. See [[#custom-string-replacement-options][Custom String Replacement Options]]. +*** 2017-12-13: Added =which-key-enable-extended-define-key= +Allows for a concise syntax to specify replacement text using =define-key= +or alternatives that use =define-key= internally. See the docstring and +[[#custom-string-replacement-options][Custom String Replacement]]. + +*** 2017-11-13: Added =which-key-show-major-mode= +Shows active bindings in current major-mode map. ** Introduction -=which-key= is a minor mode for Emacs that displays the key bindings following -your currently entered incomplete command (a prefix) in a popup. For example, -after enabling the minor mode if you enter =C-x= and wait for the default of 1 -second the minibuffer will expand with all of the available key bindings that -follow =C-x= (or as many as space allows given your settings). This includes -prefixes like =C-x 8= which are shown in a 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. + =which-key= is a minor mode for Emacs that displays the key bindings + following your currently entered incomplete command (a prefix) in a + popup. For example, af
[elpa] master updated (a86cf29 -> 56b0fc8)
justbur pushed a change to branch master. from a86cf29 Declare any search started with `el-search-this-sexp' single-buffer new 6d2e17c Update which-key version for GNU ELPA new 70d63a8 Add which-key-show-major-mode new 917d2ba Improve echo area note for which-key-show-major-mode new 6e8df96 Consolidate use of binding filters new 2934852 Mention which-key-show-major-mode in README new 1234342 Re-indent README new 159f0f9 Add notes about paging commands not working with minibuffer new 78a2943 Fix ordering of default replacement-alist new f516b84 Add which-key-enable-extended-define-key customization option new 3ff8f48 Allow null DEF in which-key--process-define-key-args new 0a212c7 Fix travis build new b6d04b3 Fix .travis.yml new 555c5c1 Demote errors in which-key--process-define-key-args new 7150aa9 Announce which-key-enable-extended-define-key in README new 1694c6d Improve which-key--process-define-key-args new 6247cb5 Simplify implementation of define-key based replacements new cd8d24d Define which-key--current-key-list before using it new c7e5f76 Merge pull request #183 from tarsiiformes/silencio new ef384e7 Fix and improve define-key based replacements new 7559a79 Version 3.1.0 new 56b0fc8 Merge commit '7559a79e95aada65601f7413a1c3f08bfa34557b' Summary of changes: packages/which-key/.travis.yml | 27 +- packages/which-key/Makefile | 6 +- packages/which-key/README.org | 787 +--- packages/which-key/which-key.el | 184 +++--- 4 files changed, 562 insertions(+), 442 deletions(-)
[elpa] master b6d04b3 12/21: Fix .travis.yml
branch: master commit b6d04b3e9c281acf4093cf871b1639c730ad9618 Author: Justin Burkett Commit: Justin Burkett Fix .travis.yml Didn't install cask --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 9da955d..918e5f1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,9 +9,11 @@ env: before_install: - git clone https://github.com/rejeep/evm.git $HOME/.evm - - export PATH=$HOME/.evm/bin:$PATH + - export PATH="$HOME/.evm/bin:$PATH" + - export PATH="$HOME/.cask/bin:$PATH" - evm config path /tmp - evm install $EVM_EMACS --use --skip + - curl -fsSkL https://raw.github.com/cask/cask/master/go | python matrix: fast_finish: true
[elpa] master 7150aa9 14/21: Announce which-key-enable-extended-define-key in README
branch: master commit 7150aa97954483517aa8395e94c39af9b49516fc Author: Justin Burkett Commit: Justin Burkett Announce which-key-enable-extended-define-key in README --- README.org | 25 + 1 file changed, 25 insertions(+) diff --git a/README.org b/README.org index edde2a4..4b4f96b 100644 --- a/README.org +++ b/README.org @@ -2,6 +2,12 @@ [[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 + +*** 2017-12-13: Added =which-key-enable-extended-define-key= +Allows for a concise syntax to specify replacement text using =define-key= +or alternatives that use =define-key= internally. See the docstring and +[[#custom-string-replacement-options][Custom String Replacement]]. + *** 2017-11-13: Added =which-key-show-major-mode= Shows active bindings in current major-mode map. ** Introduction @@ -18,6 +24,7 @@ ** Table of Contents :TOC_3: - [[#which-key][which-key]] - [[#recent-changes][Recent Changes]] +- [[#2017-12-13-added-which-key-enable-extended-define-key][2017-12-13: Added =which-key-enable-extended-define-key=]] - [[#2017-11-13-added-which-key-show-major-mode][2017-11-13: Added =which-key-show-major-mode=]] - [[#introduction][Introduction]] - [[#install][Install]] @@ -221,6 +228,24 @@ 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 + statement + + #+BEGIN_SRC emacs-lisp + (define-key some-map "f" '("foo" . long-name-for-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. + + #+BEGIN_SRC emacs-lisp + (define-key some-map "b" '("bar-prefix")) + #+END_SRC + "Key-Based" replacement Using this method, the description of a key is replaced using a string that you provide. Here's an example
[elpa] master 6e8df96 04/21: Consolidate use of binding filters
branch: master commit 6e8df961f4aecbbb59655ea804c62f09eb13b271 Author: Justin Burkett Commit: Justin Burkett Consolidate use of binding filters --- which-key.el | 28 ++-- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/which-key.el b/which-key.el index 85714c8..348f50d 100644 --- a/which-key.el +++ b/which-key.el @@ -1525,19 +1525,18 @@ alists. Returns a list (key separator description)." new-list (nreverse new-list))) -(defun which-key--get-keymap-bindings (keymap &optional filter) +(defun which-key--get-keymap-bindings (keymap) "Retrieve top-level bindings from KEYMAP." (let (bindings) (map-keymap (lambda (ev def) - (unless (and (functionp filter) (funcall filter ev def)) - (cl-pushnew - (cons (key-description (list ev)) -(cond ((keymapp def) "Prefix Command") - ((symbolp def) (copy-sequence (symbol-name def))) - ((eq 'lambda (car-safe def)) "lambda") - (t (format "%s" def - bindings :test (lambda (a b) (string= (car a) (car b)) + (cl-pushnew +(cons (key-description (list ev)) + (cond ((keymapp def) "Prefix Command") +((symbolp def) (copy-sequence (symbol-name def))) +((eq 'lambda (car-safe def)) "lambda") +(t (format "%s" def +bindings :test (lambda (a b) (string= (car a) (car b) keymap) bindings)) @@ -2204,9 +2203,10 @@ is selected interactively by mode in `minor-mode-map-alist'." (cons keymap-name keymap))) (t (which-key--hide-popup) -(defun which-key--evil-operator-filter (_ev def) - (and (functionp def) - (evil-get-command-property def :suppress-operator))) +(defun which-key--evil-operator-filter (binding) + (let ((def (intern (cdr binding +(and (functionp def) + (not (evil-get-command-property def :suppress-operator) (defun which-key--show-evil-operator-keymap () (if which-key--inhibit-next-operator-popup @@ -2220,8 +2220,8 @@ is selected interactively by mode in `minor-mode-map-alist'." which-key--using-show-operator-keymap t) (when (keymapp keymap) (let ((formatted-keys (which-key--get-formatted-key-bindings - (which-key--get-keymap-bindings -keymap 'which-key--evil-operator-filter + (which-key--get-keymap-bindings keymap) + #'which-key--evil-operator-filter))) (cond ((= (length formatted-keys) 0) (message "which-key: Keymap empty")) ((listp which-key-side-window-location)
[elpa] master 6247cb5 16/21: Simplify implementation of define-key based replacements
branch: master commit 6247cb5e28c001ffa8e09a92f654990b324db424 Author: Justin Burkett Commit: Justin Burkett Simplify implementation of define-key based replacements When a description is provided through define-key using a definition like ("description" . def) place a additional binding in the map to a "pseudo key" making it easy for which-key to find these descriptions on the fly and at the right time (i.e., when the binding is active). which-key-enable-extended-define-key must be enabled for this to have an effect. --- which-key.el | 73 +--- 1 file changed, 40 insertions(+), 33 deletions(-) diff --git a/which-key.el b/which-key.el index 1523c00..d0d11a6 100644 --- a/which-key.el +++ b/which-key.el @@ -909,21 +909,14 @@ If AT-ROOT is non-nil the binding is also placed at the root of MAP." map)) (defun which-key--process-define-key-args (keymap key def) - "When DEF takes the form (\"DESCRIPTION\". DEF), add an entry -to `which-key-replacement-alist' so that this binding is replaced -in which-key with DESCRIPTION. This function is meant to be used -as :before advice for `define-key'." + "When DEF takes the form (\"DESCRIPTION\". DEF), make sure +which-key uses \"DESCRIPTION\" for this binding. This function is +meant to be used as :before advice for `define-key'." (with-demoted-errors "Which-key extended define-key error: %s" (when (and (consp def) (stringp (car def)) (symbolp (cdr def))) - (let ((key-desc (regexp-quote (key-description key -(push (cons (cons (format "%s\\'" key-desc) - (format "\\`%s\\'" (if (cdr def) - (symbol-name (cdr def)) - "Prefix Command"))) -(cons nil (car def))) - which-key-replacement-alist) + (define-key keymap (which-key--pseudo-key key) (car def) (when which-key-enable-extended-define-key (advice-add #'define-key :before #'which-key--process-define-key-args)) @@ -1341,6 +1334,15 @@ local bindings coming first. Within these categories order using (defsubst which-key--butlast-string (str) (mapconcat #'identity (butlast (split-string str)) " ")) +(defun which-key--pseudo-key (key &optional use-current-prefix) + "Replace the last key in the sequence KEY by a special symbol +in order for which-key to allow looking up a description for the key." + (let* ((seq (listify-key-sequence key)) + (final (intern (format "which-key-%s" (key-description (last seq)) +(if use-current-prefix +(vconcat (which-key--current-key-list) (list final)) + (vconcat (butlast seq) (list final) + (defun which-key--get-replacements (key-binding &optional use-major-mode) (let ((alist (or (and use-major-mode (cdr-safe @@ -1369,27 +1371,31 @@ local bindings coming first. Within these categories order using "Use `which-key--replacement-alist' to maybe replace KEY-BINDING. KEY-BINDING is a cons cell of the form \(KEY . BINDING\) each of which are strings. KEY is of the form produced by `key-binding'." - (let* ((mode-res (which-key--get-replacements key-binding t)) - (all-repls (or mode-res - (which-key--get-replacements key-binding -(dolist (repl all-repls key-binding) - (setq key-binding -(cond ((or (not (consp repl)) (null (cdr repl))) - key-binding) - ((functionp (cdr repl)) - (funcall (cdr repl) key-binding)) - ((consp (cdr repl)) - (cons -(cond ((and (caar repl) (cadr repl)) - (replace-regexp-in-string -(caar repl) (cadr repl) (car key-binding) t)) - ((cadr repl) (cadr repl)) - (t (car key-binding))) -(cond ((and (cdar repl) (cddr repl)) - (replace-regexp-in-string -(cdar repl) (cddr repl) (cdr key-binding) t)) - ((cddr repl) (cddr repl)) - (t (cdr key-binding)) + (let ((menu-item-repl + (key-binding (which-key--pseudo-key (car key-binding) t +(if menu-item-repl +(cons (car key-binding) menu-item-repl) + (let* ((mode-res (which-key--get-replacements key-binding t)) + (all-repls (or mode-res +(which-key--get-replacements key-binding +(dolist (repl all-repls key-binding) + (setq key-binding +(cond ((or (not (consp repl)) (null (cdr repl))) + key-binding) + ((functionp (cdr repl)) + (funcall (cdr repl) key-binding)) + ((co
[elpa] master c7e5f76 18/21: Merge pull request #183 from tarsiiformes/silencio
branch: master commit c7e5f766d131cf760f181bdda780bcd63cf765cc Merge: 6247cb5 cd8d24d Author: Justin Burkett Commit: GitHub Merge pull request #183 from tarsiiformes/silencio Define which-key--current-key-list before using it --- which-key.el | 18 +- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/which-key.el b/which-key.el index d0d11a6..d28f4a2 100644 --- a/which-key.el +++ b/which-key.el @@ -1334,15 +1334,6 @@ local bindings coming first. Within these categories order using (defsubst which-key--butlast-string (str) (mapconcat #'identity (butlast (split-string str)) " ")) -(defun which-key--pseudo-key (key &optional use-current-prefix) - "Replace the last key in the sequence KEY by a special symbol -in order for which-key to allow looking up a description for the key." - (let* ((seq (listify-key-sequence key)) - (final (intern (format "which-key-%s" (key-description (last seq)) -(if use-current-prefix -(vconcat (which-key--current-key-list) (list final)) - (vconcat (butlast seq) (list final) - (defun which-key--get-replacements (key-binding &optional use-major-mode) (let ((alist (or (and use-major-mode (cdr-safe @@ -1422,6 +1413,15 @@ which are strings. KEY is of the form produced by `key-binding'." map (kbd (which-key--current-key-string (car keydesc (intern (cdr keydesc) +(defun which-key--pseudo-key (key &optional use-current-prefix) + "Replace the last key in the sequence KEY by a special symbol +in order for which-key to allow looking up a description for the key." + (let* ((seq (listify-key-sequence key)) + (final (intern (format "which-key-%s" (key-description (last seq)) +(if use-current-prefix +(vconcat (which-key--current-key-list) (list final)) + (vconcat (butlast seq) (list final) + (defun which-key--maybe-get-prefix-title (keys) "KEYS is a string produced by `key-description'. A title is possibly returned using
[elpa] master 6d2e17c 01/21: Update which-key version for GNU ELPA
branch: master commit 6d2e17c949ff7bfebfe0b0878a93d94b31585031 Author: Justin Burkett Commit: Justin Burkett Update which-key version for GNU ELPA --- which-key.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/which-key.el b/which-key.el index 78b1665..0e2c6da 100644 --- a/which-key.el +++ b/which-key.el @@ -5,7 +5,7 @@ ;; Author: Justin Burkett ;; Maintainer: Justin Burkett ;; URL: https://github.com/justbur/emacs-which-key -;; Version: 3.0.1 +;; Version: 3.0.2 ;; Keywords: ;; Package-Requires: ((emacs "24.4"))
[elpa] master 3ff8f48 10/21: Allow null DEF in which-key--process-define-key-args
branch: master commit 3ff8f48193dce6670ac57f8e67469435bc0a71ba Author: Justin Burkett Commit: Justin Burkett Allow null DEF in which-key--process-define-key-args This is useful for naming prefixes --- which-key.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/which-key.el b/which-key.el index 22bed08..15b599a 100644 --- a/which-key.el +++ b/which-key.el @@ -915,11 +915,11 @@ in which-key with DESCRIPTION. This function is meant to be used as :before advice for `define-key'." (when (and (consp def) (stringp (car def)) - (symbolp (cdr def)) - (cdr def)) + (symbolp (cdr def))) (let ((key-desc (regexp-quote (key-description key (push (cons (cons (format "%s\\'" key-desc) -(format "\\`%s\\'" (symbol-name (cdr def +(when (cdr def) + (format "\\`%s\\'" (symbol-name (cdr def) (cons nil (car def))) which-key-replacement-alist
[elpa] master 70d63a8 02/21: Add which-key-show-major-mode
branch: master commit 70d63a8babcc783cf0083b0094405d45303ec401 Author: Justin Burkett Commit: Justin Burkett Add which-key-show-major-mode This is a new function to discover bindings, including evil ones, in the keymap of the current major mode. It should be considered experimental at the moment. --- which-key.el | 36 +--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/which-key.el b/which-key.el index 0e2c6da..0f5b7d4 100644 --- a/which-key.el +++ b/which-key.el @@ -1363,6 +1363,18 @@ which are strings. KEY is of the form produced by `key-binding'." (current-local-map) (kbd (which-key--current-key-string (car keydesc (intern (cdr keydesc +(defun which-key--map-binding-p (map keydesc) + (or + (when (bound-and-true-p evil-state) + (eq (which-key--safe-lookup-key + map + (kbd (which-key--current-key-string +(format "<%s-state> %s" evil-state (car keydesc) + (intern (cdr keydesc + (eq (which-key--safe-lookup-key +map (kbd (which-key--current-key-string (car keydesc + (intern (cdr keydesc) + (defun which-key--maybe-get-prefix-title (keys) "KEYS is a string produced by `key-description'. A title is possibly returned using @@ -1615,10 +1627,12 @@ Requires `which-key-compute-remaps' to be non-nil" (forward-line)) (nreverse bindings) -(defun which-key--get-formatted-key-bindings (&optional bindings) +(defun which-key--get-formatted-key-bindings (&optional bindings filter) "Uses `describe-buffer-bindings' to collect the key bindings in BUFFER that follow the key sequence KEY-SEQ." (let* ((unformatted (if bindings bindings (which-key--get-current-bindings +(when filter + (setq unformatted (cl-remove-if-not filter unformatted))) (when which-key-sort-order (setq unformatted (sort unformatted which-key-sort-order))) @@ -2023,6 +2037,21 @@ after first page." (which-key--create-buffer-and-show nil)) ;;;###autoload +(defun which-key-show-major-mode () + "Show top-level bindings in the map of the current major mode. + +This function will also detect evil bindings made using +`evil-define-key' in this map. These bindings will depend on the +current evil state. " + (interactive) + (setq which-key--using-top-level t) + (let ((map-sym (intern (format "%s-map" major-mode +(if (and (boundp map-sym) (keymapp (symbol-value map-sym))) +(which-key--create-buffer-and-show + nil nil (apply-partially #'which-key--map-binding-p (symbol-value map-sym))) + (message "which-key: No map named %s" map-sym + +;;;###autoload (defun which-key-undo-key () "Undo last keypress and force which-key update." (interactive) @@ -2215,7 +2244,7 @@ is selected interactively by mode in `minor-mode-map-alist'." (which-key--hide-popup) (setq unread-command-events (listify-key-sequence key -(defun which-key--create-buffer-and-show (&optional prefix-keys from-keymap) +(defun which-key--create-buffer-and-show (&optional prefix-keys from-keymap filter) "Fill `which-key--buffer' with key descriptions and reformat. Finally, show the buffer." (setq which-key--current-prefix prefix-keys @@ -2223,7 +2252,8 @@ Finally, show the buffer." (let ((start-time (when which-key--debug (current-time))) (formatted-keys (which-key--get-formatted-key-bindings (when from-keymap - (which-key--get-keymap-bindings from-keymap + (which-key--get-keymap-bindings from-keymap)) + filter)) (prefix-keys (key-description which-key--current-prefix))) (cond ((= (length formatted-keys) 0) (message "%s- which-key: There are no keys to show" prefix-keys))
[elpa] master 78a2943 08/21: Fix ordering of default replacement-alist
branch: master commit 78a29434789c7e7af7b3cf10a548d6247a69d3a9 Author: Justin Burkett Commit: Justin Burkett Fix ordering of default replacement-alist When which-key-allow-multiple-replacements is nil, this order is required to get the intended behavior with left and right. Ref #181 --- which-key.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/which-key.el b/which-key.el index 79f7aff..e0c0356 100644 --- a/which-key.el +++ b/which-key.el @@ -152,10 +152,10 @@ remapped given the currently active keymaps." `(((nil . "Prefix Command") . (nil . "prefix")) ((nil . "\\`\\?\\?\\'") . (nil . "lambda")) ((nil . "which-key-show-next-page-no-cycle") . (nil . "wk next pg")) - (("<\\([[:alnum:]-]+\\)>") . ("\\1")) ,@(unless which-key-dont-use-unicode - '((("left") . ("←")) -(("right") . ("→")) + '((("") . ("←")) +(("") . ("→" + (("<\\([[:alnum:]-]+\\)>") . ("\\1" "Association list to determine how to manipulate descriptions of key bindings in the which-key popup. Each element of the list is a nested cons cell with the format
[elpa] master 0a212c7 11/21: Fix travis build
branch: master commit 0a212c71fe4ed8bf3006f5936df7ba7c673cdcd9 Author: Justin Burkett Commit: Justin Burkett Fix travis build Add support for 25.3. Remove for 24.3 --- .travis.yml | 25 + Makefile| 6 +++--- 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/.travis.yml b/.travis.yml index b22aa13..9da955d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,29 +1,22 @@ -language: generic -sudo: false - -branches: - only: -- master - -before_install: - - curl -fsSkL https://gist.github.com/rejeep/ebcd57c3af83b049833b/raw > x.sh && source ./x.sh - - evm install $EVM_EMACS --use --skip - - cask - +# language: emacs-lisp env: - - EVM_EMACS=emacs-24.3-travis - EVM_EMACS=emacs-24.4-travis - EVM_EMACS=emacs-24.5-travis - EVM_EMACS=emacs-25.1-travis - EVM_EMACS=emacs-25.2-travis + - EVM_EMACS=emacs-25.3-travis - EVM_EMACS=emacs-git-snapshot-travis +before_install: + - git clone https://github.com/rejeep/evm.git $HOME/.evm + - export PATH=$HOME/.evm/bin:$PATH + - evm config path /tmp + - evm install $EVM_EMACS --use --skip + matrix: fast_finish: true allow_failures: -env: - - EVM_EMACS=emacs-24.3-travis - - EVM_EMACS=emacs-git-snapshot-travis +- env: EVM_EMACS=emacs-git-snapshot-travis script: - emacs --version diff --git a/Makefile b/Makefile index facb1f8..a60edf6 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,15 @@ .PHONY : test -EMACS ?= emacs +emacs ?= emacs CASK ?= cask LOADPATH = -L . ELPA_DIR = \ - .cask/$(shell $(EMACS) -Q --batch --eval '(princ emacs-version)')/elpa + .cask/$(shell $(emacs) -Q --batch --eval '(princ emacs-version)')/elpa test: elpa - $(CASK) exec $(EMACS) -Q -batch $(LOADPATH) \ + $(CASK) exec $(emacs) -Q -batch $(LOADPATH) \ -l which-key-tests.el -f ert-run-tests-batch-and-exit elpa: $(ELPA_DIR)
[elpa] master 1234342 06/21: Re-indent README
branch: master commit 1234342878f9c9c9bc23ebe754e85d7fa155a51f Author: Justin Burkett Commit: Justin Burkett Re-indent README --- README.org | 792 +++-- 1 file changed, 401 insertions(+), 391 deletions(-) diff --git a/README.org b/README.org index 256abb8..9ad7cb1 100644 --- a/README.org +++ b/README.org @@ -1,19 +1,20 @@ * 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]] - + [[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 *** 2017-11-13: Added =which-key-show-major-mode= Shows active bindings in current major-mode map. ** Introduction -=which-key= is a minor mode for Emacs that displays the key bindings following -your currently entered incomplete command (a prefix) in a popup. For example, -after enabling the minor mode if you enter =C-x= and wait for the default of 1 -second the minibuffer will expand with all of the available key bindings that -follow =C-x= (or as many as space allows given your settings). This includes -prefixes like =C-x 8= which are shown in a 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. - + =which-key= is a minor mode for Emacs that displays the key bindings + following your currently entered incomplete command (a prefix) in a + popup. For example, after enabling the minor mode if you enter =C-x= and wait + for the default of 1 second the minibuffer will expand with all of the + available key bindings that follow =C-x= (or as many as space allows given + your settings). This includes prefixes like =C-x 8= which are shown in a + 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]] @@ -45,405 +46,414 @@ the popup will look like are included below. =which-key= started as a rewrite of ** Install *** MELPA -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. - +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 -(add-to-list 'load-path "path/to/which-key.el") -(require 'which-key) -(which-key-mode) -#+END_SRC - +Add which-key.el to your =load-path= and require. Something like +#+BEGIN_SRC emacs-lisp +(add-to-list 'load-path "path/to/which-key.el") +(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. - + 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 se
[elpa] master ef384e7 19/21: Fix and improve define-key based replacements
branch: master commit ef384e781e6107850c7fadc78cb0675d7fe72e69 Author: Justin Burkett Commit: Justin Burkett Fix and improve define-key based replacements Check for equality of definition as well as the key sequence. Unless it's a prefix binding, in which case only check the key sequence. Make sure we apply kbd when looking up pseudo bindings. Move the logic into which-key--get-pseudo-binding. --- which-key.el | 24 +++- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/which-key.el b/which-key.el index d28f4a2..cb6da90 100644 --- a/which-key.el +++ b/which-key.el @@ -916,7 +916,7 @@ meant to be used as :before advice for `define-key'." (when (and (consp def) (stringp (car def)) (symbolp (cdr def))) - (define-key keymap (which-key--pseudo-key key) (car def) + (define-key keymap (which-key--pseudo-key key) `(which-key ,def) (when which-key-enable-extended-define-key (advice-add #'define-key :before #'which-key--process-define-key-args)) @@ -1358,14 +1358,28 @@ local bindings coming first. Within these categories order using (throw 'res res))) (nreverse res))) +(defun which-key--get-pseudo-binding (key-binding) + (let* ((pseudo-binding + (key-binding (which-key--pseudo-key (kbd (car key-binding)) t))) + (pseudo-binding (when pseudo-binding (cadr pseudo-binding))) + (pseudo-desc (when pseudo-binding (car pseudo-binding))) + (pseudo-def (when pseudo-binding (cdr pseudo-binding))) + (real-def (key-binding (kbd (car key-binding + ;; treat keymaps as if they're nil bindings. This creates the + ;; possibility that we rename the wrong binding but this seems + ;; unlikely. + (real-def (unless (keymapp real-def) real-def))) +(when (and pseudo-binding + (eq pseudo-def real-def)) + (cons (car key-binding) pseudo-desc + (defun which-key--maybe-replace (key-binding) "Use `which-key--replacement-alist' to maybe replace KEY-BINDING. KEY-BINDING is a cons cell of the form \(KEY . BINDING\) each of which are strings. KEY is of the form produced by `key-binding'." - (let ((menu-item-repl - (key-binding (which-key--pseudo-key (car key-binding) t -(if menu-item-repl -(cons (car key-binding) menu-item-repl) + (let* ((pseudo-binding (which-key--get-pseudo-binding key-binding))) +(if pseudo-binding +pseudo-binding (let* ((mode-res (which-key--get-replacements key-binding t)) (all-repls (or mode-res (which-key--get-replacements key-binding
[elpa] master 917d2ba 03/21: Improve echo area note for which-key-show-major-mode
branch: master commit 917d2ba291eb7fea7b5c1c9097be23ea356b2477 Author: Justin Burkett Commit: Justin Burkett Improve echo area note for which-key-show-major-mode --- which-key.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/which-key.el b/which-key.el index 0f5b7d4..85714c8 100644 --- a/which-key.el +++ b/which-key.el @@ -1399,7 +1399,7 @@ no title exists." (if alternate alternate (concat "Following " keys))) (t "" -(which-key--using-top-level "Top-level bindings") +(which-key--using-top-level which-key--using-top-level) (which-key--current-show-keymap-name which-key--current-show-keymap-name) (t ""))) @@ -2033,7 +2033,7 @@ after first page." (defun which-key-show-top-level () "Show top-level bindings." (interactive) - (setq which-key--using-top-level t) + (setq which-key--using-top-level "Top-level bindings") (which-key--create-buffer-and-show nil)) ;;;###autoload @@ -2044,7 +2044,7 @@ This function will also detect evil bindings made using `evil-define-key' in this map. These bindings will depend on the current evil state. " (interactive) - (setq which-key--using-top-level t) + (setq which-key--using-top-level "Major-mode bindings") (let ((map-sym (intern (format "%s-map" major-mode (if (and (boundp map-sym) (keymapp (symbol-value map-sym))) (which-key--create-buffer-and-show