diff options
author | Miguel Ángel Moreno <mail@migalmoreno.com> | 2022-09-17 20:13:11 +0200 |
---|---|---|
committer | Miguel Ángel Moreno <mail@migalmoreno.com> | 2023-03-15 12:18:26 +0100 |
commit | 5fd4c9ffe9376a7671d93ce1fee7d210a64958d1 (patch) | |
tree | 761316162502fb7df0b59a9b105d7e0a5d4f28e0 | |
parent | a2d164b9a6482d7419f94e2c39ed29e2c51ae695 (diff) |
feat: Add autostart delay and ensure sexps are run in nyxt-user
-rw-r--r-- | nyxt.el | 20 |
1 files changed, 12 insertions, 8 deletions
@@ -99,7 +99,7 @@ it switches to its corresponding workspace." (when (equal (current-buffer) nyxt-buffer) (exwm-input-set-local-simulation-keys nil)))))) -(cl-defun nyxt-run (sexps &key (focus nil) (autostart nil)) +(cl-defun nyxt-run (sexps &key (focus nil) (autostart nil) (autostart-delay 0)) "Evaluate SEXPS in the context of the current Nyxt connection. If FOCUS, change focus to the Nyxt exwm workspace. If AUTOSTART is non-nil @@ -125,17 +125,21 @@ connect Slynk to it." (forward-line 0) (cond ((string-match (rx (: (+ any) "Slynk server started at port")) output) - (run-at-time 2 nil (lambda () - (let ((sly-default-connection (nyxt-connect-to-slynk))) - (nyxt-exwm-focus-window :focus focus) - (nyxt-sly-eval sexps))))) + (run-at-time autostart-delay nil + (lambda () + (let ((sly-default-connection (nyxt-connect-to-slynk))) + (nyxt-exwm-focus-window :focus focus) + (nyxt-sly-eval sexps))))) ((or (string-match (rx (: (+ any) "Deleting socket")) output) (/= (process-exit-status process) 0)) (setq nyxt-process nil))))))) ((or (nyxt--system-process-p) nyxt-process) - (nyxt-exwm-focus-window :focus focus) - (nyxt-sly-eval sexps))))) + (with-current-buffer (sly-mrepl--find-buffer) + (unless (string= (sly-current-package) "nyxt-user") + (sly-mrepl--eval-for-repl '(slynk-mrepl:guess-and-set-package "nyxt-user"))) + (nyxt-exwm-focus-window :focus focus) + (nyxt-sly-eval sexps)))))) (defun nyxt-extension-p (system &optional symbol) "Check if Nyxt extension SYSTEM exists in the ASDF source registry. @@ -203,7 +207,7 @@ If ROAM-P, store it in the corresponding Org Roam capture TEMPLATE." `(buffer-load (first (nyxt::input->queries ,query)) :buffer (make-buffer-focus)) - :focus t :autostart t)) + :focus t :autostart t :autostart-delay 2)) ;;;###autoload (defun nyxt-change-theme (theme) |