[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dtache 8381939f1d 1/2: Optionally show old session outp
From: |
ELPA Syncer |
Subject: |
[elpa] externals/dtache 8381939f1d 1/2: Optionally show old session output when attaching |
Date: |
Thu, 12 May 2022 11:57:30 -0400 (EDT) |
branch: externals/dtache
commit 8381939f1d82c333b9a931d214f031846c383450
Author: Rose Osterheld <dev@roeli.org>
Commit: Niklas Eklund <niklas.eklund@posteo.net>
Optionally show old session output when attaching
If `dtache-show-output-on-attach` is set to `t`, show the previous
output of the session when attaching to it instead of only showing
future output.
Also add the `dtache-cat-command` variable which dictates the command
to use to output a sessions previous output.
---
dtache.el | 22 +++++++++++++++++++---
test/dtache-test.el | 10 ++++++++--
2 files changed, 27 insertions(+), 5 deletions(-)
diff --git a/dtache.el b/dtache.el
index 2c1294fe2d..d77716399e 100644
--- a/dtache.el
+++ b/dtache.el
@@ -77,6 +77,16 @@
:type 'string
:group 'dtache)
+(defcustom dtache-show-output-on-attach nil
+ "If set to t show the session output when attaching to it."
+ :type 'bool
+ :group 'dtache)
+
+(defcustom dtache-show-output-command (executable-find "cat")
+ "The command to be run to show a sessions output."
+ :type 'string
+ :group 'dtache)
+
(defcustom dtache-env nil
"The name of, or path to, the `dtache' environment script."
:type 'string
@@ -357,7 +367,7 @@ The session is compiled by opening its output and enabling
current-prefix-arg))
(when (dtache-valid-session session)
(let* ((default-directory
- (dtache--session-working-directory session))
+ (dtache--session-working-directory session))
(dtache-session-action (dtache--session-action session))
(command (dtache--session-command session)))
(if suppress-output
@@ -783,17 +793,23 @@ Optionally CONCAT the command return command into a
string."
((not (dtache--session-attachable
session)) 'create)
(t dtache-session-mode)))
(socket (dtache--session-file session 'socket t))
+ (log (dtache--session-file session 'log t))
(dtach-arg (dtache--dtach-arg)))
(setq dtache--buffer-session session)
(if (eq dtache-session-mode 'attach)
(if concat
(mapconcat #'identity
- `(,dtache-dtach-program
+ `(,(when dtache-show-output-on-attach
+ (concat dtache-show-output-command " " log ";"))
+ ,dtache-dtach-program
,dtach-arg
,socket
"-r none")
" ")
- `(,dtach-arg ,socket "-r" "none"))
+ (append
+ (when dtache-show-output-on-attach
+ `(,dtache-show-output-command ,(concat log ";")))
+ `(,dtach-arg ,socket "-r" "none")))
(if concat
(mapconcat #'identity
`(,dtache-dtach-program
diff --git a/test/dtache-test.el b/test/dtache-test.el
index 59887bd334..9ea9011353 100644
--- a/test/dtache-test.el
+++ b/test/dtache-test.el
@@ -71,6 +71,8 @@
(dtache-env "dtache-env")
(dtache-shell-program "bash")
(session (dtache-create-session "ls -la"))
+ (dtache-show-output-on-attach t)
+ (dtache-show-output-command "/bin/cat")
((symbol-function #'dtache-create-session)
(lambda (_)
session)))
@@ -90,8 +92,12 @@
(should (equal expected (dtache-dtach-command session)))
(should (equal expected-concat (dtache-dtach-command session t))))
(let* ((dtache-session-mode 'attach)
- (expected `("-a" ,(dtache--session-file session 'socket t) "-r"
"none"))
- (expected-concat (format "%s -a %s -r none"
+ (expected `("-a" ,(dtache--session-file session 'socket t) "-r"
"none"
+ ,dtache-show-output-command
+ ,(format "%s;" (dtache--session-file session 'log t))))
+ (expected-concat (format "%s %s; %s -a %s -r none"
+ dtache-show-output-command
+ (dtache--session-file session 'log t)
dtache-dtach-program
(dtache--session-file session 'socket
t))))
(should (equal expected (dtache-dtach-command session)))