Helm/EXWM: List all EXWM buffers

master
Pierre Neidhardt 2017-11-02 10:46:49 +01:00
parent a4fca96b09
commit 06ce657889
1 changed files with 10 additions and 5 deletions

View File

@ -16,7 +16,6 @@
;; containing the class name. ;; containing the class name.
;; TODO: Write a emacs-buffers helm source to filter out EXWM buffers from buffer list. ;; TODO: Write a emacs-buffers helm source to filter out EXWM buffers from buffer list.
;; Write an all-exwm buffer source.
;; REVIEW: Helm buffer does not die? Seems to be fixed. ;; REVIEW: Helm buffer does not die? Seems to be fixed.
@ -54,12 +53,15 @@
(kill-buffer (car (helm-marked-candidates))) (kill-buffer (car (helm-marked-candidates)))
(message "after")) (message "after"))
(defun helm-exwm-candidates (class) (defun helm-exwm-candidates (&optional class)
"Return the list of EXWM buffers belonging to CLASS.
If CLASS is nil, then list all EXWM buffers."
(let ((bufs (delq nil (mapcar (let ((bufs (delq nil (mapcar
(lambda (buf) (lambda (buf)
(if (with-current-buffer buf (if (with-current-buffer buf
(and (eq major-mode 'exwm-mode) (and (eq major-mode 'exwm-mode)
(string= (downcase exwm-class-name) class))) (or (not class) (string= (downcase exwm-class-name) class))))
(buffer-name buf) (buffer-name buf)
nil)) nil))
(buffer-list))))) (buffer-list)))))
@ -68,8 +70,11 @@
(setcdr (last bufs) (list (pop bufs)))) (setcdr (last bufs) (list (pop bufs))))
bufs)) bufs))
(defun helm-exwm-buffers (class) (defun helm-exwm-buffers (&optional class)
"Preconfigured `helm' to list EXWM buffers belonging to CLASS." "Preconfigured `helm' to list EXWM buffers belonging to CLASS.
If CLASS is nil, then list all EXWM buffers."
(interactive)
(helm :sources (helm :sources
(helm-build-sync-source "EXWM buffers" (helm-build-sync-source "EXWM buffers"
:candidates (helm-exwm-candidates class) :candidates (helm-exwm-candidates class)