Helm/EXWM: Fix loss of focus

master
Pierre Neidhardt 2017-11-02 10:36:46 +01:00
parent 9ad4f9e26c
commit a4fca96b09
1 changed files with 23 additions and 25 deletions

View File

@ -18,13 +18,7 @@
;; 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. ;; Write an all-exwm buffer source.
;; TODO: s-w s-w loses focus. ;; REVIEW: Helm buffer does not die? Seems to be fixed.
;; We don't get the expected error:
;; "helm: Error: Trying to run helm within a running helm session"
;; Instead, another s-w shows
;; "Aborting an helm session running in background"
;; TODO: Helm buffer does not die?
;; TODO: kill-persistent is not persistent. ;; TODO: kill-persistent is not persistent.
@ -98,24 +92,28 @@ If there is none, start PROGRAM.
If PROGRAM is nil, it defaults to CLASS. If PROGRAM is nil, it defaults to CLASS.
With prefix argument or if OTHER-WINDOW is non-nil, open in other window." With prefix argument or if OTHER-WINDOW is non-nil, open in other window."
(setq program (or program class) ;; If current window is not in `exwm-mode' we switch to it. Therefore we must
other-window (or other-window current-prefix-arg)) ;; also make sure that current window is not a Helm buffer, otherwise calling
(if (and (eq major-mode 'exwm-mode) ;; this function will lose focus in Helm.
(string= (downcase exwm-class-name) class)) (unless helm-alive-p
(if (fboundp 'helm-exwm-buffers) (setq program (or program class)
(helm-exwm-buffers class) other-window (or other-window current-prefix-arg))
(when other-window (other-window 1)) (if (and (eq major-mode 'exwm-mode)
(start-process-shell-command program nil program)) (string= (downcase exwm-class-name) class))
(let ((last (buffer-list))) (if (fboundp 'helm-exwm-buffers)
(while (and last (helm-exwm-buffers class)
(not (with-current-buffer (car last) (when other-window (other-window 1))
(and (eq major-mode 'exwm-mode) (start-process-shell-command program nil program))
(string= (downcase exwm-class-name) class))))) (let ((last (buffer-list)))
(setq last (cdr last))) (while (and last
(if last (not (with-current-buffer (car last)
(funcall (if other-window 'switch-to-buffer-other-window 'switch-to-buffer) (car last)) (and (eq major-mode 'exwm-mode)
(when other-window (select-window (split-window-sensibly))) (string= (downcase exwm-class-name) class)))))
(start-process-shell-command program nil program))))) (setq last (cdr last)))
(if last
(funcall (if other-window 'switch-to-buffer-other-window 'switch-to-buffer) (car last))
(when other-window (select-window (split-window-sensibly)))
(start-process-shell-command program nil program))))))
(defun helm-exwm-switch-browser () (defun helm-exwm-switch-browser ()
"Switch to some `browse-url-generic-program' windows. "Switch to some `browse-url-generic-program' windows.