diff --git a/spacemacs/config.el b/spacemacs/config.el index 2307b1716..772e42703 100644 --- a/spacemacs/config.el +++ b/spacemacs/config.el @@ -14,54 +14,54 @@ ;; Prefixes ;; --------------------------------------------------------------------------- -;; We define prefix commands only for the sake of guide-key -(setq spacemacs/key-binding-prefixes '(("a" . "applications") - ("ai" . "applications-irc") - ("as" . "applications-shells") - ("b" . "buffers") - ("bm" . "buffers-move") - ("c" . "compile/comments") - ("C" . "capture/colors") - ("e" . "errors") - ("E" . "editing-modes") - ("f" . "files") - ("fe" . "files-emacs/spacemacs") - ("g" . "git/versions-control") - ("h" . "helm/help/highlight") - ("hd" . "help-describe") - ("i" . "insertion") - ("j" . "join/split") - ("k" . "lisp") - ("kd" . "lisp-delete") - ("kD" . "lisp-delete-backward") - ("k`" . "lisp-hybrid") - ("n" . "narrow/numbers") - ("p" . "projects") - ("p$" . "projects/shell") - ("q" . "quit") - ("r" . "registers/rings") - ("s" . "search/symbol") - ("sa" . "search-ag") - ("sg" . "search-grep") - ("sk" . "search-ack") - ("st" . "search-pt") - ("sw" . "search-web") - ("t" . "toggles") - ("tC" . "toggles-colors") - ("th" . "toggles-highlight") - ("tm" . "toggles-modeline") - ("T" . "toggles/themes") - ("w" . "windows") - ("wp" . "windows-popup") - ("x" . "text") - ("xa" . "text-align") - ("xd" . "text-delete") - ("xg" . "text-google-translate") - ("xm" . "text-move") - ("xt" . "text-transpose") - ("xw" . "text-words") - ("z" . "zoom"))) -(mapc (lambda (x) (spacemacs/declare-prefix (car x) (cdr x))) +;; We define prefix commands only for the sake of which-key +(setq spacemacs/key-binding-prefixes '(("a" "applications") + ("ai" "applications-irc") + ("as" "applications-shells") + ("b" "buffers") + ("bm" "buffers-move") + ("c" "compile/comments") + ("C" "capture/colors") + ("e" "errors") + ("E" "editing-modes") + ("f" "files") + ("fe" "files-emacs/spacemacs") + ("g" "git/versions-control") + ("h" "helm/help/highlight") + ("hd" "help-describe") + ("i" "insertion") + ("j" "join/split") + ("k" "lisp") + ("kd" "lisp-delete") + ("kD" "lisp-delete-backward") + ("k`" "lisp-hybrid") + ("n" "narrow/numbers") + ("p" "projects") + ("p$" "projects/shell") + ("q" "quit") + ("r" "registers/rings") + ("s" "search/symbol") + ("sa" "search-ag") + ("sg" "search-grep") + ("sk" "search-ack") + ("st" "search-pt") + ("sw" "search-web") + ("t" "toggles") + ("tC" "toggles-colors") + ("th" "toggles-highlight") + ("tm" "toggles-modeline") + ("T" "toggles/themes") + ("w" "windows") + ("wp" "windows-popup") + ("x" "text") + ("xa" "text-align") + ("xd" "text-delete") + ("xg" "text-google-translate") + ("xm" "text-move") + ("xt" "text-transpose") + ("xw" "text-words") + ("z" "zoom"))) +(mapc (lambda (x) (apply #'spacemacs/declare-prefix x)) spacemacs/key-binding-prefixes) ;; --------------------------------------------------------------------------- diff --git a/spacemacs/funcs.el b/spacemacs/funcs.el index be5ac8fc7..fed0dc9eb 100644 --- a/spacemacs/funcs.el +++ b/spacemacs/funcs.el @@ -62,6 +62,7 @@ (defvar spacemacs/prefix-command-string "group:" "Prefix string for prefix commands.") +(defvar spacemacs/prefix-titles (list)) (defun spacemacs/jump-in-buffer () (interactive) @@ -71,14 +72,20 @@ (t (call-interactively 'helm-semantic-or-imenu)))) -(defun spacemacs/declare-prefix (prefix name) - "Declare a prefix PREFIX. PREFIX is a string describing -a key sequence. NAME is a symbol name used as the prefix command." - (let ((command (intern (concat spacemacs/prefix-command-string name)))) +(defun spacemacs/declare-prefix (prefix name &optional long-name) + "Declare a prefix PREFIX. PREFIX is a string describing a key +sequence. NAME is a symbol name used as the prefix command. +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 + (unless long-name (setq long-name name)) (unless (lookup-key evil-leader--default-map prefix) (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) ;; "Declare a prefix PREFIX. MODE is the mode in which this prefix command should diff --git a/spacemacs/packages.el b/spacemacs/packages.el index b44cde17d..31b746823 100644 --- a/spacemacs/packages.el +++ b/spacemacs/packages.el @@ -3676,6 +3676,16 @@ one of `l' or `r'." ;; disorienting if you don't understand it (setq which-key-special-keys nil) (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")))) (defun spacemacs/init-window-numbering ()