[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/detached 95db0a3613: Update duration statistics
From: |
ELPA Syncer |
Subject: |
[elpa] externals/detached 95db0a3613: Update duration statistics |
Date: |
Wed, 23 Nov 2022 11:57:37 -0500 (EST) |
branch: externals/detached
commit 95db0a361340a7d68049c35c0f58eabcd5887b0f
Author: Niklas Eklund <niklas.eklund@posteo.net>
Commit: Niklas Eklund <niklas.eklund@posteo.net>
Update duration statistics
Calculate statistics on the fly if requested.
---
detached-list.el | 14 +------------
detached.el | 63 +++++++++++++++++++++++---------------------------------
2 files changed, 27 insertions(+), 50 deletions(-)
diff --git a/detached-list.el b/detached-list.el
index ac930b833b..66ceafd0b0 100644
--- a/detached-list.el
+++ b/detached-list.el
@@ -117,18 +117,6 @@ detached list implements."
;;;; Commands
-(defun detached-list-describe-duration (session)
- "Describe the SESSION's duration statistics."
- (interactive
- (list (detached-session-in-context)))
- (let ((mean (detached-session-mean-duration session))
- (std (detached-session-std-duration session)))
- (message "%s: %s %s: %s"
- (propertize "μ" 'face 'detached-mark-face)
- (if mean (detached--duration-str2 mean) "-")
- (propertize "σ" 'face 'detached-mark-face)
- (if std (detached--duration-str2 std) "-"))))
-
(defun detached-list-initialize-session-directory (&optional all)
"Initialize a session-directory.
@@ -920,7 +908,7 @@ If prefix-argument is provided unmark instead of mark."
(define-key map (kbd "!") #'detached-shell-command)
;; Describe
(define-key map (kbd ". s") #'detached-describe-session)
- (define-key map (kbd ". d") #'detached-list-describe-duration)
+ (define-key map (kbd ". d") #'detached-describe-duration)
(define-key map (kbd "<backspace>")
#'detached-list-remove-narrow-criterion)
(define-key map (kbd "<return>") #'detached-list-open-session)
map)
diff --git a/detached.el b/detached.el
index a69d5e40f4..1ac0e3dd21 100644
--- a/detached.el
+++ b/detached.el
@@ -231,9 +231,11 @@ If set to a non nil value the latest entry to
(let ((map (make-sparse-keymap)))
(define-key map "a" #'detached-edit-session-annotation)
(define-key map "d" #'detached-detach-session)
+ (define-key map "D" #'detached-describe-duration)
(define-key map "e" #'detached-edit-and-run-session)
(define-key map "k" #'detached-kill-session)
(define-key map "r" #'detached-rerun-session)
+ (define-key map "S" #'detached-describe-session)
(define-key map "w" #'detached-copy-session-command)
(define-key map "W" #'detached-copy-session-output)
map))
@@ -333,9 +335,6 @@ This version is encoded as [package-version].[revision].")
;;;;; Private
-(defvar detached--session-durations nil
- "An hash-table with duration sessions.")
-
(defvar detached--sessions-initialized nil
"Sessions are initialized.")
@@ -572,6 +571,20 @@ Optionally TOGGLE-SESSION-MODE."
(detached--session-header session)))
(goto-char (point-min)))))
+;;;###autoload
+(defun detached-describe-duration (session)
+ "Describe the SESSION's duration statistics."
+ (interactive
+ (list (detached-session-in-context)))
+ (let* ((statistics (detached-session-duration-statistics session)))
+ (message "%s: %s %s: %s"
+ (propertize "μ" 'face 'detached-mark-face)
+ (if-let ((mean (plist-get statistics :mean)))
+ (detached--duration-str2 (plist-get statistics :mean)) "-")
+ (propertize "σ" 'face 'detached-mark-face)
+ (if-let ((std (plist-get statistics :std)))
+ (detached--duration-str2 std) "-"))))
+
;;;###autoload
(defun detached-attach-session (session)
"Attach to SESSION."
@@ -830,9 +843,6 @@ active session. For sessions created with
`detached-compile' or
sessions)
ht))
- ;; Hash sessions and their duration times
- (detached--initialize-sessions-duration-hashtable)
-
;; Initialize accessible sessions
(let ((detached--current-emacsen (detached--active-detached-emacsen)))
(detached--update-detached-emacsen)
@@ -1120,20 +1130,6 @@ cluttering the `comint-history' with dtach commands."
(detached--session-time session) :duration)
(- (time-to-seconds) (detached-session-start-time session))))
-(defun detached-session-mean-duration (session)
- "Return SESSION's mean duration."
- (when-let* ((duration-statistics
- (gethash (detached-session-identifier session)
- detached--session-durations nil)))
- (plist-get duration-statistics :mean)))
-
-(defun detached-session-std-duration (session)
- "Return SESSION's std duration."
- (when-let* ((duration-statistics
- (gethash (detached-session-identifier session)
- detached--session-durations nil)))
- (plist-get duration-statistics :std)))
-
(defun detached-session-host-type (session)
"Return the type of SESSION's host."
(pcase-let ((`(,_name . ,type)
@@ -1212,6 +1208,16 @@ cluttering the `comint-history' with dtach commands."
(when (detached-session-p session)
session)))
+(defun detached-session-duration-statistics (session)
+ "Return duration statistics for SESSION."
+ (when-let* ((identifier (detached-session-identifier session))
+ (sessions (thread-last (detached-get-sessions)
+ (seq-filter (lambda (it)
+ (string= identifier
(detached-session-identifier it))))
+ (seq-remove #'detached-session-failed-p)
+ (seq-filter
#'detached-session-inactive-p))))
+ (detached--get-duration-statistics sessions)))
+
(defun detached-session-validated-p (session)
"Return t if SESSION has been validated."
(not
@@ -1506,23 +1512,6 @@ Optionally make the path LOCAL to host."
(kill-buffer)
(kill-buffer-and-window))))
-(defun detached--initialize-sessions-duration-hashtable ()
- "Initialize the `detached--session-durations'."
- (let* ((sessions (detached-get-sessions))
- (grouped-sessions
- (thread-last sessions
- (seq-filter #'detached-session-inactive-p)
- (seq-remove #'detached-session-failed-p)
- (seq-group-by #'detached-session-identifier))))
- (setq detached--session-durations
- (make-hash-table :test #'equal :size (seq-length grouped-sessions)))
- (thread-last grouped-sessions
- (seq-do (lambda (it)
- (pcase-let* ((`(,identifier . ,sessions) it))
- (puthash identifier
- (detached--get-duration-statistics
sessions)
- detached--session-durations)))))))
-
(defun detached--get-duration-statistics (sessions)
"Return a plist of duration statistics for SESSIONS."
(let* ((durations (seq-map #'detached-session-duration sessions))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/detached 95db0a3613: Update duration statistics,
ELPA Syncer <=