1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-02-28 02:40:46 -08:00

Merge branch 'god-mode'

This commit is contained in:
justbur 2016-04-26 14:27:58 -04:00
commit e095d528f7
2 changed files with 89 additions and 17 deletions

View file

@ -13,7 +13,6 @@ to a certain extent.
** Table of Contents :TOC@4:
- [[#which-key-][which-key ]]
- [[#whats-new][What's New]]
- [[#introduction][Introduction]]
- [[#install][Install]]
- [[#melpa][MELPA]]
@ -39,6 +38,10 @@ to a certain extent.
- [[#method-2-bind-your-own-keys][Method 2: Bind your own keys]]
- [[#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]]
- [[#status][Status]]
@ -52,7 +55,6 @@ 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)
@ -434,6 +436,24 @@ shown.
;; Set to t to show the count of keys shown vs. total keys in the mode line.
(setq which-key-show-remaining-keys nil)
#+END_SRC
** Support for Third-Party Libraries
Some support is provided for third-party libraries which don't use standard
methods of looking up commands. Some of these need to be enabled
explicitly. This code includes some hacks, so please report any problems.
*** Key-chord
Enabled by default.
*** Evil operators
Evil motions and text objects following an operator like =d= are not all
looked up in a standard way. Support is controlled through
=which-key-allow-evil-operators= which should be non-nil if evil is loaded
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.
*** 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
report any issues.
** More Examples
*** Nice Display with Split Frame
Unlike guide-key, which-key looks good even if the frame is split into several

View file

@ -330,21 +330,6 @@ prefixes in `which-key-paging-prefixes'"
"No longer applies. See `which-key-C-h-dispatch'"
"2015-12-2")
(defcustom which-key-allow-evil-operators (boundp 'evil-this-operator)
"Allow popup to show for evil operators. The popup is normally
inhibited in the middle of commands, but setting this to
non-nil will override this behavior for evil operators."
:group 'which-key
:type 'boolean)
(defcustom which-key-show-operator-state-maps nil
"Experimental: Try to show the right keys following an evil
command that reads a motion, such as \"y\", \"d\" and \"c\" from
normal state. This is experimental, because there might be some
valid keys missing and it might be showing some invalid keys."
:group 'which-key
:type 'boolean)
(defcustom which-key-hide-alt-key-translations t
"Hide key translations using Alt key if non nil.
These translations are not relevant most of the times since a lot
@ -505,6 +490,65 @@ sequence. prefix-title is a string. The title is displayed
alongside the actual current key sequence when
`which-key-show-prefix' is set to either top or echo.")
;; Third-party library support
;; Evil
(defcustom which-key-allow-evil-operators (boundp 'evil-this-operator)
"Allow popup to show for evil operators. The popup is normally
inhibited in the middle of commands, but setting this to
non-nil will override this behavior for evil operators."
:group 'which-key
:type 'boolean)
(defcustom which-key-show-operator-state-maps nil
"Experimental: Try to show the right keys following an evil
command that reads a motion, such as \"y\", \"d\" and \"c\" from
normal state. This is experimental, because there might be some
valid keys missing and it might be showing some invalid keys."
:group 'which-key
:type 'boolean)
;; God-mode
(defvar which-key--god-mode-support-enabled nil
"Support god-mode if non-nil. This is experimental,
so you need to explicitly opt-in for now. Please report any
problems at github.")
(defvar which-key--god-mode-key-string nil
"Holds key string to use for god-mode support.")
(defadvice god-mode-lookup-command
(before which-key--god-mode-lookup-command-advice disable)
(setq which-key--god-mode-key-string (ad-get-arg 0)))
(defadvice god-mode-self-insert
(after which-key--god-mode-self-insert-advice disable)
(which-key--hide-popup))
(defun which-key-enable-god-mode-support (&optional disable)
"Enable support for god-mode if non-nil. This is experimental,
so you need to explicitly opt-in for now. Please report any
problems at github. If DISABLE is non-nil disable support."
(interactive "P")
(setq which-key--god-mode-support-enabled (null disable))
(if disable
(progn
(ad-disable-advice
'god-mode-lookup-command
'before 'which-key--god-mode-lookup-command-advice)
(ad-disable-advice
'god-mode-self-insert
'after 'which-key--god-mode-self-insert-advice))
(ad-enable-advice
'god-mode-lookup-command
'before 'which-key--god-mode-lookup-command-advice)
(ad-enable-advice
'god-mode-self-insert
'after 'which-key--god-mode-self-insert-advice))
(ad-activate 'god-mode-lookup-command)
(ad-activate 'god-mode-self-insert))
;;;###autoload
(define-minor-mode which-key-mode
"Toggle which-key-mode."
@ -2058,6 +2102,11 @@ Finally, show the buffer."
(error (progn
(message "which-key error in key-chord handling")
[key-chord])))))
(when (and which-key--god-mode-support-enabled
(bound-and-true-p god-local-mode)
(eq this-command 'god-mode-self-insert))
(setq prefix-keys (when which-key--god-mode-key-string
(kbd which-key--god-mode-key-string))))
(cond ((and (> (length prefix-keys) 0)
(or (keymapp (key-binding prefix-keys))
;; Some keymaps are stored here like iso-transl-ctl-x-8-map
@ -2071,6 +2120,9 @@ Finally, show the buffer."
;; executed
(or (and which-key-allow-evil-operators
(bound-and-true-p evil-this-operator))
(and which-key--god-mode-support-enabled
(bound-and-true-p god-local-mode)
(eq this-command 'god-mode-self-insert))
(null this-command)))
(which-key--create-buffer-and-show prefix-keys)
(when which-key-idle-secondary-delay