Replace guide-key by which-key

This commit is contained in:
syl20bnr 2015-07-24 00:08:43 -04:00
parent f4e5e4cbe6
commit 84640910b3
5 changed files with 101 additions and 118 deletions

View File

@ -1,18 +0,0 @@
#+TITLE: Which-key contribution layer for Spacemacs
* Table of Contents :TOC@4:
- [[#description][Description]]
- [[#install][Install]]
* Description
This layer is a work in progress to test [[https://github.com/justbur/emacs-which-key][which-key]] package in Spacemacs.
=which-key= is aimed to replace =guide-key=, it is developed by [[https://github.com/justbur][justbur]].
* Install
To use this contribution add it to your =~/.spacemacs=
#+BEGIN_SRC emacs-lisp
(setq-default dotspacemacs-configuration-layers '(which-key))
#+END_SRC

View File

@ -1,44 +0,0 @@
(setq which-key-packages '(which-key))
(setq which-key-excluded-packages '(guide-key
guide-key-tip))
(defun which-key/init-which-key ()
(use-package which-key
:init
(progn
(setq which-key-max-description-length 32)
(which-key-mode)
(spacemacs|add-toggle which-key
:status which-key-mode
:on (which-key-mode)
:off (which-key-mode -1)
:documentation
"Display a buffer with available key bindings."
:evil-leader "tK")
(defadvice which-key--update
(around spacemacs/inhibit-which-key-buffer activate)
"Prevent the popup of the which-key buffer in some case."
;; a micro-state is running
;; or
;; bzg-big-fringe-mode is on
(if (or overriding-terminal-local-map
bzg-big-fringe-mode)
(let ((which-key-inhibit t)) ad-do-it)
ad-do-it))
(add-to-list 'which-key-description-replacement-alist '("select-window-\\([0-9]\\)" . "Window \\1"))
(which-key-add-key-based-replacements
"SPC TAB" "last buffer"
"SPC SPC" "ace word"
"SPC !" "shell cmd"
"SPC '" "open shell"
"SPC /" "smart search"
"SPC ?" "show keybindings"
"SPC J" "split sexp"
"SPC l" "ace line"
"SPC u" "universal arg"
"SPC v" "expand region"
"SPC <f1>" "apropos"
"SPC m" "maj mode cmds"
(concat "SPC " dotspacemacs-command-key) "M-x")
(spacemacs|diminish which-key-mode "" " K"))))

View File

@ -115,8 +115,10 @@ initialization."
(setq-default evil-want-C-u-scroll t)
;; Initializing configuration from ~/.spacemacs
(dotspacemacs|call-func dotspacemacs/init "Executing user init...")
;; mandatory dependencies
;; dash is required to prevent a package.el bug with f on 24.3.1
(spacemacs/load-or-install-package 'dash t)
(spacemacs/load-or-install-package 's t)
;; bind-key is required by use-package
(spacemacs/load-or-install-package 'bind-key t)
(spacemacs/load-or-install-package 'use-package t)
@ -124,6 +126,8 @@ initialization."
;; inject use-package hooks for easy customization of
;; stock package configuration
(setq use-package-inject-hooks t)
;; which-key
(spacemacs/load-or-install-package 'which-key t)
;; evil and evil-leader must be installed at the beginning of the
;; boot sequence.
;; Use C-u as scroll-up (must be set before actually loading evil)

View File

@ -913,7 +913,7 @@ can be reached using the =control= key.
| ~SPC t c~ | =none= | | fill-column-indicator mode |
| ~SPC t F~ | =Ⓕ= | F | auto-fill mode |
| ~SPC t g~ | =ⓖ= | g | [[https://github.com/roman/golden-ratio.el][golden-ratio]] mode |
| ~SPC t k~ | =Ⓖ= | G | guide-key mode |
| ~SPC t G~ | =Ⓖ= | G | guide-key mode |
| ~SPC t i~ | =ⓘ= | i | indentation guide |
| ~SPC t C-i~ | =ⓘ= | i | global indentation guide |
| ~SPC t I~ | =Ⓘ= | I | aggressive indent mode |

View File

@ -57,7 +57,7 @@
gh-md
golden-ratio
google-translate
guide-key-tip
;; guide-key-tip
helm
helm-ag
helm-descbinds
@ -100,6 +100,7 @@
vi-tilde-fringe
volatile-highlights
whitespace
which-key
window-numbering
winner
))
@ -1285,63 +1286,63 @@ Example: (evil-map visual \"<\" \"<gv\")"
(setq google-translate-default-source-language "En")
(setq google-translate-default-target-language "Fr"))))
(defun spacemacs/init-guide-key-tip ()
(use-package guide-key-tip
:init
(progn
(defun spacemacs/toggle-guide-key ()
"Toggle golden-ratio mode on and off."
(interactive)
(if (symbol-value guide-key-mode)
(guide-key-mode -1)
(guide-key-mode)))
;; (defun spacemacs/init-guide-key-tip ()
;; (use-package guide-key-tip
;; :init
;; (progn
;; (defun spacemacs/toggle-guide-key ()
;; "Toggle golden-ratio mode on and off."
;; (interactive)
;; (if (symbol-value guide-key-mode)
;; (guide-key-mode -1)
;; (guide-key-mode)))
(defadvice guide-key/popup-guide-buffer-p
(around spacemacs/inhibit-guide-buffer activate)
"Prevent the popup of the guide-key buffer in some case."
;; a micro-state is running
;; or
;; bzg-big-fringe-mode is on
(unless (or overriding-terminal-local-map
bzg-big-fringe-mode)
ad-do-it))
;; (defadvice guide-key/popup-guide-buffer-p
;; (around spacemacs/inhibit-guide-buffer activate)
;; "Prevent the popup of the guide-key buffer in some case."
;; ;; a micro-state is running
;; ;; or
;; ;; bzg-big-fringe-mode is on
;; (unless (or overriding-terminal-local-map
;; bzg-big-fringe-mode)
;; ad-do-it))
(spacemacs|add-toggle guide-key
:status guide-key-mode
:on (guide-key-mode)
:off (guide-key-mode -1)
:documentation
"Display a buffer with available key bindings."
:evil-leader "tG")
;; (spacemacs|add-toggle guide-key
;; :status guide-key-mode
;; :on (guide-key-mode)
;; :off (guide-key-mode -1)
;; :documentation
;; "Display a buffer with available key bindings."
;; :evil-leader "tG")
(setq guide-key/guide-key-sequence `("C-x"
"C-c"
"C-w"
,dotspacemacs-leader-key
,dotspacemacs-emacs-leader-key
,dotspacemacs-major-mode-leader-key
,dotspacemacs-major-mode-emacs-leader-key
;; M-m in terminal
"<ESC>m"
;; C-M-m in terminal
"<ESC><RET>"
"g"
"\["
"\]"
"z"
"C-h")
guide-key/recursive-key-sequence-flag t
guide-key/popup-window-position 'bottom
guide-key/idle-delay dotspacemacs-guide-key-delay
guide-key/text-scale-amount 0
;; use this in your ~/.spacemacs file to enable tool tip in a
;; graphical envrionment
;; guide-key-tip/enabled (if window-system t)
guide-key-tip/enabled nil)
(setq guide-key/highlight-command-regexp
(cons spacemacs/prefix-command-string font-lock-warning-face))
(guide-key-mode 1)
(spacemacs|diminish guide-key-mode "" " G"))))
;; (setq guide-key/guide-key-sequence `("C-x"
;; "C-c"
;; "C-w"
;; ,dotspacemacs-leader-key
;; ,dotspacemacs-emacs-leader-key
;; ,dotspacemacs-major-mode-leader-key
;; ,dotspacemacs-major-mode-emacs-leader-key
;; ;; M-m in terminal
;; "<ESC>m"
;; ;; C-M-m in terminal
;; "<ESC><RET>"
;; "g"
;; "\["
;; "\]"
;; "z"
;; "C-h")
;; guide-key/recursive-key-sequence-flag t
;; guide-key/popup-window-position 'bottom
;; guide-key/idle-delay dotspacemacs-guide-key-delay
;; guide-key/text-scale-amount 0
;; ;; use this in your ~/.spacemacs file to enable tool tip in a
;; ;; graphical envrionment
;; ;; guide-key-tip/enabled (if window-system t)
;; guide-key-tip/enabled nil)
;; (setq guide-key/highlight-command-regexp
;; (cons spacemacs/prefix-command-string font-lock-warning-face))
;; (guide-key-mode 1)
;; (spacemacs|diminish guide-key-mode " Ⓖ" " G"))))
(defun spacemacs/init-helm ()
(use-package helm
@ -3205,6 +3206,46 @@ It is a string holding:
(spacemacs|diminish whitespace-mode "" " w")
(spacemacs|diminish global-whitespace-mode "" " W"))))
(defun spacemacs/init-which-key ()
(use-package which-key
:init
(progn
(setq which-key-max-description-length 32)
(which-key-mode)
(spacemacs|add-toggle which-key
:status which-key-mode
:on (which-key-mode)
:off (which-key-mode -1)
:documentation
"Display a buffer with available key bindings."
:evil-leader "tK")
(defadvice which-key--update
(around spacemacs/inhibit-which-key-buffer activate)
"Prevent the popup of the which-key buffer in some case."
;; a micro-state is running
;; or
;; bzg-big-fringe-mode is on
(if (or overriding-terminal-local-map
bzg-big-fringe-mode)
(let ((which-key-inhibit t)) ad-do-it)
ad-do-it))
(add-to-list 'which-key-description-replacement-alist '("select-window-\\([0-9]\\)" . "Window \\1"))
(which-key-add-key-based-replacements
"SPC TAB" "last buffer"
"SPC SPC" "ace word"
"SPC !" "shell cmd"
"SPC '" "open shell"
"SPC /" "smart search"
"SPC ?" "show keybindings"
"SPC J" "split sexp"
"SPC l" "ace line"
"SPC u" "universal arg"
"SPC v" "expand region"
"SPC <f1>" "apropos"
"SPC m" "maj mode cmds"
(concat "SPC " dotspacemacs-command-key) "M-x")
(spacemacs|diminish which-key-mode "" " K"))))
(defun spacemacs/init-window-numbering ()
(use-package window-numbering
;; not deferred on puprose