emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/detached 023cfd93d9 1/3: Create function for starting a


From: ELPA Syncer
Subject: [elpa] externals/detached 023cfd93d9 1/3: Create function for starting a detached session
Date: Thu, 6 Oct 2022 10:57:30 -0400 (EDT)

branch: externals/detached
commit 023cfd93d91b61b70c580dc506ca321aab42df4b
Author: Niklas Eklund <niklas.eklund@posteo.net>
Commit: Niklas Eklund <niklas.eklund@posteo.net>

    Create function for starting a detached session
---
 detached-compile.el | 14 +++++++-------
 detached.el         | 15 ++++++++++-----
 2 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/detached-compile.el b/detached-compile.el
index c759d0d692..f43f4d58b0 100644
--- a/detached-compile.el
+++ b/detached-compile.el
@@ -57,7 +57,8 @@ Optionally enable COMINT if prefix-argument is provided."
          (detached-session-origin (or detached-session-origin 'compile))
          (detached-session-action (or detached-session-action
                                       detached-compile-session-action))
-         (detached-session-mode (or detached-session-mode 'create-and-attach)))
+         (detached-session-mode (or detached-session-mode 'create-and-attach))
+         (detached--current-session (detached-create-session command)))
     (compile command comint)))
 
 ;;;###autoload
@@ -68,7 +69,8 @@ Optionally EDIT-COMMAND."
   (let* ((detached-enabled t)
          (detached-session-action detached-compile-session-action)
          (detached-session-origin 'compile)
-         (detached-session-mode 'create-and-attach))
+         (detached-session-mode 'create-and-attach)
+         (detached--current-session edit-command))
     (recompile edit-command)))
 
 (defun detached-compile-kill ()
@@ -107,13 +109,11 @@ Optionally EDIT-COMMAND."
 (defun detached-compile--compilation-start (compilation-start &rest args)
   "Create a `detached' session before running COMPILATION-START with ARGS."
   (if detached-enabled
-      (pcase-let ((`(,command ,mode ,_ ,highlight-regexp) args)
+      (pcase-let ((`(,_command ,mode ,_name_function ,highlight-regexp) args)
                   (buffer-name "*detached-compilation*"))
         (if (eq detached-session-mode 'create)
-            (detached-start-session command t)
-          (cl-letf* ((name-function (lambda (_) buffer-name))
-                     (detached--current-session (or detached--current-session
-                                                    (detached-create-session 
command))))
+            (detached-start-detached-session detached--current-session)
+          (cl-letf* ((name-function (lambda (_) buffer-name)))
             (apply compilation-start `(,(detached--shell-command 
detached--current-session t)
                                        ,(or mode 'detached-compilation-mode)
                                        ,name-function
diff --git a/detached.el b/detached.el
index 7e2024e922..9836454e34 100644
--- a/detached.el
+++ b/detached.el
@@ -679,11 +679,8 @@ Optionally SUPPRESS-OUTPUT."
                (or detached--current-session
                    (detached-create-session command))))
           (setq detached-enabled nil)
-          (if detached-local-session
-              (apply #'start-process-shell-command
-                     `("detached" nil ,(detached--dtach-command 
detached--current-session t)))
-            (apply #'start-file-process-shell-command
-                   `("detached" nil ,(detached--dtach-command 
detached--current-session t)))))
+          (detached-start-detached-session
+           detached--current-session))
       (cl-letf* ((detached-session-mode 'create-and-attach)
                  (detached--current-session
                   (or detached--current-session
@@ -698,6 +695,14 @@ Optionally SUPPRESS-OUTPUT."
         (with-current-buffer buffer
           (setq detached--buffer-session detached--current-session))))))
 
+(defun detached-start-detached-session (session)
+  "Start SESSION in detached mode."
+  (if detached-local-session
+      (apply #'start-process-shell-command
+             `("detached" nil ,(detached--dtach-command session t)))
+    (apply #'start-file-process-shell-command
+           `("detached" nil ,(detached--dtach-command session t)))))
+
 (defun detached-session-candidates (sessions)
   "Return an alist of SESSIONS candidates."
   (when sessions



reply via email to

[Prev in Thread] Current Thread [Next in Thread]