From 0986db35bb51d5b3426a0aad9467bd3b1765358d Mon Sep 17 00:00:00 2001 From: jao Date: Wed, 7 Sep 2022 05:33:28 +0100 Subject: jao-river-toggle-emacs --- init.el | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/init.el b/init.el index f068a78..de13c05 100644 --- a/init.el +++ b/init.el @@ -485,14 +485,15 @@ (defsubst jao-river-get-focused-title () (alist-get 'title (jao-river-focused))) -(defun jao-river-focus-window (title) +(defun jao-river-focus-window (title &optional rx) (let* ((ws (jao-river-window-list)) - (w (seq-some (lambda (w) (and (equal title (alist-get 'title w)) w)) + (fltr (if rx #'string-match-p #'string=) ) + (w (seq-find (lambda (w) (funcall fltr title (alist-get 'title w ""))) ws))) (or (alist-get 'activated w) (seq-some (lambda (_ignored) (jao-shell-exec "riverctl focus-view next" t) - (equal title (jao-river-get-focused-title))) + (funcall fltr title (jao-river-get-focused-title))) (and w ws))))) (defun jao-river-zathura-to-org () @@ -538,6 +539,13 @@ (jao-tracking-set-log "")) (message "Welcome to river")) +(defun jao-river-toggle-emacs () + (if (member (jao-river-get-focused-title) '("emacsclient" "emacs")) + (jao-shell-exec "riverctl focus-previous-tags") + (jao-river-to-ws 1) + (unless (jao-river-focus-window "^emacs\\(client\\)?" t) + (jao-shell-exec* "riverctl" "spawn" "efoot")))) + (when jao-river-enabled (add-hook 'after-init-hook #'jao-river-enable)) -- cgit v1.2.3