branch: externals/detached commit 4b3609385d8910861f1ff338c7b3f97a02564902 Author: Niklas Eklund <niklas.ekl...@posteo.net> Commit: Niklas Eklund <niklas.ekl...@posteo.net>
Start session rewrite --- detached-compile.el | 4 +++- detached-shell.el | 3 ++- detached.el | 29 ++++++++++++++++++++++++++++- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/detached-compile.el b/detached-compile.el index ab3b86d7ef..4ebc51da2f 100644 --- a/detached-compile.el +++ b/detached-compile.el @@ -113,7 +113,9 @@ Optionally EDIT-COMMAND." (pcase-let ((`(,_command ,mode ,name-function ,highlight-regexp) args)) (if (eq detached-session-mode 'create) (detached-start-detached-session detached--current-session) - (apply compilation-start `(,(detached--shell-command detached--current-session t) + (apply compilation-start `(,(if (eq detached-session-mode 'attach) + (detached--shell-command detached--current-session t) + (detached-session-start-command detached--current-session 'concat)) ,(or mode 'detached-compilation-mode) ,name-function ,highlight-regexp)))) diff --git a/detached-shell.el b/detached-shell.el index 3c78e69550..11299a488e 100644 --- a/detached-shell.el +++ b/detached-shell.el @@ -110,7 +110,8 @@ cluttering the `comint-history' with dtach commands." (with-connection-local-variables (let* ((session (detached-create-session (substring-no-properties string))) - (command (detached--shell-command session t))) + (command + (detached-session-start-command session 'concat))) (setq detached--buffer-session session) (comint-simple-send proc command)))) diff --git a/detached.el b/detached.el index 79d21ab25e..d84ee6ef94 100644 --- a/detached.el +++ b/detached.el @@ -734,7 +734,7 @@ Optionally SUPPRESS-OUTPUT." (defun detached-start-detached-session (session) "Start SESSION in detached mode." - (if detached-local-session + (if (detached-session-local-p session) (apply #'start-process-shell-command `("detached" nil ,(detached--dtach-command session t))) (apply #'start-file-process-shell-command @@ -905,6 +905,33 @@ This function uses the `notifications' library." ;;;;; Public session functions +(defun detached-session-start-command (session &optional concat) + "Return command to start SESSION. + +Optionally return concatenated string when CONCAT." + (detached-connection-local-variables + (let* ((socket (detached--session-file session 'socket t)) + (log (detached--session-file session 'log t))) + (if (detached-session-degraded-p session) + (let ((tail-command + `(,detached-tail-program + "--follow=name" + "--retry" + ,(concat "--lines=" detached-session-context-lines) + ,log))) + (when (eq 'create-and-attach + (detached--session-initial-mode session)) + (detached-start-detached-session session)) + (if concat (string-join tail-command " ") tail-command)) + (let ((dtach-command + `(,detached-dtach-program + ,(detached--dtach-arg) ,socket "-z" + ,detached-shell-program "-c" + ,(if concat + (shell-quote-argument (detached--detached-command session)) + (detached--detached-command session))))) + (if concat (string-join dtach-command " ") dtach-command)))))) + (defun detached-session-output (session) "Return content of SESSION's output." (let* ((filename (detached--session-file session 'log))