which-key: Add support for prefix-titles
This commit is contained in:
parent
beaa36095b
commit
eeb33e4711
3 changed files with 70 additions and 53 deletions
|
@ -14,54 +14,54 @@
|
||||||
;; Prefixes
|
;; Prefixes
|
||||||
;; ---------------------------------------------------------------------------
|
;; ---------------------------------------------------------------------------
|
||||||
|
|
||||||
;; We define prefix commands only for the sake of guide-key
|
;; We define prefix commands only for the sake of which-key
|
||||||
(setq spacemacs/key-binding-prefixes '(("a" . "applications")
|
(setq spacemacs/key-binding-prefixes '(("a" "applications")
|
||||||
("ai" . "applications-irc")
|
("ai" "applications-irc")
|
||||||
("as" . "applications-shells")
|
("as" "applications-shells")
|
||||||
("b" . "buffers")
|
("b" "buffers")
|
||||||
("bm" . "buffers-move")
|
("bm" "buffers-move")
|
||||||
("c" . "compile/comments")
|
("c" "compile/comments")
|
||||||
("C" . "capture/colors")
|
("C" "capture/colors")
|
||||||
("e" . "errors")
|
("e" "errors")
|
||||||
("E" . "editing-modes")
|
("E" "editing-modes")
|
||||||
("f" . "files")
|
("f" "files")
|
||||||
("fe" . "files-emacs/spacemacs")
|
("fe" "files-emacs/spacemacs")
|
||||||
("g" . "git/versions-control")
|
("g" "git/versions-control")
|
||||||
("h" . "helm/help/highlight")
|
("h" "helm/help/highlight")
|
||||||
("hd" . "help-describe")
|
("hd" "help-describe")
|
||||||
("i" . "insertion")
|
("i" "insertion")
|
||||||
("j" . "join/split")
|
("j" "join/split")
|
||||||
("k" . "lisp")
|
("k" "lisp")
|
||||||
("kd" . "lisp-delete")
|
("kd" "lisp-delete")
|
||||||
("kD" . "lisp-delete-backward")
|
("kD" "lisp-delete-backward")
|
||||||
("k`" . "lisp-hybrid")
|
("k`" "lisp-hybrid")
|
||||||
("n" . "narrow/numbers")
|
("n" "narrow/numbers")
|
||||||
("p" . "projects")
|
("p" "projects")
|
||||||
("p$" . "projects/shell")
|
("p$" "projects/shell")
|
||||||
("q" . "quit")
|
("q" "quit")
|
||||||
("r" . "registers/rings")
|
("r" "registers/rings")
|
||||||
("s" . "search/symbol")
|
("s" "search/symbol")
|
||||||
("sa" . "search-ag")
|
("sa" "search-ag")
|
||||||
("sg" . "search-grep")
|
("sg" "search-grep")
|
||||||
("sk" . "search-ack")
|
("sk" "search-ack")
|
||||||
("st" . "search-pt")
|
("st" "search-pt")
|
||||||
("sw" . "search-web")
|
("sw" "search-web")
|
||||||
("t" . "toggles")
|
("t" "toggles")
|
||||||
("tC" . "toggles-colors")
|
("tC" "toggles-colors")
|
||||||
("th" . "toggles-highlight")
|
("th" "toggles-highlight")
|
||||||
("tm" . "toggles-modeline")
|
("tm" "toggles-modeline")
|
||||||
("T" . "toggles/themes")
|
("T" "toggles/themes")
|
||||||
("w" . "windows")
|
("w" "windows")
|
||||||
("wp" . "windows-popup")
|
("wp" "windows-popup")
|
||||||
("x" . "text")
|
("x" "text")
|
||||||
("xa" . "text-align")
|
("xa" "text-align")
|
||||||
("xd" . "text-delete")
|
("xd" "text-delete")
|
||||||
("xg" . "text-google-translate")
|
("xg" "text-google-translate")
|
||||||
("xm" . "text-move")
|
("xm" "text-move")
|
||||||
("xt" . "text-transpose")
|
("xt" "text-transpose")
|
||||||
("xw" . "text-words")
|
("xw" "text-words")
|
||||||
("z" . "zoom")))
|
("z" "zoom")))
|
||||||
(mapc (lambda (x) (spacemacs/declare-prefix (car x) (cdr x)))
|
(mapc (lambda (x) (apply #'spacemacs/declare-prefix x))
|
||||||
spacemacs/key-binding-prefixes)
|
spacemacs/key-binding-prefixes)
|
||||||
|
|
||||||
;; ---------------------------------------------------------------------------
|
;; ---------------------------------------------------------------------------
|
||||||
|
|
|
@ -62,6 +62,7 @@
|
||||||
|
|
||||||
(defvar spacemacs/prefix-command-string "group:"
|
(defvar spacemacs/prefix-command-string "group:"
|
||||||
"Prefix string for prefix commands.")
|
"Prefix string for prefix commands.")
|
||||||
|
(defvar spacemacs/prefix-titles (list))
|
||||||
|
|
||||||
(defun spacemacs/jump-in-buffer ()
|
(defun spacemacs/jump-in-buffer ()
|
||||||
(interactive)
|
(interactive)
|
||||||
|
@ -71,14 +72,20 @@
|
||||||
(t
|
(t
|
||||||
(call-interactively 'helm-semantic-or-imenu))))
|
(call-interactively 'helm-semantic-or-imenu))))
|
||||||
|
|
||||||
(defun spacemacs/declare-prefix (prefix name)
|
(defun spacemacs/declare-prefix (prefix name &optional long-name)
|
||||||
"Declare a prefix PREFIX. PREFIX is a string describing
|
"Declare a prefix PREFIX. PREFIX is a string describing a key
|
||||||
a key sequence. NAME is a symbol name used as the prefix command."
|
sequence. NAME is a symbol name used as the prefix command.
|
||||||
(let ((command (intern (concat spacemacs/prefix-command-string name))))
|
LONG-NAME if given is stored in `spacemacs/prefix-command-alist'."
|
||||||
|
(let ((command (intern (concat spacemacs/prefix-command-string name)))
|
||||||
|
(full-prefix-vim (listify-key-sequence (kbd (concat dotspacemacs-leader-key " " prefix))))
|
||||||
|
(full-prefix-emacs (listify-key-sequence (kbd (concat dotspacemacs-emacs-leader-key " " prefix)))))
|
||||||
;; define the prefix command only if it does not already exist
|
;; define the prefix command only if it does not already exist
|
||||||
|
(unless long-name (setq long-name name))
|
||||||
(unless (lookup-key evil-leader--default-map prefix)
|
(unless (lookup-key evil-leader--default-map prefix)
|
||||||
(define-prefix-command command)
|
(define-prefix-command command)
|
||||||
(evil-leader/set-key prefix command))))
|
(evil-leader/set-key prefix command)
|
||||||
|
(push (cons full-prefix-vim long-name) spacemacs/prefix-titles)
|
||||||
|
(push (cons full-prefix-emacs long-name) spacemacs/prefix-titles))))
|
||||||
|
|
||||||
(defun spacemacs/declare-prefix-for-mode (mode prefix name)
|
(defun spacemacs/declare-prefix-for-mode (mode prefix name)
|
||||||
;; "Declare a prefix PREFIX. MODE is the mode in which this prefix command should
|
;; "Declare a prefix PREFIX. MODE is the mode in which this prefix command should
|
||||||
|
|
|
@ -3676,6 +3676,16 @@ one of `l' or `r'."
|
||||||
;; disorienting if you don't understand it
|
;; disorienting if you don't understand it
|
||||||
(setq which-key-special-keys nil)
|
(setq which-key-special-keys nil)
|
||||||
(setq which-key-use-C-h-for-paging t)
|
(setq which-key-use-C-h-for-paging t)
|
||||||
|
(setq which-key-prefix-title-alist
|
||||||
|
`((,(listify-key-sequence
|
||||||
|
(kbd (concat dotspacemacs-leader-key " m"))) . "Major mode commands")
|
||||||
|
(,(listify-key-sequence
|
||||||
|
(kbd (concat dotspacemacs-emacs-leader-key " m"))) . "Major mode commands")
|
||||||
|
(,(listify-key-sequence
|
||||||
|
(kbd dotspacemacs-leader-key)) . "Spacemacs root")
|
||||||
|
(,(listify-key-sequence
|
||||||
|
(kbd dotspacemacs-emacs-leader-key)) . "Spacemacs root")))
|
||||||
|
(nconc which-key-prefix-title-alist spacemacs/prefix-titles)
|
||||||
(spacemacs|diminish which-key-mode " Ⓚ" " K"))))
|
(spacemacs|diminish which-key-mode " Ⓚ" " K"))))
|
||||||
|
|
||||||
(defun spacemacs/init-window-numbering ()
|
(defun spacemacs/init-window-numbering ()
|
||||||
|
|
Reference in a new issue