branch: externals/detached commit aa75d63a4cacd9a799dc153ea8e97187a2c9c470 Author: Niklas Eklund <niklas.ekl...@posteo.net> Commit: Niklas Eklund <niklas.ekl...@posteo.net>
Update session start command --- detached-compile.el | 3 ++- detached-eshell.el | 4 +++- detached-org.el | 7 +++++-- detached-shell.el | 2 +- detached-vterm.el | 3 ++- detached.el | 19 ++++++++++++------- 6 files changed, 25 insertions(+), 13 deletions(-) diff --git a/detached-compile.el b/detached-compile.el index 4ebc51da2f..60d0b1ea82 100644 --- a/detached-compile.el +++ b/detached-compile.el @@ -115,7 +115,8 @@ Optionally EDIT-COMMAND." (detached-start-detached-session detached--current-session) (apply compilation-start `(,(if (eq detached-session-mode 'attach) (detached--shell-command detached--current-session t) - (detached-session-start-command detached--current-session 'concat)) + (detached-session-start-command detached--current-session + :type 'string)) ,(or mode 'detached-compilation-mode) ,name-function ,highlight-regexp)))) diff --git a/detached-eshell.el b/detached-eshell.el index 4046d65143..6add34cda5 100644 --- a/detached-eshell.el +++ b/detached-eshell.el @@ -49,7 +49,9 @@ (let* ((detached-session-action detached-eshell-session-action) (command (string-trim-right (string-join (flatten-list args) " "))) (session (detached-create-session command)) - (command (detached--shell-command session))) + (command + (detached-session-start-command session + :type 'list))) (advice-remove #'eshell-external-command #'detached-eshell-external-command) (setq detached--buffer-session session) (setq detached-enabled nil) diff --git a/detached-org.el b/detached-org.el index dc887b68c2..b933419d29 100644 --- a/detached-org.el +++ b/detached-org.el @@ -54,10 +54,13 @@ property of :detached t in the org babel src block." (detached-session-action detached-org-session-action) (detached-session-mode 'create) (new-command (replace-regexp-in-string "\n" " && " full-body)) + (detached-session (detached-create-session new-command)) (dtach-command (if (string= "none" (alist-get :session params)) - (detached--dtach-command new-command t) - (format "%s\necho \"[detached]\"" (detached--dtach-command new-command t)))) + (detached-session-start-command detached-session + :type 'string) + (format "%s\necho \"[detached]\"" (detached-session-start-command detached-session + :type 'string)))) ((symbol-function #'org-babel-eval) (lambda (_ command) (start-file-process-shell-command "detached-org" nil command) diff --git a/detached-shell.el b/detached-shell.el index 11299a488e..8c0c679e8a 100644 --- a/detached-shell.el +++ b/detached-shell.el @@ -111,7 +111,7 @@ cluttering the `comint-history' with dtach commands." (let* ((session (detached-create-session (substring-no-properties string))) (command - (detached-session-start-command session 'concat))) + (detached-session-start-command session :type 'string))) (setq detached--buffer-session session) (comint-simple-send proc command)))) diff --git a/detached-vterm.el b/detached-vterm.el index f8222b55f6..e84cf1ce37 100644 --- a/detached-vterm.el +++ b/detached-vterm.el @@ -59,7 +59,8 @@ Optionally DETACH from it." (detached-session-mode (if detach 'create 'create-and-attach)) (detached--current-session (detached-create-session input)) - (command (detached--shell-command detached--current-session t))) + (command (detached-session-start-command detached--current-session + :type 'string))) (vterm-send-C-a) (vterm-send-C-k) (process-send-string vterm--process command) diff --git a/detached.el b/detached.el index d84ee6ef94..f9d87df320 100644 --- a/detached.el +++ b/detached.el @@ -905,10 +905,8 @@ 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." +(cl-defun detached-session-start-command (session &key type) + "Return command to start SESSION with specified TYPE." (detached-connection-local-variables (let* ((socket (detached--session-file session 'socket t)) (log (detached--session-file session 'log t))) @@ -922,15 +920,22 @@ Optionally return concatenated string when CONCAT." (when (eq 'create-and-attach (detached--session-initial-mode session)) (detached-start-detached-session session)) - (if concat (string-join tail-command " ") tail-command)) + (pcase type + ('string (string-join tail-command " ")) + ('list tail-command) + (_ (error "Type not specified for session start command"))) + (if )) (let ((dtach-command `(,detached-dtach-program ,(detached--dtach-arg) ,socket "-z" ,detached-shell-program "-c" - ,(if concat + ,(if (eq type 'string) (shell-quote-argument (detached--detached-command session)) (detached--detached-command session))))) - (if concat (string-join dtach-command " ") dtach-command)))))) + (pcase type + ('string (string-join dtach-command " ")) + ('list dtach-command) + (_ (error "Type not specified for session start command")))))))) (defun detached-session-output (session) "Return content of SESSION's output."