[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/detached 91d57497aa: Utilize new public session functio
From: |
ELPA Syncer |
Subject: |
[elpa] externals/detached 91d57497aa: Utilize new public session functions |
Date: |
Thu, 10 Nov 2022 10:57:31 -0500 (EST) |
branch: externals/detached
commit 91d57497aa2c138ed191c165b68d04e0c56d2c8e
Author: Niklas Eklund <niklas.eklund@posteo.net>
Commit: Niklas Eklund <niklas.eklund@posteo.net>
Utilize new public session functions
---
detached-eshell.el | 2 +-
detached-extra.el | 4 ++--
detached-list.el | 7 +++----
detached-shell.el | 2 +-
detached-vterm.el | 2 +-
detached.el | 41 ++++++++++++++++++++++-------------------
doc/detached.info | 2 +-
test/detached-test.el | 2 +-
8 files changed, 32 insertions(+), 30 deletions(-)
diff --git a/detached-eshell.el b/detached-eshell.el
index 75209de39d..d870ac09dc 100644
--- a/detached-eshell.el
+++ b/detached-eshell.el
@@ -107,7 +107,7 @@ If prefix-argument directly DETACH from the session."
(sessions
(thread-last (detached-get-sessions)
(seq-filter (lambda (it)
- (string= (car (detached--session-host
it)) host-name)))
+ (string= (detached-session-host-name it)
host-name)))
(seq-filter (lambda (it) (eq 'active
(detached--determine-session-state it)))))))
(detached-completing-read sessions)))
diff --git a/detached-extra.el b/detached-extra.el
index b678ead9da..3410e33bad 100644
--- a/detached-extra.el
+++ b/detached-extra.el
@@ -58,8 +58,8 @@ Optionally USE-COMINT-MODE"
;;;###autoload
(defun detached-extra-alert-notification (session)
"Send an `alert' notification when SESSION becomes inactive."
- (let ((status (car (detached--session-status session)))
- (host (car (detached--session-host session))))
+ (let ((status (detached-session-status session))
+ (host (detached-session-host-name session)))
(alert (detached--session-command session)
:title (pcase status
('success (format "Detached finished [%s]" host))
diff --git a/detached-list.el b/detached-list.el
index 0d773141a2..3eee4f9a2b 100644
--- a/detached-list.el
+++ b/detached-list.el
@@ -348,8 +348,7 @@ Optionally TOGGLE-SUPPRESS-OUTPUT."
(list
(when-let* ((hostnames
(thread-last (detached-list--get-narrowed-sessions)
- (seq-map #'detached--session-host)
- (seq-map #'car)
+ (seq-map #'detached-session-host-name)
(seq-uniq))))
(completing-read
"Select host: "
@@ -361,7 +360,7 @@ Optionally TOGGLE-SUPPRESS-OUTPUT."
,(lambda (sessions)
(seq-filter (lambda (it)
(string-match hostname
- (car (detached--session-host it))))
+ (detached-session-host-name it)))
sessions)))))))
(defun detached-list-narrow-output (regexp)
@@ -479,7 +478,7 @@ Optionally TOGGLE-SUPPRESS-OUTPUT."
,(lambda (sessions)
(let ((current-host (car (detached--host))))
(seq-filter (lambda (it)
- (string= (car (detached--session-host it))
current-host))
+ (string= (detached-session-host-name it)
current-host))
sessions)))))))
(defun detached-list-select-filter ()
diff --git a/detached-shell.el b/detached-shell.el
index 2d19e0a29d..35807ed722 100644
--- a/detached-shell.el
+++ b/detached-shell.el
@@ -94,7 +94,7 @@ cluttering the `comint-history' with dtach commands."
(sessions
(thread-last (detached-get-sessions)
(seq-filter (lambda (it)
- (string= (car (detached--session-host
it)) host-name)))
+ (string= (detached-session-host-name it)
host-name)))
(seq-filter (lambda (it) (eq 'active
(detached--determine-session-state it)))))))
(detached-completing-read sessions)))
diff --git a/detached-vterm.el b/detached-vterm.el
index 268e15df5c..818a6f1b7f 100644
--- a/detached-vterm.el
+++ b/detached-vterm.el
@@ -75,7 +75,7 @@ Optionally DETACH from it."
(sessions
(thread-last (detached-get-sessions)
(seq-filter (lambda (it)
- (string= (car (detached--session-host
it)) host-name)))
+ (string= (detached-session-host-name
it) host-name)))
(seq-filter (lambda (it) (eq 'active
(detached--determine-session-state it)))))))
(detached-completing-read sessions))))
(let ((detached-session-mode 'attach))
diff --git a/detached.el b/detached.el
index d6206259a3..6fe43baf64 100644
--- a/detached.el
+++ b/detached.el
@@ -668,7 +668,7 @@ active session. For sessions created with
`detached-compile' or
(sessions (if all-hosts
(detached-get-sessions)
(seq-filter (lambda (it)
- (string= (car (detached--session-host it))
host-name))
+ (string= (detached-session-host-name it)
host-name))
(detached-get-sessions)))))
(seq-do #'detached--db-remove-entry sessions)))
@@ -823,9 +823,9 @@ If session is not valid trigger an automatic cleanup on
SESSION's host."
(when (detached-session-p session)
(if (not (detached--session-missing-p session))
t
- (let ((host (detached--session-host session)))
- (message "Session does not exist. Initiate session cleanup on host %s"
(car host))
- (detached--cleanup-host-sessions host)
+ (let ((hostname (detached-session-host-name session)))
+ (message "Session does not exist. Initiate session cleanup on host %s"
hostname)
+ (detached--cleanup-host-sessions hostname)
nil))))
(defun detached-session-exit-code-status (session)
@@ -844,16 +844,16 @@ If session is not valid trigger an automatic cleanup on
SESSION's host."
(defun detached-state-transitionion-echo-message (session)
"Issue a notification when SESSION transitions from active to inactive.
This function uses the echo area."
- (let ((status (pcase (car (detached--session-status session))
+ (let ((status (pcase (car (detached-session-status session))
('success "Detached finished")
('failure "Detached failed"))))
- (message "%s [%s]: %s" status (car (detached--session-host session))
(detached--session-command session))))
+ (message "%s [%s]: %s" status (detached-session-host-name session)
(detached--session-command session))))
(defun detached-state-transition-notifications-message (session)
"Issue a notification when SESSION transitions from active to inactive.
This function uses the `notifications' library."
- (let ((status (car (detached--session-status session)))
- (host (car (detached--session-host session))))
+ (let ((status (detached-session-status session))
+ (host (detached-session-host-name session)))
(notifications-notify
:title (pcase status
('success (format "Detached finished [%s]" host))
@@ -865,7 +865,7 @@ This function uses the `notifications' library."
(defun detached-view-dwim (session)
"View SESSION in a do what I mean fashion."
- (let ((status (car (detached--session-status session))))
+ (let ((status (detached-session-status session)))
(cond ((eq 'success status)
(detached-view-session session))
((eq 'failure status)
@@ -973,6 +973,10 @@ This function uses the `notifications' library."
(detached--session-status session)))
exit-code))
+(defun detached-session-failed-p (session)
+ "Return t if SESSION failed."
+ (eq 'failure (detached-session-status session)))
+
(defun detached-session-remotehost-p (session)
"Return t if SESSION is running on a remote host."
(eq 'remotehost (detached-session-host-type session)))
@@ -1182,7 +1186,7 @@ Optionally CONCAT the command return command into a
string."
(string-join
`(,(format "Command: %s" (detached--session-command session))
,(format "Working directory: %s" (detached--working-dir-str session))
- ,(format "Host: %s" (car (detached--session-host session)))
+ ,(format "Host: %s" (detached-session-host-name session))
,(format "Id: %s" (symbol-name (detached--session-id session)))
,(format "Status: %s" (car (detached--session-status session)))
,(format "Annotation: %s" (if-let ((annotation
(detached--session-annotation session))) annotation ""))
@@ -1257,13 +1261,12 @@ Optionally make the path LOCAL to host."
remote-local-path
full-path)))
-(defun detached--cleanup-host-sessions (host)
- "Run cleanup on HOST sessions."
- (let ((host-name (car host)))
- (thread-last (detached--db-get-sessions)
- (seq-filter (lambda (it) (string= host-name (car
(detached--session-host it)))))
- (seq-filter #'detached--session-missing-p)
- (seq-do #'detached--db-remove-entry))))
+(defun detached--cleanup-host-sessions (hostname)
+ "Run cleanup on HOSTNAME sessions."
+ (thread-last (detached--db-get-sessions)
+ (seq-filter (lambda (it) (string= hostname
(detached-session-host-name it))))
+ (seq-filter #'detached--session-missing-p)
+ (seq-do #'detached--db-remove-entry)))
(defun detached--maybe-watch-session (session)
"Maybe watch SESSION."
@@ -1788,7 +1791,7 @@ start searching at NUMBER offset."
(defun detached--status-str (session)
"Return string if SESSION has failed."
- (pcase (car (detached--session-status session))
+ (pcase (detached-session-status session)
('failure "!")
('success "")
('unknown "")))
@@ -1812,7 +1815,7 @@ start searching at NUMBER offset."
(defun detached--host-str (session)
"Return host name of SESSION."
- (car (detached--session-host session)))
+ (detached-session-host-name session))
;;;; Minor modes
diff --git a/doc/detached.info b/doc/detached.info
index 8c833929d1..8dbcebd47d 100644
--- a/doc/detached.info
+++ b/doc/detached.info
@@ -1,4 +1,4 @@
-This is detached.info, produced by makeinfo version 6.7 from
+This is detached.info, produced by makeinfo version 7.0 from
detached.texi.
This manual describes the design of the ‘detached’ (version 0.9.2, last
diff --git a/test/detached-test.el b/test/detached-test.el
index 169da977ec..b936be9c0d 100644
--- a/test/detached-test.el
+++ b/test/detached-test.el
@@ -167,7 +167,7 @@
;; One inactive, one missing, one active
(detached-test--change-session-state session1 'deactivate)
(detached-test--change-session-state session2 'kill)
- (detached--cleanup-host-sessions host)
+ (detached--cleanup-host-sessions "localhost")
(detached--db-get-sessions)
(should (seq-set-equal-p
(detached--db-get-sessions)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/detached 91d57497aa: Utilize new public session functions,
ELPA Syncer <=