emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/detached be2a8f4d8c 2/3: Add event detection for log cr


From: ELPA Syncer
Subject: [elpa] externals/detached be2a8f4d8c 2/3: Add event detection for log creation
Date: Fri, 18 Nov 2022 04:57:36 -0500 (EST)

branch: externals/detached
commit be2a8f4d8c2077b6a16063c40845dee920715ed8
Author: Niklas Eklund <niklas.eklund@posteo.net>
Commit: Niklas Eklund <niklas.eklund@posteo.net>

    Add event detection for log creation
    
    This speeds up the validation of a session.
---
 detached.el | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/detached.el b/detached.el
index 1ad3673a30..3c948cd13e 100644
--- a/detached.el
+++ b/detached.el
@@ -1803,6 +1803,7 @@ log to deduce the end time."
 If event is caused by the deletion of a socket, locate the related
 session and trigger a state transition."
   (pcase-let* ((`(,_ ,action ,file) event))
+    ;; Session becomes inactive
     (when (and (eq action 'deleted)
                (string= "socket" (file-name-extension file)))
 
@@ -1832,7 +1833,23 @@ session and trigger a state transition."
           (file-notify-rm-watch
            (alist-get session-directory detached--watched-session-directories 
nil nil #'string=))
           (setq detached--watched-session-directories
-                (assoc-delete-all session-directory 
detached--watched-session-directories)))))))
+                (assoc-delete-all session-directory 
detached--watched-session-directories)))))
+
+    ;; Session becomes active
+    (when (and (eq action 'created)
+               (string= "log" (file-name-extension file)))
+      (when-let* ((id (intern (file-name-base file)))
+                  (session
+                   (or (alist-get id detached--unvalidated-sessions)
+                       (detached--db-get-session id)))
+                  (session-directory (detached-session-directory session))
+                  (is-primary
+                   (detached--primary-detached-emacs-p session)))
+        (setq detached--unvalidated-sessions
+              (assq-delete-all (detached-session-id session)
+                               detached--unvalidated-sessions))
+        (setf (detached--session-state session) 'active)
+        (detached--db-insert-entry session)))))
 
 (defun detached--initialize-session (session)
   "Initialize SESSION."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]