[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/detached 804cce6665: Implement detached session state f
From: |
ELPA Syncer |
Subject: |
[elpa] externals/detached 804cce6665: Implement detached session state function |
Date: |
Mon, 14 Nov 2022 13:57:36 -0500 (EST) |
branch: externals/detached
commit 804cce666593af9520349a3f335af0111d61f5c4
Author: Niklas Eklund <niklas.eklund@posteo.net>
Commit: Niklas Eklund <niklas.eklund@posteo.net>
Implement detached session state function
---
detached-eshell.el | 6 +++---
detached-shell.el | 4 ++--
detached-vterm.el | 2 +-
detached.el | 22 +++++++++++++++++-----
4 files changed, 23 insertions(+), 11 deletions(-)
diff --git a/detached-eshell.el b/detached-eshell.el
index 00c9c35c65..28a72f6ff4 100644
--- a/detached-eshell.el
+++ b/detached-eshell.el
@@ -74,7 +74,7 @@ If prefix-argument directly DETACH from the session."
(interactive
(list (detached-eshell--select-session)))
(when (detached-valid-session session)
- (if (eq 'active (detached--determine-session-state session))
+ (if (detached-session-active-p session)
(cl-letf* ((detached-session-mode 'attach)
(input
(detached--shell-command session t))
@@ -108,12 +108,12 @@ If prefix-argument directly DETACH from the session."
(thread-last (detached-get-sessions)
(seq-filter (lambda (it)
(string= (detached-session-host-name it)
host-name)))
- (seq-filter (lambda (it) (eq 'active
(detached--determine-session-state it)))))))
+ (seq-filter #'detached-session-active-p))))
(detached-completing-read sessions)))
(cl-defmethod detached--detach-session ((_mode (derived-mode eshell-mode)))
"Detach from session when MODE is `eshell-mode'."
- (when-let ((active-session (eq 'active (detached--determine-session-state
detached--buffer-session)))
+ (when-let ((active-session (detached-session-active-p
detached--buffer-session))
(dtach-process (detached-eshell--get-dtach-process)))
(setq detached--buffer-session nil)
(process-send-string dtach-process
diff --git a/detached-shell.el b/detached-shell.el
index 35807ed722..3c78e69550 100644
--- a/detached-shell.el
+++ b/detached-shell.el
@@ -75,7 +75,7 @@ cluttering the `comint-history' with dtach commands."
(interactive
(list (detached-shell--select-session)))
(when (detached-valid-session session)
- (if (eq 'active (detached--determine-session-state session))
+ (if (detached-session-active-p session)
(cl-letf ((detached--current-session session)
(comint-input-sender #'detached-shell--attach-input-sender)
((symbol-function 'comint-add-to-input-history) (lambda (_)
t)))
@@ -95,7 +95,7 @@ cluttering the `comint-history' with dtach commands."
(thread-last (detached-get-sessions)
(seq-filter (lambda (it)
(string= (detached-session-host-name it)
host-name)))
- (seq-filter (lambda (it) (eq 'active
(detached--determine-session-state it)))))))
+ (seq-filter #'detached-session-active-p))))
(detached-completing-read sessions)))
(defun detached-shell--attach-input-sender (proc _string)
diff --git a/detached-vterm.el b/detached-vterm.el
index 818a6f1b7f..af9db0d970 100644
--- a/detached-vterm.el
+++ b/detached-vterm.el
@@ -76,7 +76,7 @@ Optionally DETACH from it."
(thread-last (detached-get-sessions)
(seq-filter (lambda (it)
(string= (detached-session-host-name
it) host-name)))
- (seq-filter (lambda (it) (eq 'active
(detached--determine-session-state it)))))))
+ (seq-filter #'detached-session-active-p))))
(detached-completing-read sessions))))
(let ((detached-session-mode 'attach))
(setq detached--buffer-session session)
diff --git a/detached.el b/detached.el
index 636d53047c..33218c2420 100644
--- a/detached.el
+++ b/detached.el
@@ -560,7 +560,7 @@ The session is compiled by opening its output and enabling
(interactive
(list (detached-completing-read (detached-get-sessions))))
(when (detached-valid-session session)
- (if (eq 'active (detached--determine-session-state session))
+ (if (detached-session-active-p session)
(message "Kill session first before removing it.")
(detached--db-remove-entry session))))
@@ -930,6 +930,12 @@ This function uses the `notifications' library."
(buffer-string))
"\n" t))))
+(defun detached-session-state (session)
+ "Return SESSION's state."
+ (if (detached-session-validated-p session)
+ (detached--session-state session)
+ 'unknown))
+
(defun detached-session-status (session)
"Return status for SESSION."
(pcase-let ((`(,status . ,_exit-code)
@@ -1003,6 +1009,12 @@ This function uses the `notifications' library."
(plist-get (detached--session-action session) :status)
#'detached-session-exit-code-status))
+(defun detached-session-validated-p (session)
+ "Return t if SESSION has been validated."
+ (not
+ (alist-get (detached-session-id session)
+ detached--unvalidated-sessions)))
+
(defun detached-session-failed-p (session)
"Return t if SESSION failed."
(eq 'failure (detached-session-status session)))
@@ -1017,11 +1029,11 @@ This function uses the `notifications' library."
(defun detached-session-active-p (session)
"Return t if SESSION is active."
- (eq 'active (detached--session-state session)))
+ (eq 'active (detached-session-state session)))
(defun detached-session-inactive-p (session)
"Return t if SESSION is inactive."
- (eq 'inactive (detached--session-state session)))
+ (eq 'inactive (detached-session-state session)))
(defun detached-session-degraded-p (session)
"Return t if SESSION is degraded."
@@ -1366,7 +1378,7 @@ Optionally make the path LOCAL to host."
(defun detached--detach-from-comint-process ()
"Detach from the underlying `comint' process."
- (when-let ((active-session (eq 'active (detached--determine-session-state
detached--buffer-session)))
+ (when-let ((active-session (detached-session-active-p
detached--buffer-session))
(dtach-process (get-buffer-process (current-buffer))))
(setq detached--buffer-session nil)
(comint-simple-send dtach-process detached--dtach-detach-character)))
@@ -1841,7 +1853,7 @@ start searching at NUMBER offset."
(defun detached--state-str (session)
"Return string based on SESSION state."
- (pcase (detached--session-state session)
+ (pcase (detached-session-state session)
('active (if (detached--session-accessible-p session)
"*"
"?"))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/detached 804cce6665: Implement detached session state function,
ELPA Syncer <=