[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/detached 492223d576 2/6: Rename non-attachable to degra
From: |
ELPA Syncer |
Subject: |
[elpa] externals/detached 492223d576 2/6: Rename non-attachable to degraded session |
Date: |
Fri, 3 Jun 2022 03:57:32 -0400 (EDT) |
branch: externals/detached
commit 492223d576902665cbf967a185d33bde8a051089
Author: Niklas Eklund <niklas.eklund@posteo.net>
Commit: Niklas Eklund <niklas.eklund@posteo.net>
Rename non-attachable to degraded session
---
README.md | 10 +++++-----
detached.el | 46 +++++++++++++++++++++-------------------------
test/detached-test.el | 20 ++++++++++----------
3 files changed, 36 insertions(+), 40 deletions(-)
diff --git a/README.md b/README.md
index 2a2c67464c..4875a26f47 100644
--- a/README.md
+++ b/README.md
@@ -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 |
@@ -259,16 +259,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.el b/detached.el
index 2a427be677..4b93fef177 100644
--- a/detached.el
+++ b/detached.el
@@ -132,8 +132,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 +184,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 +271,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)
@@ -561,7 +561,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
@@ -776,9 +776,9 @@ Optionally CONCAT the command return command into a string."
"Return shell command for SESSION.
Optionally CONCAT the command return command into a string."
- (if (detached--session-attachable session)
- (detached-dtach-command session concat)
- (detached-tail-command session concat)))
+ (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.")
@@ -824,10 +824,7 @@ 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)
@@ -858,15 +855,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."
@@ -1195,7 +1191,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;"
@@ -1204,9 +1200,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
diff --git a/test/detached-test.el b/test/detached-test.el
index fb6c2ce012..2a6045024f 100644
--- a/test/detached-test.el
+++ b/test/detached-test.el
@@ -207,29 +207,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
- [elpa] externals/detached updated (6e7a236fa5 -> 670433a5ab), ELPA Syncer, 2022/06/03
- [elpa] externals/detached c5aefccb97 4/6: Use context instead of show output, ELPA Syncer, 2022/06/03
- [elpa] externals/detached 492223d576 2/6: Rename non-attachable to degraded session,
ELPA Syncer <=
- [elpa] externals/detached 201de1eb65 3/6: Update CHANGELOG, ELPA Syncer, 2022/06/03
- [elpa] externals/detached 9a00a50971 1/6: Introduce usage of tail for degraded sessions, ELPA Syncer, 2022/06/03
- [elpa] externals/detached 28e3eb5b6a 5/6: Update tests, ELPA Syncer, 2022/06/03
- [elpa] externals/detached 670433a5ab 6/6: Merge branch 'new-tailing', ELPA Syncer, 2022/06/03