[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dtache 5d9c8aa54f 053/158: Add macOS support
From: |
ELPA Syncer |
Subject: |
[elpa] externals/dtache 5d9c8aa54f 053/158: Add macOS support |
Date: |
Wed, 19 Jan 2022 18:57:50 -0500 (EST) |
branch: externals/dtache
commit 5d9c8aa54f1e9129745037107c18b03f484183e5
Author: Niklas Eklund <niklas.eklund@posteo.net>
Commit: Niklas Eklund <niklas.eklund@posteo.net>
Add macOS support
Previously it was not possible to create a monitor for a session on a
macOS host. The users previously had to resort to a hack mentioned in
the README. This patch adds special handling for monitors on macOS and
the users don't need to configure that themselves anymore.
---
CHANELOG.org | 2 ++
README.org | 16 ----------------
dtache.el | 45 +++++++++++++++++++++++++++------------------
3 files changed, 29 insertions(+), 34 deletions(-)
diff --git a/CHANELOG.org b/CHANELOG.org
index e3a1370758..128aadf69f 100644
--- a/CHANELOG.org
+++ b/CHANELOG.org
@@ -4,6 +4,8 @@
* Development
+- macOS (monitor) support is added to the package.
+
* Version 0.2 (2021-12-23)
- With the recent improvements to =dtache-open-session=, the package is ready
to harmonize the user interface. This means deprecating =dtache-list-sessions=.
diff --git a/README.org b/README.org
index 658db79ad6..edc4bd5872 100644
--- a/README.org
+++ b/README.org
@@ -202,22 +202,6 @@ Some programs doesn't play well with =tee=, which =dtache=
relies upon to redire
Here a command beginning with =ls= would from now on be using redirect only.
* Tips & Tricks
-** macOS support
-
-=Dtache= depends on =filenotify= to trigger events when a =dtach socket= is
deleted, which defines the transition from active to inactive for a dtache
session. Currently this implementation causes issues for macOS users, it should
work, but until the root cause has been identified this provides a workaround
solution.
-
-#+begin_src elisp :lexical t :results none
- (defun my/dtache--add-end-of-session-notification-advice (session)
- "Trigger an event when SESSION transition to inactive."
- (let ((dtache-timer-configuration
- '(:seconds 0.5 :repeat 0.5 :function run-with-idle-timer)))
- (dtache--session-timer session)))
-
- (advice-add 'dtache--add-end-of-session-notification :override
#'my/dtache--add-end-of-session-notification-advice)
-#+end_src
-
-We replace the notification function with one based on a timer instead. This
timer will periodically check if a session has gotten deactivated.
-
** System notifications
By default =dtache= uses the echo area to notify the user when a session has
finished. An alternative is to utilize the
[[https://github.com/jwiegley/alert][alert]] package to get a system
notification instead.
diff --git a/dtache.el b/dtache.el
index c5bb0635da..76ab90404a 100644
--- a/dtache.el
+++ b/dtache.el
@@ -468,10 +468,10 @@ Sessions running on current host or localhost are
updated."
(dtache-update-session session))))
(dtache--db-get-sessions))
- ;; Setup notifications
+ ;; Start monitors
(thread-last (dtache--db-get-sessions)
(seq-filter #'dtache--session-active)
- (seq-do #'dtache-setup-notification))))
+ (seq-do #'dtache-start-session-monitor))))
(defun dtache-cleanup-host-sessions (host)
"Run cleanuup on HOST sessions."
@@ -548,11 +548,13 @@ Sessions running on current host or localhost are
updated."
(cand (completing-read "Select session: " collection nil t)))
(cdr (assoc cand candidates))))
-(defun dtache-setup-notification (session)
- "Setup notification for SESSION."
+(defun dtache-start-session-monitor (session)
+ "Start to monitor SESSION activity."
(if (file-remote-p (dtache--session-working-directory session))
- (dtache--session-timer session)
- (dtache--add-end-of-session-notification session)))
+ (dtache--session-timer-monitor session)
+ (if (eq system-type 'darwin)
+ (dtache--session-macos-monitor session)
+ (dtache--session-filenotify-monitor session))))
(defun dtache-dtach-command (session)
"Return a dtach command for SESSION."
@@ -697,8 +699,9 @@ Sessions running on current host or localhost are updated."
"")
"\n"))
-(defun dtache--session-timer (session)
- "Create a timmer for SESSION according to `dtache-timer-configuration'."
+(defun dtache--session-timer-monitor (session)
+ "Configure a timer to monitor SESSION activity.
+ The timer object is configured according to `dtache-timer-configuration'."
(let* ((timer)
(callback
(lambda ()
@@ -711,6 +714,22 @@ Sessions running on current host or localhost are
updated."
(plist-get dtache-timer-configuration :repeat)
callback))))
+(defun dtache--session-filenotify-monitor (session)
+ "Configure `filenotify' to monitor SESSION activity."
+ (file-notify-add-watch
+ (dtache-session-file session 'socket)
+ '(change)
+ (lambda (event)
+ (pcase-let ((`(,_ ,action ,_) event))
+ (when (eq action 'deleted)
+ (dtache--session-final-update session))))))
+
+(defun dtache--session-macos-monitor (session)
+ "Configure a timer to monitor SESSION activity on macOS."
+ (let ((dtache-timer-configuration
+ '(:seconds 0.5 :repeat 0.5 :function run-with-idle-timer)))
+ (dtache--session-timer-monitor session)))
+
;;;;; Database
(defun dtache--db-initialize ()
@@ -764,16 +783,6 @@ Sessions running on current host or localhost are
updated."
('attach "-a")
(_ "-n")))
-(defun dtache--add-end-of-session-notification (session)
- "Trigger an event when SESSION is stopped."
- (file-notify-add-watch
- (dtache-session-file session 'socket)
- '(change)
- (lambda (event)
- (pcase-let ((`(,_ ,action ,_) event))
- (when (eq action 'deleted)
- (dtache--session-final-update session))))))
-
(defun dtache--session-final-update (session)
"Make a final update to SESSION."
(if (dtache--session-missing-p session)
- [elpa] externals/dtache ecc7563302 048/158: Update LICENSE, (continued)
- [elpa] externals/dtache ecc7563302 048/158: Update LICENSE, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 2958d21869 035/158: Remove marginalia from dtache, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache afb2684f38 027/158: Improve dtache-env command, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache c29079e0c0 047/158: Remove dtache-session-history, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache db230154e4 016/158: Merge develop branch into master, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 2a38a9b538 030/158: Robustify against failures in configuration, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 115de6c1a2 022/158: Add default value for dtache-max-command-length, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 09d378e50a 024/158: Fix read-only problematic, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 4e99fc9daa 049/158: Deprecate dtache-list-sessions, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache cb1762ffc2 052/158: Add presentation about dtache version 0.2, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 5d9c8aa54f 053/158: Add macOS support,
ELPA Syncer <=
- [elpa] externals/dtache 01a27b4dc2 056/158: Update README with reference to consult-dtache, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache b75af1b9a7 059/158: Update notification setup, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache b47bc3be09 061/158: Update copyright years, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 182ab7ccc6 064/158: Add integration with consult, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache ea6d8ae426 068/158: Add missing autoloads, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache e2efe466e0 076/158: Improve error handling with dtache-valid-session, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 79f1d905a9 078/158: Add example of how to enhance a command with dtach, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache dae6db33db 083/158: Fix various minor problems, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 52e839ff4a 007/158: Update README with links, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 7e8727f3a2 020/158: Add TODO to investigate unknown inactive sessions, ELPA Syncer, 2022/01/19