[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dtache 8d4106e2f2: Monitor updates to the database
From: |
ELPA Syncer |
Subject: |
[elpa] externals/dtache 8d4106e2f2: Monitor updates to the database |
Date: |
Wed, 26 Jan 2022 17:57:29 -0500 (EST) |
branch: externals/dtache
commit 8d4106e2f2b352e1b4d9585b888547414df9318c
Author: Niklas Eklund <niklas.eklund@posteo.net>
Commit: Niklas Eklund <niklas.eklund@posteo.net>
Monitor updates to the database
This patch utilizes filenotify to add a watch for the
dtache-db-directory. This is needed in order for dtache to support
multiple active Emacs sessions. Any change to the database by any of
the Emacs instances will trigger a re-initialization of all
dtache-sessions. This means that once a session is created from any of
the Emacs sessions, that information will propagate to the others as well.
---
CHANGELOG.org | 2 ++
dtache.el | 17 +++++++++++++++++
2 files changed, 19 insertions(+)
diff --git a/CHANGELOG.org b/CHANGELOG.org
index 093afe3058..8f3e31f60f 100644
--- a/CHANGELOG.org
+++ b/CHANGELOG.org
@@ -4,6 +4,8 @@
* Development
+- Support for multiple Emacs sessions. When a =dtache= session is created, it
will now become visible in all active Emacs sessions.
+
* Version 0.4 (2022-010-22)
- =dtache= takes care of setting up the keybindings for its users. The detach
key can be customized through =dtache-detach-key=
diff --git a/dtache.el b/dtache.el
index 48bd6443a1..e627ab17d9 100644
--- a/dtache.el
+++ b/dtache.el
@@ -214,6 +214,8 @@ This version is encoded as [package-version].[revision].")
"A list of sessions.")
(defvar dtache--watched-session-directories nil
"An alist where values are a (directory . descriptor).")
+(defvar dtache--db-watch nil
+ "A descriptor to the `dtache-db-directory'.")
(defvar dtache--buffer-session nil
"The `dtache-session' session in current buffer.")
(defvar dtache--current-session nil
@@ -598,6 +600,11 @@ Optionally SUPPRESS-OUTPUT."
(unless (file-exists-p dtache-db-directory)
(make-directory dtache-db-directory t))
(dtache--db-initialize)
+ (setq dtache--db-watch
+ (file-notify-add-watch dtache-db-directory
+ '(change attribute-change)
+ #'dtache--db-directory-event))
+ (setq dtache--sessions-initialized t)
;; Remove missing local sessions
(thread-last (dtache--db-get-sessions)
@@ -1129,6 +1136,16 @@ session and trigger a state transition."
(setq dtache--watched-session-directories
(assoc-delete-all session-directory
dtache--watched-session-directories)))))))
+(defun dtache--db-directory-event (event)
+ "Act on EVENT in `dtache-db-directory'.
+
+If event is cased by an update to the `dtache' database, re-initialize
+`dtache--sessions'."
+ (pcase-let ((`(,_descriptor ,action ,file)))
+ (when (and (string= "dtache.db" file)
+ (eq 'attribute-changed action)))
+ (dtache--db-initialize)))
+
;;;;; UI
(defun dtache--metadata-str (session)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/dtache 8d4106e2f2: Monitor updates to the database,
ELPA Syncer <=