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

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

[elpa] externals/detached 670433a5ab 6/6: Merge branch 'new-tailing'


From: ELPA Syncer
Subject: [elpa] externals/detached 670433a5ab 6/6: Merge branch 'new-tailing'
Date: Fri, 3 Jun 2022 03:57:32 -0400 (EDT)

branch: externals/detached
commit 670433a5ab47ab3a093b0441088311e30be9a993
Merge: 6e7a236fa5 28e3eb5b6a
Author: Niklas Eklund <niklas.eklund@posteo.net>
Commit: Niklas Eklund <niklas.eklund@posteo.net>

    Merge branch 'new-tailing'
---
 CHANGELOG.org         |   4 +-
 README.md             |  20 +++---
 detached-compile.el   |   5 +-
 detached-eshell.el    |   7 +--
 detached-shell.el     |  11 ++--
 detached-vterm.el     |   4 +-
 detached.el           | 165 ++++++++++++++++++++++++++++++--------------------
 test/detached-test.el |  35 ++++++-----
 8 files changed, 141 insertions(+), 110 deletions(-)

diff --git a/CHANGELOG.org b/CHANGELOG.org
index 3bfe8a8373..ccafaaadca 100644
--- a/CHANGELOG.org
+++ b/CHANGELOG.org
@@ -3,7 +3,9 @@
 #+language: en
 
 * Development
-- Remove tail command, favor using =attach= or =view= instead. To tail a 
session doesn't work as well as attaching to it. For non-attachable-commands it 
will open in log mode, and there is a keybinding for manually refresh the log 
output.
+- Detached now relies on the tool =tail= in order to attach to degraded 
sessions. That means that =dtach= and =tail= are required to properly use the 
package.
+- Rename non-attachable sessions to degraded sessions.
+- Remove tail command, favor using =attach= or =view=.
 - Improve support for Emacsen. The PID of all detached Emacsen are registered, 
this is done to be able to promote one Emacs to primary, which has the 
responsibility to update the database.
 - Add command to open a session's log file in =dired=.
 - Remove the need for =detached-shell-history-file=, the advice is updated to 
figure out the history file based on the shell program.
diff --git a/README.md b/README.md
index 8bd2900bf6..6444790e64 100644
--- a/README.md
+++ b/README.md
@@ -41,7 +41,7 @@ The package is available on [GNU ELPA](https://elpa.gnu.org) 
and [MELPA](https:/
 
 # Configuration
 
-The prerequisite for `detached.el` is that the user has the program `dtach` 
installed.
+The prerequisite for `detached.el` is that the user has the programs `dtach` 
and `tail` installed.
 
 ## Use-package example
 
@@ -192,7 +192,7 @@ The package provides the following customizable variables.
 | detached-timer-configuration         | Configuration of the timer that runs 
on remote hosts                             |
 | detached-annotation-format           | A list of annotations that should be 
present in completion                       |
 | detached-command-format              | A configuration for displaying a 
session command                                 |
-| detached-nonattachable-commands      | A list of commands that should be 
considered nonattachable                       |
+| detached-degraded-commands      | A list of commands that should be run in 
degraded mode                       |
 | detached-notification-function       | Specifies which function to issue 
notifications with                             |
 | detached-detach-key                  | Specifies which keybinding to use to 
detach from a session                       |
 | detached-shell-command-initial-input | Enables latest value in history to be 
used as initial input                      |
@@ -241,13 +241,9 @@ Users can customize the appearance of annotations in 
`detached-open-session` by
   "The format of the annotations.")
 ```
 
-## Show session output when attaching
+## Show session context when attaching
 
-By default the `detached-show-output-on-attach` is set to nil. However if the 
user enables this feature it means that all the output from a session will be 
shown when attaching to a session. To be able to do this the 
`detached-show-output-command` is used. This is set to use `cat` to display the 
output. Many times with long sessions showing all the output might not be 
necessary, or desirable. A good alternative is then to use `tail` as the 
command. For example by showing the last 50 line [...]
-
-``` emacs-lisp
-(setq detached-show-output-command "tail --lines=50")
-```
+By default the `detached-show-session-context` is set to t. This means that 
part of the output from a session will be shown when attaching to a session. 
The number of lines of the context is determined by 
`detached-session-context-lines`. The package uses `tail` in order to display 
the context.
 
 ## Metadata annotators
 
@@ -259,16 +255,16 @@ This function can be added as an annotation function to 
the `detached-metadata-a
 (setq detached-metadata-annotators-alist '((branch . 
detached--metadata-git-branch)))
 ```
 
-## Non-attachable commands
+## Degraded commands
 
 To be able to both attach to a dtach session as well as logging its output 
`detached.el` relies on the usage of `tee`. However it is possible that the 
user tries to run a command which involves a program that doesn't integrate 
well with tee. In those situations the output could be delayed until the 
session ends, which is not preferable.
 
-For these situations `detached.el` provides the 
`detached-nonattachable-commands` variable. This is a list of regular 
expressions. Any command that matches any of the strings will be getting the 
property `attachable` set to false.
+For these situations `detached.el` provides the `detached-degraded-commands` 
variable. This is a list of regular expressions. Any command that matches any 
of the strings will be getting the property `degraded` set to true.
 ``` emacs-lisp
