branch: externals/detached commit 18c388bb4817a0d2c5b7b071873a3aee87bae4a8 Author: Niklas Eklund <niklas.ekl...@posteo.net> Commit: Niklas Eklund <niklas.ekl...@posteo.net>
Update attach shell command Use detached-with-session macro. --- detached.el | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/detached.el b/detached.el index d13fb5a8aa..7a296506f5 100644 --- a/detached.el +++ b/detached.el @@ -574,8 +574,8 @@ Optionally TOGGLE-SESSION-MODE." (defun detached-attach-session (session) "Attach to SESSION." (interactive - (list (detached-completing-read (detached-get-sessions)))) - (when (detached-valid-session session) + (list (detached-session-in-context))) + (when session (let ((initialized-session (detached--get-initialized-session session))) (if (detached-session-inactive-p initialized-session) (detached-open-session initialized-session) @@ -909,19 +909,18 @@ This function uses the `notifications' library." (defun detached-shell-command-attach-session (session) "Attach to SESSION with `async-shell-command'." - (let* ((detached-current-session session) - (inhibit-message t)) - (cl-letf* (((symbol-function #'set-process-sentinel) #'ignore) - (buffer (get-buffer-create detached--shell-command-buffer)) - (detached-local-session (detached--session-local session)) - (default-directory (detached-session-directory session)) - (command (detached-session-attach-command session :type 'string))) - (when (get-buffer-process buffer) - (setq buffer (generate-new-buffer (buffer-name buffer)))) - (funcall #'async-shell-command command buffer) - (with-current-buffer buffer - (setq-local default-directory (detached-session-working-directory session)) - (setq detached-buffer-session detached-current-session))))) + (let* ((inhibit-message t)) + (detached-with-session session + (cl-letf* (((symbol-function #'set-process-sentinel) #'ignore) + (buffer (get-buffer-create detached--shell-command-buffer)) + (default-directory (detached-session-directory session)) + (command (detached-session-attach-command session :type 'string))) + (when (get-buffer-process buffer) + (setq buffer (generate-new-buffer (buffer-name buffer)))) + (funcall #'async-shell-command command buffer) + (with-current-buffer buffer + (setq-local default-directory (detached-session-working-directory session)) + (setq detached-buffer-session detached-current-session)))))) (defun detached-start-shell-command-session (session) "Start SESSION as a `shell-command'."