[compleseus] integration with which-key

https://github.com/oantolin/embark/wiki/Additional-Configuration#use-which-key-like-a-key-menu-prompt

embark-act `M-o` menu will be handled by which-key
This commit is contained in:
Thanh Vuong 2021-12-19 22:12:12 -07:00 committed by Maxi Wolff
parent 295b86e57a
commit eb3ebe2c6e
2 changed files with 41 additions and 6 deletions

View File

@ -151,3 +151,35 @@ Binding a key to: `find-file' calls: `ido-find-file'"
(interactive)
(selectrum-previous-candidate (or n 1))
(spacemacs/embark-preview))
;; which-key integration functions for embark
;; https://github.com/oantolin/embark/wiki/Additional-Configuration#use-which-key-like-a-key-menu-prompt
(defun spacemacs/embark-which-key-indicator ()
"An embark indicator that displays keymaps using which-key.
The which-key help message will show the type and value of the
current target followed by an ellipsis if there are further
targets."
(lambda (&optional keymap targets prefix)
(if (null keymap)
(which-key--hide-popup-ignore-command)
(which-key--show-keymap
(if (eq (plist-get (car targets) :type) 'embark-become)
"Become"
(format "Act on %s '%s'%s"
(plist-get (car targets) :type)
(embark--truncate-target (plist-get (car targets) :target))
(if (cdr targets) "" "")))
(if prefix
(pcase (lookup-key keymap prefix 'accept-default)
((and (pred keymapp) km) km)
(_ (key-binding prefix 'accept-default)))
keymap)
nil nil t (lambda (binding)
(not (string-suffix-p "-argument" (cdr binding))))))))
(defun spacemacs/embark-hide-which-key-indicator (fn &rest args)
"Hide the which-key indicator immediately when using the completing-read prompter."
(which-key--hide-popup-ignore-command)
(let ((embark-indicators
(remq #'spacemacs/embark-which-key-indicator embark-indicators)))
(apply fn args)))

View File

@ -250,13 +250,16 @@
;; same key binding as ivy-occur
(define-key minibuffer-local-map (kbd "C-c C-o") #'embark-export)
:config
(define-key embark-file-map "s" 'spacemacs/compleseus-search-from)))
;; Hide the mode line of the Embark live/completions buffers
;; (add-to-list 'display-buffer-alist
;; '("\\`\\*Embark Collect \\(Live\\|Completions\\)\\*"
;; nil
;; (window-parameters (mode-line-format . none))))
(define-key embark-file-map "s" 'spacemacs/compleseus-search-from)
;; which key integration setup
;; https://github.com/oantolin/embark/wiki/Additional-Configuration#use-which-key-like-a-key-menu-prompt
(setq embark-indicators
'(spacemacs/embark-which-key-indicator
embark-highlight-indicator
embark-isearch-highlight-indicator))
(advice-add #'embark-completing-read-prompter
:around #'spacemacs/embark-hide-which-key-indicator)))
(defun compleseus/init-embark-consult ()
(use-package embark-consult