-(setq detached-nonattachable-commands '("^ls"))
+(setq detached-degraded-commands '("^ls"))
 ```
 
-Here a command beginning with `ls` would from now on be considered 
non-attachable.
+Here a command beginning with `ls` would from now on be considered degraded, 
hence `detached` will use `tail`to tail the sessions log instead of attaching 
to the `dtach` process.
 
 ## Colors in sessions
 
diff --git a/detached-compile.el b/detached-compile.el
index 0c737bf6d4..cba80eb6ae 100644
--- a/detached-compile.el
+++ b/detached-compile.el
@@ -108,13 +108,12 @@ Optionally EDIT-COMMAND."
   (if detached-enabled
       (pcase-let ((`(,command ,mode ,_ ,highlight-regexp) args)
                   (buffer-name "*detached-compilation*"))
-        (if (and (not (eq detached-session-mode 'attach))
-                 (not (detached-attachable-command-p command)))
+        (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))))
-            (apply compilation-start `(,(detached-dtach-command 
detached--current-session t)
+            (apply compilation-start `(,(detached--shell-command 
detached--current-session t)
                                        ,(or mode 'detached-compilation-mode)
                                        ,name-function
                                        ,highlight-regexp)))))
diff --git a/detached-eshell.el b/detached-eshell.el
index 4c6c758ac1..adc0ca11ce 100644
--- a/detached-eshell.el
+++ b/detached-eshell.el
@@ -80,11 +80,10 @@ If prefix-argument directly DETACH from the session."
   (interactive
    (list (detached-eshell-select-session)))
   (when (detached-valid-session session)
-    (if (and (eq 'active (detached--determine-session-state session))
-             (detached--session-attachable session))
+    (if (eq 'active (detached--determine-session-state session))
         (cl-letf* ((detached-session-mode 'attach)
                    (input
-                    (detached-dtach-command session t))
+                    (detached--shell-command session t))
                    ((symbol-function #'eshell-add-to-history) #'ignore))
           (let ((kill-ring nil))
             (eshell-kill-input))
@@ -111,7 +110,7 @@ If prefix-argument directly DETACH from the session."
                               (flatten-list args)
                               " ")))
          (session (detached-create-session command))
-         (command (detached-dtach-command session)))
+         (command (detached--shell-command session)))
     (advice-remove #'eshell-external-command 
#'detached-eshell-external-command)
     (setq detached--buffer-session session)
     (setq detached-enabled nil)
diff --git a/detached-shell.el b/detached-shell.el
index 58a13c38a5..e3b9e5bfff 100644
--- a/detached-shell.el
+++ b/detached-shell.el
@@ -70,8 +70,7 @@ cluttering the comint-history with dtach commands."
   (interactive
    (list (detached-shell-select-session)))
   (when (detached-valid-session session)
-    (if (and (eq 'active (detached--determine-session-state session))
-             (detached--session-attachable session))
+    (if (eq 'active (detached--determine-session-state session))
         (cl-letf ((detached--current-session session)
                   (comint-input-sender #'detached-shell--attach-input-sender)
                   ((symbol-function 'comint-add-to-input-history) (lambda (_) 
t)))
@@ -88,15 +87,15 @@ cluttering the comint-history with dtach commands."
   "Attach to `detached--session' and send the attach command to PROC."
   (let* ((detached-session-mode 'attach)
          (input
-          (detached-dtach-command detached--current-session t)))
+          (detached--shell-command detached--current-session t)))
     (comint-simple-send proc input)))
 
 (defun detached-shell--create-input-sender (proc string)
   "Create a detached session based on STRING and send to PROC."
   (with-connection-local-variables
-   (let* ((command (substring-no-properties string))
-          (dtach-command (detached-dtach-command command t)))
-     (comint-simple-send proc dtach-command))))
+   (let* ((command (detached--shell-command
+                    (substring-no-properties string) t)))
+     (comint-simple-send proc command))))
 
 (defun detached-shell--comint-read-input-ring-advice (orig-fun &rest args)
   "Set `comint-input-ring-file-name' before calling ORIG-FUN with ARGS."
diff --git a/detached-vterm.el b/detached-vterm.el
index daff21faa4..71357d247a 100644
--- a/detached-vterm.el
+++ b/detached-vterm.el
@@ -53,7 +53,7 @@ Optionally DETACH from it."
          (detached-session-mode
           (if detach 'create 'create-and-attach)))
     (vterm-send-C-k)
-    (process-send-string vterm--process (detached-dtach-command input t))
+    (process-send-string vterm--process (detached--shell-command input t))
     (vterm-send-C-e)
     (vterm-send-return)))
 
@@ -70,7 +70,7 @@ Optionally DETACH from it."
                          (seq-filter (lambda (it) (eq 'active 
(detached--determine-session-state it)))))))
       (detached-completing-read sessions))))
   (let ((detached-session-mode 'attach))
-    (process-send-string vterm--process (detached-dtach-command session t))
+    (process-send-string vterm--process (detached--shell-command session t))
     (vterm-send-return)))
 
 ;;;###autoload
diff --git a/detached.el b/detached.el
index 0fcd3c70aa..9515fbe44b 100644
--- a/detached.el
+++ b/detached.el
@@ -68,7 +68,12 @@
   :group 'detached)
 
 (defcustom detached-dtach-program "dtach"
-  "The name of the `dtach' program."
+  "The name of the dtach program."
+  :type 'string
+  :group 'detached)
+
+(defcustom detached-tail-program "tail"
+  "The name of the tail program."
   :type 'string
   :group 'detached)
 
@@ -77,14 +82,14 @@
   :type 'string
   :group 'detached)
 
-(defcustom detached-show-output-on-attach nil
-  "If set to t show the session output when attaching to it."
-  :type 'bool
+(defcustom detached-session-context-lines 50
+  "Number of context lines to display for a session."
+  :type 'string
   :group 'detached)
 
-(defcustom detached-show-output-command (executable-find "cat")
-  "The command to be run to show a sessions output."
-  :type 'string
+(defcustom detached-show-session-context t
+  "If session context should be shown when attaching."
+  :type 'boolean
   :group 'detached)
 
 (defcustom detached-terminal-data-command "script --quiet --flush --return 
--command \"%s\" /dev/null"
@@ -132,8 +137,8 @@ If set to a non nil value the latest entry to
   :type 'bool
   :group 'detached)
 
-(defcustom detached-nonattachable-commands nil
-  "A list of commands which `detached' should consider nonattachable."
+(defcustom detached-degraded-commands nil
+  "A list of commands which `detached' should consider degraded."
   :type '(repeat (regexp :format "%v"))
   :group 'detached)
 
@@ -184,7 +189,7 @@ Valid values are: create, new and attach")
 (defvar detached-metadata-annotators-alist nil
   "An alist of annotators for metadata.")
 
-(defconst detached-session-version "0.7.1"
+(defconst detached-session-version "0.7.2"
   "The version of `detached-session'.
 This version is encoded as [package-version].[revision].")
 
@@ -271,7 +276,7 @@ This version is encoded as [package-version].[revision].")
   (directory nil :read-only t)
   (metadata nil :read-only t)
   (host nil :read-only t)
-  (attachable nil :read-only t)
+  (degraded nil :read-only t)
   (env nil :read-only t)
   (action nil :read-only t)
   (time nil)
@@ -379,9 +384,8 @@ The session is compiled by opening its output and enabling
   (interactive
    (list (detached-completing-read (detached-get-sessions))))
   (when (detached-valid-session session)
-    (if (or (eq 'inactive (detached--session-state session))
-            (not (detached--session-attachable session)))
-        (detached-view-dwim session)
+    (if (eq 'inactive (detached--session-state session))
+        (detached-open-session session)
       (if-let ((attach-fun (plist-get (detached--session-action session) 
:attach)))
           (funcall attach-fun session)
         (detached-shell-command-attach-session session)))))
@@ -463,20 +467,6 @@ Optionally DELETE the session if prefix-argument is 
provided."
             (pop-to-buffer buffer-name))
         (message "Detached can't find file: %s" file-path)))))
 
-;;;###autoload
-(defun detached-refresh-session-log ()
-  "Refresh log content of session in current buffer."
-  (interactive)
-  (let* ((session detached--buffer-session)
-         (inhibit-read-only t))
-    (if (not (eq 'active (detached--session-state session)))
-        (message "Session is inactive")
-      (erase-buffer)
-      (insert (detached--session-output session))
-      (detached-log-mode)
-      (setq detached--buffer-session session)
-      (goto-char (point-max)))))
-
 ;;;###autoload
 (defun detached-diff-session (session1 session2)
   "Diff SESSION1 with SESSION2."
@@ -576,7 +566,7 @@ active session.  For sessions created with 
`detached-compile' or
                                   :origin detached-session-origin
                                   :action detached-session-action
                                   :working-directory 
(detached--get-working-directory)
-                                  :attachable (detached-attachable-command-p 
command)
+                                  :degraded (detached-degraded-command-p 
command)
                                   :time `(:start ,(time-to-seconds 
(current-time)) :end 0.0 :duration 0.0 :offset 0.0)
                                   :status '(unknown . 0)
                                   :size 0
@@ -601,9 +591,8 @@ Optionally SUPPRESS-OUTPUT."
          (or detached--current-session
              (detached-create-session command))))
     (if-let ((run-in-background
-              (and (or suppress-output
-                       (eq detached-session-mode 'create)
-                       (not (detached--session-attachable 
detached--current-session)))))
+              (or suppress-output
+                  (eq detached-session-mode 'create)))
              (detached-session-mode 'create))
         (progn (setq detached-enabled nil)
                (if detached-local-session
@@ -613,11 +602,12 @@ Optionally SUPPRESS-OUTPUT."
                         `("detached" nil ,(detached-dtach-command 
detached--current-session t)))))
       (cl-letf* ((detached-session-mode 'create-and-attach)
                  ((symbol-function #'set-process-sentinel) #'ignore)
-                 (buffer (get-buffer-create detached--shell-command-buffer)))
+                 (buffer (get-buffer-create detached--shell-command-buffer))
+                 (command (detached--shell-command detached--current-session 
t)))
         (when (get-buffer-process buffer)
           (setq buffer (generate-new-buffer (buffer-name buffer))))
         (setq detached-enabled nil)
-        (funcall #'async-shell-command (detached-dtach-command 
detached--current-session t) buffer)
+        (funcall #'async-shell-command command buffer)
         (with-current-buffer buffer (setq detached--buffer-session 
detached--current-session))))))
 
 (defun detached-session-candidates (sessions)
@@ -770,16 +760,14 @@ This function uses the `notifications' library."
   (let* ((detached--current-session session)
          (detached-session-mode 'attach)
          (inhibit-message t))
-    (if (not (detached--session-attachable session))
-        (detached-view-session session)
-      (cl-letf* (((symbol-function #'set-process-sentinel) #'ignore)
-                 (buffer (get-buffer-create detached--shell-command-buffer))
-                 (default-directory (detached--session-working-directory 
session))
-                 (dtach-command (detached-dtach-command session t)))
-        (when (get-buffer-process buffer)
-          (setq buffer (generate-new-buffer (buffer-name buffer))))
-        (funcall #'async-shell-command dtach-command buffer)
-        (with-current-buffer buffer (setq detached--buffer-session 
detached--current-session))))))
+    (cl-letf* (((symbol-function #'set-process-sentinel) #'ignore)
+               (buffer (get-buffer-create detached--shell-command-buffer))
+               (default-directory (detached--session-working-directory 
session))
+               (command (detached--shell-command session t)))
+      (when (get-buffer-process buffer)
+        (setq buffer (generate-new-buffer (buffer-name buffer))))
+      (funcall #'async-shell-command command buffer)
+      (with-current-buffer buffer (setq detached--buffer-session 
detached--current-session)))))
 
 (defun detached-session-exit-code (session)
   "Return exit code for SESSION."
@@ -795,6 +783,55 @@ This function uses the `notifications' library."
 
 ;;;;; Other
 
+(cl-defgeneric detached--shell-command (entity &optional concat)
+  "Return shell command for ENTITY optionally CONCAT.")
+
+(cl-defmethod detached--shell-command ((command string) &optional concat)
+  "Return shell command for COMMAND.
+
+Optionally CONCAT the command return command into a string."
+  (detached--shell-command (detached-create-session command) concat))
+
+(cl-defmethod detached--shell-command ((session detached-session) &optional 
concat)
+  "Return shell command for SESSION.
+
+Optionally CONCAT the command return command into a string."
+  (if (detached--session-degraded session)
+      (detached-tail-command session concat)
+    (detached-dtach-command session concat)))
+
+(cl-defgeneric detached-tail-command (entity &optional concat)
+  "Return tail command for ENTITY optionally CONCAT.")
+
+(cl-defmethod detached-tail-command ((command string) &optional concat)
+  "Return tail command for COMMAND.
+
+Optionally CONCAT the command return command into a string."
+  (detached-tail-command (detached-create-session command) concat))
+
+(cl-defmethod detached-tail-command ((session detached-session) &optional 
concat)
+  "Return tail command for SESSION.
+
+Optionally CONCAT the command return command into a string."
+  (detached-connection-local-variables
+   (let* ((log (detached--session-file session 'log t))
+          (tail-command `(,detached-tail-program "--follow=name" "--retry"
+                                                 ,(concat "--lines=" 
detached-session-context-lines)
+                                                 ,log)))
+     (cond ((eq 'create detached-session-mode)
+            (detached-dtach-command session))
+           ((eq 'create-and-attach detached-session-mode)
+            (let ((detached-session-mode 'create)
+                  (detached--current-session session))
+              (detached-start-session (detached--session-command session))
+              (if concat
+                  (mapconcat #'identity tail-command " ")
+                tail-command)))
+           ((eq 'attach detached-session-mode)
+            (if concat
+                (mapconcat #'identity tail-command " ")
+              tail-command))))))
+
 (cl-defgeneric detached-dtach-command (entity &optional concat)
   "Return dtach command for ENTITY optionally CONCAT.")
 
@@ -809,26 +846,24 @@ Optionally CONCAT the command return command into a 
string."
 
 Optionally CONCAT the command return command into a string."
   (detached-connection-local-variables
-   (let* ((detached-session-mode (cond ((eq detached-session-mode 'attach) 
'attach)
-                                     ((not (detached--session-attachable 
session)) 'create)
-                                     (t detached-session-mode)))
-          (socket (detached--session-file session 'socket t))
+   (let* ((socket (detached--session-file session 'socket t))
           (log (detached--session-file session 'log t))
           (dtach-arg (detached--dtach-arg)))
      (setq detached--buffer-session session)
      (if (eq detached-session-mode 'attach)
          (if concat
              (mapconcat #'identity
-                        `(,(when detached-show-output-on-attach
-                             (concat detached-show-output-command " " log ";"))
+                        `(,(when detached-show-session-context
+                             (format  "%s --lines=%s %s;" 
detached-tail-program detached-session-context-lines log))
                           ,detached-dtach-program
                           ,dtach-arg
                           ,socket
                           "-r none")
                         " ")
            (append
-            (when detached-show-output-on-attach
-              `(,detached-show-output-command  ,(concat log ";")))
+            (when detached-show-session-context
+              `(,detached-tail-program ,(format "--lines=%s" 
detached-session-context-lines)
+                                       ,(concat log ";")))
             `(,detached-dtach-program ,dtach-arg ,socket "-r" "none")))
        (if concat
            (mapconcat #'identity
@@ -843,15 +878,14 @@ Optionally CONCAT the command return command into a 
string."
                       ,detached-shell-program "-c"
                       ,(detached--detached-command session)))))))
 
-(defun detached-attachable-command-p (command)
-  "Return t if COMMAND is attachable."
-  (if (thread-last detached-nonattachable-commands
-                   (seq-filter (lambda (regexp)
-                                 (string-match-p regexp command)))
-                   (length)
-                   (= 0))
-      t
-    nil))
+(defun detached-degraded-command-p (command)
+  "Return t if COMMAND is degraded."
+  (>
+   (thread-last detached-degraded-commands
+                (seq-filter (lambda (regexp)
+                              (string-match-p regexp command)))
+                (length))
+   0))
 
 (defun detached-metadata ()
   "Return a property list with metadata."
@@ -1180,7 +1214,7 @@ Optionally make the path LOCAL to host."
 (defun detached--detached-command (session)
   "Return the detached command for SESSION.
 
-If SESSION is non-attachable fallback to a command that doesn't rely on tee."
+If SESSION is degraded fallback to a command that doesn't rely on tee."
   (let* ((log (detached--session-file session 'log t))
          (begin-shell-group (if (string= "fish" (file-name-nondirectory 
detached-shell-program))
                                 "begin;"
@@ -1189,9 +1223,9 @@ If SESSION is non-attachable fallback to a command that 
doesn't rely on tee."
                               "end"
                             "}"))
          (redirect
-          (if (detached--session-attachable session)
-              (format "2>&1 | tee %s" log)
-            (format "&> %s" log)))
+          (if (detached--session-degraded session)
+              (format "&> %s" log)
+            (format "2>&1 | tee %s" log)))
          (shell (format "%s -c" detached-shell-program))
          (command
           (shell-quote-argument
@@ -1425,7 +1459,6 @@ If event is cased by an update to the `detached' 
database, re-initialize
 (defvar detached-log-mode-map
   (let ((map (make-sparse-keymap)))
     (define-key map (kbd detached-detach-key) #'detached-detach-session)
-    (define-key map (kbd "C-c C-l") #'detached-refresh-session-log)
     map)
   "Keymap for `detached-log-mode'.")
 
diff --git a/test/detached-test.el b/test/detached-test.el
index fb6c2ce012..788745434a 100644
--- a/test/detached-test.el
+++ b/test/detached-test.el
@@ -69,8 +69,9 @@
    (cl-letf* ((detached-dtach-program "dtach")
               (detached-shell-program "bash")
               (session (detached-create-session "ls -la"))
-              (detached-show-output-on-attach t)
-              (detached-show-output-command "/bin/cat")
+              (detached-show-session-context t)
+              (detached-session-context-lines 20)
+              (detached-tail-program "tail")
               ((symbol-function #'detached-create-session)
                (lambda (_)
                  session))
@@ -91,12 +92,14 @@
        (should (equal expected (detached-dtach-command session)))
        (should (equal expected-concat (detached-dtach-command session t))))
      (let* ((detached-session-mode 'attach)
-            (expected `(,detached-show-output-command
-                        ,(format "%s;" (detached--session-file session 'log t))
+            (log (detached--session-file session 'log t))
+            (expected `(,detached-tail-program
+                        ,(format "--lines=%s" detached-session-context-lines)
+                        ,(format "%s;" log)
                         ,detached-dtach-program "-a" ,(detached--session-file 
session 'socket t) "-r" "none"))
             (expected-concat (format "%s %s; %s -a %s -r none"
-                                     detached-show-output-command
-                                     (detached--session-file session 'log t)
+                                     (format "%s --lines=%s" 
detached-tail-program detached-session-context-lines)
+                                     log
                                      detached-dtach-program
                                      (detached--session-file session 'socket 
t))))
        (should (equal expected (detached-dtach-command session)))
@@ -207,29 +210,29 @@
 (ert-deftest detached-test-detached-command ()
   (let ((detached-shell-program "bash")
         (detached-terminal-data-command "script --quiet --flush --return 
--command \"%s\" /dev/null")
-        (attachable-terminal-data-session
+        (terminal-data-session
          (detached--session-create :directory "/tmp/detached/"
                                    :working-directory "/home/user/"
                                    :command "ls -la"
-                                   :attachable t
+                                   :degraded nil
                                    :env 'terminal-data
                                    :id 'foo123))
-        (nonattachable-plain-text-session
+        (degraded-plain-text-session
          (detached--session-create :directory "/tmp/detached/"
                                    :working-directory "/home/user/"
                                    :command "ls -la"
-                                   :attachable nil
+                                   :degraded t
                                    :env 'plain-text
                                    :id 'foo123)))
     (should (string= "{ bash -c if\\ TERM\\=eterm-color\\ script\\ --quiet\\ 
--flush\\ --return\\ --command\\ \\\"ls\\ -la\\\"\\ /dev/null\\;\\ then\\ 
true\\;\\ else\\ echo\\ \\\"\\[detached-exit-code\\:\\ \\$\\?\\]\\\"\\;\\ fi; } 
2>&1 | tee /tmp/detached/foo123.log"
-                     (detached--detached-command 
attachable-terminal-data-session)))
+                     (detached--detached-command terminal-data-session)))
     (should (string= "{ bash -c if\\ ls\\ -la\\;\\ then\\ true\\;\\ else\\ 
echo\\ \\\"\\[detached-exit-code\\:\\ \\$\\?\\]\\\"\\;\\ fi; } &> 
/tmp/detached/foo123.log"
-                     (detached--detached-command 
nonattachable-plain-text-session)))))
+                     (detached--detached-command 
degraded-plain-text-session)))))
 
-(ert-deftest detached-test-attachable-command-p ()
-  (let ((detached-nonattachable-commands '("ls")))
-    (should (detached-attachable-command-p "cd"))
-    (should (not (detached-attachable-command-p "ls -la")))))
+(ert-deftest detached-test-degraded-command-p ()
+  (let ((detached-degraded-commands '("ls")))
+    (should (not (detached-degraded-command-p "cd")))
+    (should (detached-degraded-command-p "ls -la"))))
 
 ;;;;; String representations
 



reply via email to

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