2.3 KiB
2.3 KiB
Consult Buffer Source for EXWM Windows
This lets me select windows in EXWM using Consult; hitting, uhmm, C-x b e <SPC>
will show me all the EXWM windows and C-x b E <SPC>
will show me windows in the current workspace.
(defun consult-exwm--state ()
(lexical-let ((preview (consult--buffer-preview)))
(lambda (action cand)
(when cand
(funcall preview action (get-buffer cand))
(when
(and cand (eq action 'return))
(consult--buffer-action
(get-buffer cand)))))))
(defvar exwm-buffer-source-this-workspace
`(:name "EXWM Windows (in this workspace)"
:hidden nil
:narrow ?E
:category exwm-window
:annotate ,(lambda (cand) (with-current-buffer cand
exwm-class-name))
:state ,#'consult-exwm--state
:items ,(lambda ()
(consult--buffer-query
:sort 'visibility
:filter t
:as #'buffer-name
:predicate (lambda (buf)
(with-current-buffer buf
(and
(eq major-mode 'exwm-mode)
(eq exwm-workspace--current
exwm--frame))))))))
(defvar exwm-buffer-source
`(:name "EXWM Windows"
:hidden nil
:narrow ?e
:category exwm-window
:annotate ,(lambda (cand) (with-current-buffer cand
exwm-class-name))
:state ,#'consult-exwm--state
:items ,(lambda ()
(consult--buffer-query
:sort 'visibility
:filter t
:as #'buffer-name
:predicate (lambda (buf)
(with-current-buffer buf
(eq major-mode 'exwm-mode)))))))
(with-eval-after-load 'consult
(add-to-list 'consult-buffer-sources 'exwm-buffer-source t)
(add-to-list 'consult-buffer-sources 'exwm-buffer-source-this-workspace t))