helm-exwm: Write some debugging code for persistent killing
parent
40e9146e50
commit
4bc7e23b77
|
@ -1,52 +1,56 @@
|
||||||
;;; helm-exwm
|
;;; helm-exwm
|
||||||
|
|
||||||
(defun foo ()
|
;; The following works, so `kill-buffer' on an EXWM window is fine.
|
||||||
|
(defun helm-exwm-kill-all ()
|
||||||
(dolist (b (buffer-list))
|
(dolist (b (buffer-list))
|
||||||
(let (victim count)
|
(with-current-buffer b
|
||||||
(with-current-buffer b
|
(when (eq major-mode 'exwm-mode)
|
||||||
(when (string-match "duck" (buffer-name))
|
(message "helm-exwm: Killing %s..." b)
|
||||||
(setq victim b)))
|
(kill-buffer b)
|
||||||
(when victim
|
(message "helm-exwm: Killed.")))))
|
||||||
(setq count (kill-buffer victim))
|
|
||||||
(message "HELM killed %s" count)))))
|
|
||||||
|
|
||||||
|
|
||||||
;; TODO: Post on EXWM's wiki once all TODOs are fixed.
|
;; TODO: Post on EXWM's wiki once all TODOs are fixed.
|
||||||
;; Publish on MELPA? Maybe with generic code for EXWM buffers with column
|
;; Publish on MELPA? Maybe with generic code for EXWM buffers with column
|
||||||
;; containing the class name, and and emacs-buffers helm source too.
|
;; containing the class name, and and emacs-buffers helm source too.
|
||||||
|
|
||||||
;; TODO: Change namespace to helm-exwm.
|
|
||||||
|
|
||||||
;; TODO: s-w s-w loses focus.
|
;; TODO: s-w s-w loses focus.
|
||||||
;; We should get
|
;; We don't get the expected error:
|
||||||
;; helm: Error: Trying to run helm within a running helm session
|
;; "helm: Error: Trying to run helm within a running helm session"
|
||||||
;; but we don't.
|
|
||||||
|
|
||||||
;; TODO: Helm buffer does not die?
|
;; TODO: Helm buffer does not die?
|
||||||
|
|
||||||
;; TODO: kill-persistent is not persistent.
|
;; TODO: kill-persistent is not persistent.
|
||||||
|
|
||||||
;; TODO: Killing buffers message "Killed 0 buffer(s)".
|
;; REVIEW: Killing buffers message "Killed 0 buffer(s)".
|
||||||
;; See https://github.com/ch11ng/exwm/issues/322.
|
;; See https://github.com/ch11ng/exwm/issues/322.
|
||||||
|
;; A workaround would be to discard the result of kill-buffer and print the
|
||||||
|
;; count manually.
|
||||||
|
|
||||||
(defvar exwm/helm-browser-map
|
(defvar helm-exwm-browser-map
|
||||||
(let ((map (make-sparse-keymap)))
|
(let ((map (make-sparse-keymap)))
|
||||||
(set-keymap-parent map helm-map)
|
(set-keymap-parent map helm-map)
|
||||||
(define-key map (kbd "C-c o") 'helm-buffer-switch-other-window)
|
(define-key map (kbd "C-c o") 'helm-buffer-switch-other-window)
|
||||||
(define-key map (kbd "C-c C-o") 'helm-buffer-switch-other-frame)
|
(define-key map (kbd "C-c C-o") 'helm-buffer-switch-other-frame)
|
||||||
(define-key map (kbd "M-D") 'helm-buffer-run-kill-buffers)
|
(define-key map (kbd "M-D") 'helm-buffer-run-kill-buffers)
|
||||||
(define-key map (kbd "C-c d") 'helm-buffer-run-kill-persistent)
|
;; (define-key map (kbd "C-c d") 'helm-buffer-run-kill-persistent)
|
||||||
;; (define-key map (kbd "C-c d") 'exwm/helm-browsers-run-kill-persistent)
|
(define-key map (kbd "C-c d") 'helm-exwm-buffer-run-kill-persistent)
|
||||||
map)
|
map)
|
||||||
"Keymap for browser source in Helm.")
|
"Keymap for browser source in Helm.")
|
||||||
|
|
||||||
;; (defun exwm/helm-update ()
|
;;; This fails to be persistent, nothing is run after kill-buffer.
|
||||||
;; (message "EXWM/HELM"))
|
(defun helm-exwm-buffer-run-kill-persistent ()
|
||||||
|
"Kill buffer without quitting helm."
|
||||||
|
(interactive)
|
||||||
|
(message "before")
|
||||||
|
(kill-buffer (car (helm-marked-candidates)))
|
||||||
|
(message "after"))
|
||||||
|
;; (put 'helm-exwm-buffer-run-kill-persistent 'helm-only t)
|
||||||
|
|
||||||
(defun exwm/helm-browser-buffers ()
|
(defun helm-exwm-browser-buffers ()
|
||||||
"Preconfigured `helm' to list browser buffers."
|
"Preconfigured `helm' to list browser buffers."
|
||||||
(interactive)
|
(interactive)
|
||||||
(helm :sources
|
(helm :sources
|
||||||
(helm-build-sync-source "exwm/helm browser buffers"
|
(helm-build-sync-source "helm-exwm browser buffers"
|
||||||
:candidates
|
:candidates
|
||||||
(let ((bufs (delq nil (mapcar
|
(let ((bufs (delq nil (mapcar
|
||||||
(lambda (buf)
|
(lambda (buf)
|
||||||
|
@ -59,19 +63,19 @@
|
||||||
(when bufs
|
(when bufs
|
||||||
;; Move first buffer (current) to last position.
|
;; Move first buffer (current) to last position.
|
||||||
(setcdr (last bufs) (list (pop bufs))))
|
(setcdr (last bufs) (list (pop bufs))))
|
||||||
(message "HELM %s" bufs)
|
|
||||||
bufs)
|
bufs)
|
||||||
:action '(("Switch to browser buffer(s)" . helm-buffer-switch-buffers)
|
:action '(("Switch to browser buffer(s)" . helm-buffer-switch-buffers)
|
||||||
("Switch to browser buffer(s) in other window `C-c o'" . helm-buffer-switch-buffers-other-window)
|
("Switch to browser buffer(s) in other window `C-c o'" . helm-buffer-switch-buffers-other-window)
|
||||||
("Switch to browser buffer in other frame `C-c C-o'" . switch-to-buffer-other-frame)
|
("Switch to browser buffer in other frame `C-c C-o'" . switch-to-buffer-other-frame)
|
||||||
("Kill browser buffer(s)" . helm-kill-marked-buffers))
|
("Kill browser buffer(s)" . helm-kill-marked-buffers))
|
||||||
;; When follow-mode is on, the persistent-action allows for multiple candidate selection.
|
;; When follow-mode is on, the persistent-action allows for multiple candidate selection.
|
||||||
;; :persistent-action 'helm-buffers-list-persistent-action
|
:persistent-action 'helm-buffers-list-persistent-action
|
||||||
;; :update 'exwm/helm-update
|
;; :update 'helm-exwm-update
|
||||||
:keymap exwm/helm-browser-map)
|
:keymap helm-exwm-browser-map)
|
||||||
:buffer "*exwm/helm browser*"))
|
:buffer "*helm-exwm browser*"))
|
||||||
|
|
||||||
(add-to-list 'helm-source-names-using-follow "exwm/helm browser buffers"))
|
;; (add-to-list 'helm-source-names-using-follow "helm-exwm browser buffers"))
|
||||||
|
;; (setq helm-source-names-using-follow nil)
|
||||||
|
|
||||||
(defun exwm-start-browser (&optional other-window)
|
(defun exwm-start-browser (&optional other-window)
|
||||||
"Fire-up the web browser as defined in `browse-url-generic-program'.
|
"Fire-up the web browser as defined in `browse-url-generic-program'.
|
||||||
|
@ -83,8 +87,8 @@ With prefix argument or if OTHER-WINDOW is non-nil, open in other window."
|
||||||
(interactive "P")
|
(interactive "P")
|
||||||
(if (and (eq major-mode 'exwm-mode)
|
(if (and (eq major-mode 'exwm-mode)
|
||||||
(string= (downcase exwm-class-name) (file-name-nondirectory browse-url-generic-program)))
|
(string= (downcase exwm-class-name) (file-name-nondirectory browse-url-generic-program)))
|
||||||
(if (fboundp 'exwm/helm-browser-buffers)
|
(if (fboundp 'helm-exwm-browser-buffers)
|
||||||
(exwm/helm-browser-buffers)
|
(helm-exwm-browser-buffers)
|
||||||
(when other-window (other-window 1))
|
(when other-window (other-window 1))
|
||||||
(start-process-shell-command browse-url-generic-program nil browse-url-generic-program))
|
(start-process-shell-command browse-url-generic-program nil browse-url-generic-program))
|
||||||
(let ((last (buffer-list)))
|
(let ((last (buffer-list)))
|
||||||
|
|
Loading…
Reference in New Issue