[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/detached d6d3b755c2 1/2: Update behavior of detached-te
From: |
ELPA Syncer |
Subject: |
[elpa] externals/detached d6d3b755c2 1/2: Update behavior of detached-terminal-data-command |
Date: |
Thu, 25 Aug 2022 14:57:29 -0400 (EDT) |
branch: externals/detached
commit d6d3b755c2745553764454612c3a66a70e1dadc7
Author: Niklas Eklund <niklas.eklund@posteo.net>
Commit: Niklas Eklund <niklas.eklund@posteo.net>
Update behavior of detached-terminal-data-command
Don't deduce the terminal data command automatically based on host
operating system. This interfere with remote connections when the os
differs from localhost. This solution is better since it works for
both remote as well as local sessions.
---
CHANGELOG.org | 2 ++
README.md | 5 +++--
detached.el | 28 +++++++++++++++++++---------
3 files changed, 24 insertions(+), 11 deletions(-)
diff --git a/CHANGELOG.org b/CHANGELOG.org
index 88e01d074a..41ba1b85f9 100644
--- a/CHANGELOG.org
+++ b/CHANGELOG.org
@@ -3,6 +3,8 @@
#+language: en
* Development
+- Update expectations on =detached-terminal-data-command= command, user should
now set it manually. This approach works better since it doesn't cause any
conflict when remote host and local host operating system differs.
+- Improved handling of remote sessions. The package will not eagerly try to
watch sessions, it waits until user requests or that it finds an open
connection to the remote host.
- Detached tries to guess the =detached-terimal-data-command= based on
operating system, if that's not possible the user needs to set it manually.
Currently detection of =gnu/linux= and =darwin= is supported.
- 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.
diff --git a/README.md b/README.md
index f4e958d0d1..3316894210 100644
--- a/README.md
+++ b/README.md
@@ -58,7 +58,8 @@ A minimal `use-package` configuration.
([remap recompile] . detached-compile-recompile)
;; Replace built in completion of sessions with `consult'
([remap detached-open-session] . detached-consult-session))
- :custom ((detached-show-output-on-attach t)))
+ :custom ((detached-show-output-on-attach t)
+ (detached-terminal-data-command system-type)))
```
The users are required to call `detached-init`. This function orchestrates the
integration with all other internal and external packages that `detached.el`
supports. These are:
@@ -272,7 +273,7 @@ The package needs to use a trick to get programs programs
such as `git` or `grep
The drawback is that there can be commands which generates escape sequences
that the package supports and will therefore mess up the output for some
commands. If you detect such an incompatible command you can add a regexp that
matches that command to the list `detached-plain-text-commands`. By doing so
`detached.el` will be instructed to run those commands in plain-text mode.
-The tool `script` can have different options depending on version and
operating system. The package tries to automatically determine the command to
use, based on your operating system. But if it fails to do that there is the
option to set the command manually with `detached-terminal-data-command`.
+The tool `script` can have different options depending on version and
operating system. The package requires the user to set the
`detached-terminal-data-command` in the package configuration and with
`connection-local-set-profiles` for remote sessions. It can either be set to a
symbol or to a string.
## Chained commands
diff --git a/detached.el b/detached.el
index 0f95ff3136..cb3bfe10cd 100644
--- a/detached.el
+++ b/detached.el
@@ -94,8 +94,14 @@
(defcustom detached-terminal-data-command nil
"The command for the tool script, which is used to record terminal data.
-If the variable is not set, the command is the deduced by `detached'
-based on the `system-type'."
+The variable needs to be set in order for terminal data to be
+recorded, instead of plain-text data.
+
+Acceptable values are
+- `gnu/linux'
+- `darwin'
+- a custom string
+"
:type 'string
:group 'detached)
@@ -1234,19 +1240,23 @@ If SESSION is degraded fallback to a command that
doesn't rely on tee."
(command
(shell-quote-argument
(format "if %s; then true; else echo \"[detached-exit-code: $?]\";
fi"
- (if (eq 'terminal-data (detached--session-env session))
+ (if (and (eq 'terminal-data (detached--session-env session))
+ detached-terminal-data-command)
(format "TERM=eterm-color %s"
(format
- (or
- detached-terminal-data-command
- (pcase system-type
- ('gnu/linux "script --quiet --flush
--return --command \"%s\" /dev/null")
- ('darwin "script -F -q /dev/null %s")
- (_ (error "Unable to determine script
command, set `detached-terminal-data-command'"))))
+ (detached--get-terminal-data-command)
(detached--session-command session)))
(detached--session-command session))))))
(format "%s %s %s; %s %s" begin-shell-group shell command end-shell-group
redirect)))
+(defun detached--get-terminal-data-command ()
+ "Return terminal data command."
+ (pcase detached-terminal-data-command
+ ('gnu/linux "script --quiet --flush --return --command \"%s\" /dev/null")
+ ('darwin "script -F -q /dev/null %s")
+ ((and (pred stringp) command) command)
+ (_ (error "Unable to determine script command, set
`detached-terminal-data-command' properly"))))
+
(defun detached--env (command)
"Return the environment to run in COMMAND in."
(if (seq-find (lambda (regexp)