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

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

[elpa] externals/dtache b247ddc6dd 077/158: Rewrite dtache-dtach-command


From: ELPA Syncer
Subject: [elpa] externals/dtache b247ddc6dd 077/158: Rewrite dtache-dtach-command
Date: Wed, 19 Jan 2022 18:57:59 -0500 (EST)

branch: externals/dtache
commit b247ddc6dd4fc100ffd0c9240beeed41c38be5b3
Author: Niklas Eklund <niklas.eklund@posteo.net>
Commit: Niklas Eklund <niklas.eklund@posteo.net>

    Rewrite dtache-dtach-command
    
    Implement the function using defmethod in order to work both for
    commands as well as sessions.
---
 dtache-shell.el |  3 +--
 dtache.el       | 36 ++++++++++++++++++++++--------------
 2 files changed, 23 insertions(+), 16 deletions(-)

diff --git a/dtache-shell.el b/dtache-shell.el
index 664929cf4c..9d73eb680f 100644
--- a/dtache-shell.el
+++ b/dtache-shell.el
@@ -133,8 +133,7 @@ cluttering the comint-history with dtach commands."
                    dtache-shell-new-block-list)
                   'create
                 dtache--dtach-mode))
-             (session (dtache-create-session (substring-no-properties string)))
-             (dtach-command (dtache-dtach-command session t)))
+             (dtach-command (dtache-dtach-command (substring-no-properties 
string) t)))
        (comint-simple-send proc dtach-command)
      (comint-simple-send proc string))))
 
diff --git a/dtache.el b/dtache.el
index af70718a43..364cf355ee 100644
--- a/dtache.el
+++ b/dtache.el
@@ -455,8 +455,7 @@ Optionally SUPPRESS-OUTPUT."
                (dtache-redirect-only-p command)))
       (let* ((inhibit-message t)
              (dtache--dtach-mode 'new)
-             (session (dtache-create-session command))
-             (dtach-command (dtache-dtach-command session)))
+             (dtach-command (dtache-dtach-command command)))
         (apply #'start-file-process
                `("dtache" nil ,dtache-dtach-program ,@dtach-command)))
     (cl-letf* ((inhibit-message t)
@@ -655,8 +654,17 @@ If session is not valid trigger an automatic cleanup on 
SESSION's host."
         (dtache--session-macos-monitor session)
       (dtache--session-filenotify-monitor session))))
 
-(defun dtache-dtach-command (session &optional concat)
-  "Return a list of arguments to run SESSION.
+(cl-defgeneric dtache-dtach-command (entity &optional concat)
+  "Return dtach command for ENTITY optionally CONCAT.")
+
+(cl-defgeneric dtache-dtach-command ((command string) &optional concat)
+  "Return dtach command for COMMAND.
+
+Optionally CONCAT the command return command into a string."
+  (dtache-dtach-command (dtache-create-session command) concat))
+
+(cl-defgeneric dtache-dtach-command ((session dtache-session) &optional concat)
+  "Return dtach command for SESSION.
 
 Optionally CONCAT the command return command into a string."
   (with-connection-local-variables
@@ -674,16 +682,16 @@ Optionally CONCAT the command return command into a 
string."
                         " ")
            `(,(dtache--dtach-arg) ,socket))
        (if concat
-             (mapconcat 'identity
-                        `(,dtache-dtach-program
-                          ,(dtache--dtach-arg)
-                          ,socket "-z"
-                          ,dtache-shell-program "-c"
-                          ,(shell-quote-argument (dtache--magic-command 
session)))
-                        " ")
-           `(,(dtache--dtach-arg) ,socket "-z"
-             ,dtache-shell-program "-c"
-             ,(dtache--magic-command session)))))))
+           (mapconcat 'identity
+                      `(,dtache-dtach-program
+                        ,(dtache--dtach-arg)
+                        ,socket "-z"
+                        ,dtache-shell-program "-c"
+                        ,(shell-quote-argument (dtache--magic-command 
session)))
+                      " ")
+         `(,(dtache--dtach-arg) ,socket "-z"
+           ,dtache-shell-program "-c"
+           ,(dtache--magic-command session)))))))
 
 (defun dtache-redirect-only-p (command)
   "Return t if COMMAND should run in degreaded mode."



reply via email to

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