[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dtache c40f0b2203 102/158: Make some public functions p
From: |
ELPA Syncer |
Subject: |
[elpa] externals/dtache c40f0b2203 102/158: Make some public functions private |
Date: |
Wed, 19 Jan 2022 18:58:02 -0500 (EST) |
branch: externals/dtache
commit c40f0b2203fedbb749f39596845706b8176a1120
Author: Niklas Eklund <niklas.eklund@posteo.net>
Commit: Niklas Eklund <niklas.eklund@posteo.net>
Make some public functions private
Be more restrictive in which functions are considered public.
---
documentation/demo.org | 2 +-
dtache-compile.el | 54 ++++++------
dtache-eshell.el | 34 +++----
dtache-shell.el | 26 +++---
dtache.el | 234 ++++++++++++++++++++++++-------------------------
test/dtache-test.el | 30 +++----
6 files changed, 191 insertions(+), 189 deletions(-)
diff --git a/documentation/demo.org b/documentation/demo.org
index ec30340ee7..c8de5702f9 100644
--- a/documentation/demo.org
+++ b/documentation/demo.org
@@ -218,7 +218,7 @@ Sometimes you need to tweak =dtache's= behavior in how to
interact with specific
(with-current-buffer buffer
(erase-buffer)
(insert "This is a custom view of the session\n")
- (insert (dtache-session-output session)))
+ (insert (dtache--session-output session)))
(pop-to-buffer buffer)))))
(dtache-start-session command)))
diff --git a/dtache-compile.el b/dtache-compile.el
index 7a5a869069..67a4fd4bc2 100644
--- a/dtache-compile.el
+++ b/dtache-compile.el
@@ -63,31 +63,6 @@ Optionally EDIT-COMMAND."
;;;;; Functions
-(defun dtache-compile-advice (compilation-start &rest args)
- "Optionally create a `dtache' session before running COMPILATION-START with
ARGS."
- (if dtache-enabled
- (pcase-let ((`(,command ,mode ,_ ,highlight-regexp) args)
- (buffer-name "*dtache-compilation*"))
- (if (and (not (eq dtache-session-mode 'attach))
- (dtache-redirect-only-p command))
- (dtache-start-session command t)
- (cl-letf* ((name-function (lambda (_) buffer-name))
- (dtache--current-session (or dtache--current-session
- (dtache-create-session
command))))
- (apply compilation-start `(,(dtache-dtach-command
dtache--current-session t)
- ,(or mode 'dtache-compilation-mode)
- ,name-function
- ,highlight-regexp)))))
- (apply compilation-start args)))
-
-(defun dtache-compile-maybe-start (_proc)
- "Maybe run when compilation starts."
- (when dtache-enabled
- (setq dtache--buffer-session dtache--current-session)
- (dtache-compile--replace-modesetter)
- (add-hook 'comint-preoutput-filter-functions
#'dtache--dtache-env-message-filter 0 t)
- (add-hook 'comint-preoutput-filter-functions
#'dtache--dtach-eof-message-filter 0 t)))
-
(defun dtache-compile-attach (session)
"Attach to SESSION with `compile'."
(when (dtache-valid-session session)
@@ -107,11 +82,36 @@ Optionally EDIT-COMMAND."
(defun dtache-compile-setup ()
"Setup `dtache-compile'."
(dtache-setup)
- (advice-add #'compilation-start :around #'dtache-compile-advice)
- (add-hook 'compilation-start-hook #'dtache-compile-maybe-start))
+ (advice-add #'compilation-start :around #'dtache-compile--compilation-start)
+ (add-hook 'compilation-start-hook #'dtache-compile--start))
;;;;; Support functions
+(defun dtache-compile--compilation-start (compilation-start &rest args)
+ "Optionally create a `dtache' session before running COMPILATION-START with
ARGS."
+ (if dtache-enabled
+ (pcase-let ((`(,command ,mode ,_ ,highlight-regexp) args)
+ (buffer-name "*dtache-compilation*"))
+ (if (and (not (eq dtache-session-mode 'attach))
+ (dtache-redirect-only-p command))
+ (dtache-start-session command t)
+ (cl-letf* ((name-function (lambda (_) buffer-name))
+ (dtache--current-session (or dtache--current-session
+ (dtache-create-session
command))))
+ (apply compilation-start `(,(dtache-dtach-command
dtache--current-session t)
+ ,(or mode 'dtache-compilation-mode)
+ ,name-function
+ ,highlight-regexp)))))
+ (apply compilation-start args)))
+
+(defun dtache-compile--start (_)
+ "Run in `compilation-start-hook' if dtache-enabled."
+ (when dtache-enabled
+ (setq dtache--buffer-session dtache--current-session)
+ (dtache-compile--replace-modesetter)
+ (add-hook 'comint-preoutput-filter-functions
#'dtache--dtache-env-message-filter 0 t)
+ (add-hook 'comint-preoutput-filter-functions
#'dtache--dtach-eof-message-filter 0 t)))
+
(defun dtache-compile--replace-modesetter ()
"Replace the modsetter inserted by `compilation-start'."
(save-excursion
diff --git a/dtache-eshell.el b/dtache-eshell.el
index 9d39e7a7ba..662e7fa0bf 100644
--- a/dtache-eshell.el
+++ b/dtache-eshell.el
@@ -40,7 +40,7 @@
(defun dtache-eshell-setup ()
"Setup `dtache-eshell'."
(dtache-setup)
- (add-hook 'eshell-prepare-command-hook #'dtache-eshell-maybe-create-session)
+ (add-hook 'eshell-prepare-command-hook #'dtache-eshell--maybe-create-session)
(add-hook 'eshell-mode-hook #'dtache-eshell-mode))
(defun dtache-eshell-select-session ()
@@ -53,21 +53,6 @@
(seq-filter #'dtache--session-active-p))))
(dtache-completing-read sessions)))
-(defun dtache-eshell-maybe-create-session ()
- "Create a session if `dtache-eshell-command' value is t."
- (when dtache-enabled
- (let* ((dtache-session-mode 'create)
- (dtache-session-action dtache-eshell-session-action)
- (command (mapconcat #'identity
- `(,eshell-last-command-name
- ,@eshell-last-arguments)
- " "))
- (session (dtache-create-session command)))
- (setq eshell-last-arguments (dtache-dtach-command session))
- (setq dtache--buffer-session session)
- (setq dtache-enabled nil)
- (setq eshell-last-command-name "dtach"))))
-
(defun dtache-eshell-get-dtach-process ()
"Return `eshell' process if `dtache' is running."
(when-let* ((process (and eshell-process-list (caar eshell-process-list))))
@@ -112,6 +97,23 @@ If prefix-argument directly DETACH from the session."
(call-interactively #'eshell-send-input))
(dtache-open-session session))))
+;;;; Support functions
+
+(defun dtache-eshell--maybe-create-session ()
+ "Create a session if `dtache-eshell-command' value is t."
+ (when dtache-enabled
+ (let* ((dtache-session-mode 'create)
+ (dtache-session-action dtache-eshell-session-action)
+ (command (mapconcat #'identity
+ `(,eshell-last-command-name
+ ,@eshell-last-arguments)
+ " "))
+ (session (dtache-create-session command)))
+ (setq eshell-last-arguments (dtache-dtach-command session))
+ (setq dtache--buffer-session session)
+ (setq dtache-enabled nil)
+ (setq eshell-last-command-name "dtach"))))
+
;;;; Minor mode
;;;###autoload
diff --git a/dtache-shell.el b/dtache-shell.el
index 6be40c0ba8..a226a8895e 100644
--- a/dtache-shell.el
+++ b/dtache-shell.el
@@ -36,23 +36,11 @@
;;;; Functions
-(defun dtache-shell-override-history (orig-fun &rest args)
- "Override history to read `dtache-shell-history-file' in ORIG-FUN with ARGS.
-
-This function also makes sure that the HISTFILE is disabled for local shells."
- (cl-letf (((getenv "HISTFILE") ""))
- (advice-add 'comint-read-input-ring :around
#'dtache-shell--comint-read-input-ring-advice)
- (apply orig-fun args)))
-
-(defun dtache-shell-save-history ()
- "Add hook to save history when killing `shell' buffer."
- (add-hook 'kill-buffer-hook #'dtache-shell-save-history 0 t))
-
;;;###autoload
(defun dtache-shell-setup ()
"Setup `dtache-shell'."
(dtache-setup)
- (add-hook 'shell-mode-hook #'dtache-shell-save-history)
+ (add-hook 'shell-mode-hook #'dtache-shell--save-history-on-kill)
(advice-add 'shell :around #'dtache-shell-override-history))
(defun dtache-shell-select-session ()
@@ -134,6 +122,18 @@ cluttering the comint-history with dtach commands."
dtache-shell-history-file)))
(comint-write-input-ring))))
+(defun dtache-shell-override-history (orig-fun &rest args)
+ "Override history to read `dtache-shell-history-file' in ORIG-FUN with ARGS.
+
+This function also makes sure that the HISTFILE is disabled for local shells."
+ (cl-letf (((getenv "HISTFILE") ""))
+ (advice-add 'comint-read-input-ring :around
#'dtache-shell--comint-read-input-ring-advice)
+ (apply orig-fun args)))
+
+(defun dtache-shell--save-history-on-kill ()
+ "Add hook to save history when killing `shell' buffer."
+ (add-hook 'kill-buffer-hook #'dtache-shell--save-history 0 t))
+
(provide 'dtache-shell)
;;; dtache-shell.el ends here
diff --git a/dtache.el b/dtache.el
index a25d28155f..708194113f 100644
--- a/dtache.el
+++ b/dtache.el
@@ -242,13 +242,13 @@ Optionally SUPPRESS-OUTPUT."
(when (dtache-valid-session session)
(let ((buffer-name "*dtache-session-output*")
(file
- (dtache-session-file session 'log))
+ (dtache--session-file session 'log))
(tramp-verbose 1))
(when (file-exists-p file)
(with-current-buffer (get-buffer-create buffer-name)
(setq-local buffer-read-only nil)
(erase-buffer)
- (insert (dtache-session-output session))
+ (insert (dtache--session-output session))
(setq-local default-directory
(dtache--session-working-directory session))
(run-hooks 'dtache-compile-hooks)
@@ -280,7 +280,7 @@ Optionally SUPPRESS-OUTPUT."
(list (dtache-completing-read (dtache-get-sessions))))
(when (dtache-valid-session session)
(with-temp-buffer
- (insert (dtache-session-output session))
+ (insert (dtache--session-output session))
(kill-new (buffer-string)))))
;;;###autoload
@@ -327,14 +327,14 @@ Optionally SUPPRESS-OUTPUT."
(when (dtache-valid-session session)
(let* ((buffer-name "*dtache-session-output*")
(file-path
- (dtache-session-file session 'log))
+ (dtache--session-file session 'log))
(tramp-verbose 1))
(if (file-exists-p file-path)
(progn
(with-current-buffer (get-buffer-create buffer-name)
(setq-local buffer-read-only nil)
(erase-buffer)
- (insert (dtache-session-output session))
+ (insert (dtache--session-output session))
(setq-local default-directory (dtache--session-working-directory
session))
(dtache-log-mode)
(goto-char (point-max)))
@@ -349,7 +349,7 @@ Optionally SUPPRESS-OUTPUT."
(when (dtache-valid-session session)
(if (dtache--session-active-p session)
(let* ((file-path
- (dtache-session-file session 'log))
+ (dtache--session-file session 'log))
(tramp-verbose 1))
(when (file-exists-p file-path)
(find-file-other-window file-path)
@@ -371,11 +371,11 @@ Optionally SUPPRESS-OUTPUT."
(with-current-buffer (get-buffer-create buffer1)
(erase-buffer)
(insert (dtache--session-header session1))
- (insert (dtache-session-output session1)))
+ (insert (dtache--session-output session1)))
(with-current-buffer (get-buffer-create buffer2)
(erase-buffer)
(insert (dtache--session-header session2))
- (insert (dtache-session-output session2)))
+ (insert (dtache--session-output session2)))
(ediff-buffers buffer1 buffer2))))
;;;###autoload
@@ -428,13 +428,13 @@ nil before closing."
(defun dtache-create-session (command)
"Create a `dtache' session from COMMAND."
- (dtache-create-session-directory)
+ (dtache--create-session-directory)
(let ((session
(dtache--session-create :id (intern (dtache--create-id command))
:command command
:origin dtache-session-origin
:action dtache-session-action
- :working-directory
(dtache-get-working-directory)
+ :working-directory
(dtache--get-working-directory)
:redirect-only (dtache-redirect-only-p
command)
:creation-time (time-to-seconds
(current-time))
:status 'unknown
@@ -444,7 +444,7 @@ nil before closing."
:metadata (dtache-metadata)
:active t)))
(dtache--db-insert-entry session)
- (dtache-start-session-monitor session)
+ (dtache--start-session-monitor session)
session))
(defun dtache-start-session (command &optional suppress-output)
@@ -471,38 +471,6 @@ Optionally SUPPRESS-OUTPUT."
(funcall #'async-shell-command (dtache-dtach-command
dtache--current-session t) buffer)
(with-current-buffer buffer (setq dtache--buffer-session
dtache--current-session))))))
-(defun dtache-update-sessions ()
- "Update `dtache' sessions.
-
-Sessions running on current host or localhost are updated."
- (let ((current-host (dtache--host)))
- (seq-do (lambda (it)
- (if (and (or (string= current-host (dtache--session-host it))
- (string= "localhost" (dtache--session-host it)))
- (or (dtache--session-active it)
- (dtache--session-deactivated-p it)))
- (dtache-update-session it)))
- (dtache--db-get-sessions))))
-
-(defun dtache-session-file (session file &optional local)
- "Return the full path to SESSION's FILE.
-
-Optionally make the path LOCAL to host."
- (let* ((file-name
- (concat
- (symbol-name
- (dtache--session-id session))
- (pcase file
- ('socket ".socket")
- ('log ".log"))))
- (remote (file-remote-p (dtache--session-working-directory session)))
- (directory (concat
- remote
- (dtache--session-session-directory session))))
- (if (and local remote)
- (string-remove-prefix remote (expand-file-name file-name directory))
- (expand-file-name file-name directory))))
-
(defun dtache-session-candidates (sessions)
"Return an alist of SESSIONS candidates."
(setq dtache--session-candidates
@@ -529,16 +497,6 @@ Optionally make the path LOCAL to host."
0 ?\s)))
" ")))
-(defun dtache-update-session (session)
- "Update SESSION."
- (if (or (dtache--session-deactivated-p session)
- (dtache--session-missing-p session))
- (dtache--session-final-update session)
- (setf (dtache--session-output-size session)
- (file-attribute-size (file-attributes
- (dtache-session-file session 'log))))
- (dtache--db-update-entry session)))
-
;;;###autoload
(defun dtache-setup ()
"Initialize `dtache'."
@@ -559,13 +517,13 @@ Optionally make the path LOCAL to host."
;; Update local active sessions
(when (and (string= "localhost" (dtache--session-host session))
(dtache--session-active session))
- (dtache-update-session session))))
+ (dtache--update-session session))))
(dtache--db-get-sessions))
;; Start monitors
(thread-last (dtache--db-get-sessions)
(seq-filter #'dtache--session-active)
- (seq-do #'dtache-start-session-monitor))
+ (seq-do #'dtache--start-session-monitor))
;; Add `dtache-shell-mode'
(add-hook 'shell-mode-hook #'dtache-shell-mode)))
@@ -579,40 +537,20 @@ If session is not valid trigger an automatic cleanup on
SESSION's host."
t
(let ((host (dtache--session-host session)))
(message "Session does not exist. Initiate sesion cleanup on host %s"
host)
- (dtache-cleanup-host-sessions host)
+ (dtache--cleanup-host-sessions host)
nil))))
-(defun dtache-cleanup-host-sessions (host)
- "Run cleanuup on HOST sessions."
- (thread-last (dtache--db-get-sessions)
- (seq-filter (lambda (it) (string= host (dtache--session-host
it))))
- (seq-filter #'dtache--session-missing-p)
- (seq-do #'dtache--db-remove-entry)))
-
(defun dtache-session-exit-code-status (session)
"Return status based on exit-code in SESSION."
(if (null dtache-env)
'unknown
(with-temp-buffer
- (insert-file-contents (dtache-session-file session 'log))
+ (insert-file-contents (dtache--session-file session 'log))
(goto-char (point-max))
(if (string-match "Dtache session finished" (thing-at-point 'line t))
'success
'failure))))
-(defun dtache-session-output (session)
- "Return content of SESSION's output."
- (let* ((filename (dtache-session-file session 'log))
- (dtache-message (rx (regexp "\n?\nDtache session ") (or "finished"
"exited"))))
- (with-temp-buffer
- (insert-file-contents filename)
- (goto-char (point-min))
- (let ((beginning (point))
- (end (if (search-forward-regexp dtache-message nil t)
- (match-beginning 0)
- (point-max))))
- (buffer-substring beginning end)))))
-
(defun dtache-inactive-session-notification (session)
"Send a notification when SESSION becomes inactive."
(let ((status (pcase (dtache--session-status session)
@@ -632,7 +570,7 @@ If session is not valid trigger an automatic cleanup on
SESSION's host."
(defun dtache-get-sessions ()
"Update and return sessions."
- (dtache-update-sessions)
+ (dtache--update-sessions)
(dtache--db-get-sessions))
(defun dtache-shell-command-attach (session)
@@ -648,11 +586,6 @@ If session is not valid trigger an automatic cleanup on
SESSION's host."
(funcall #'async-shell-command (dtache--session-command session)
buffer)
(with-current-buffer buffer (setq dtache--buffer-session
dtache--current-session)))))))
-(defun dtache-delete-sessions ()
- "Delete all `dtache' sessions."
- (seq-do #'dtache--db-remove-entry
- (dtache-get-sessions)))
-
(defun dtache-attach-session (session)
"Attach to SESSION."
(if (dtache--session-redirect-only session)
@@ -667,15 +600,12 @@ If session is not valid trigger an automatic cleanup on
SESSION's host."
(funcall view-fun session)
(dtache-view-dwim session)))
-;;;;; Other
+(defun dtache-delete-sessions ()
+ "Delete all `dtache' sessions."
+ (seq-do #'dtache--db-remove-entry
+ (dtache-get-sessions)))
-(defun dtache-start-session-monitor (session)
- "Start to monitor SESSION activity."
- (if (file-remote-p (dtache--session-working-directory session))
- (dtache--session-timer-monitor session)
- (if (eq system-type 'darwin)
- (dtache--session-macos-monitor session)
- (dtache--session-filenotify-monitor session))))
+;;;;; Other
(cl-defgeneric dtache-dtach-command (entity &optional concat)
"Return dtach command for ENTITY optionally CONCAT.")
@@ -694,7 +624,7 @@ Optionally CONCAT the command return command into a string."
(let* ((dtache-session-mode (cond ((eq dtache-session-mode 'attach) 'attach)
((dtache--session-redirect-only session)
'new)
(t dtache-session-mode)))
- (socket (dtache-session-file session 'socket t)))
+ (socket (dtache--session-file session 'socket t)))
(setq dtache--buffer-session session)
(if (eq dtache-session-mode 'attach)
(if concat
@@ -733,24 +663,6 @@ Optionally CONCAT the command return command into a
string."
(push `(,(car annotator) . ,(funcall (cdr annotator))) metadata))
metadata))
-(defun dtache-create-session-directory ()
- "Create session directory if it doesn't exist."
- (let ((directory
- (concat
- (file-remote-p default-directory)
- dtache-session-directory)))
- (unless (file-exists-p directory)
- (make-directory directory t))))
-
-(defun dtache-get-working-directory ()
- "Return an abreviated working directory path."
- (let* ((remote (file-remote-p default-directory))
- (full-home (if remote (expand-file-name remote) (expand-file-name
"~")))
- (short-home (if remote (concat remote "~/") "~")))
- (replace-regexp-in-string full-home
- short-home
- (expand-file-name default-directory))))
-
(defun dtache-completing-read (sessions)
"Select a session from SESSIONS through `completing-read'."
(let* ((candidates (dtache-session-candidates sessions))
@@ -815,19 +727,19 @@ Optionally CONCAT the command return command into a
string."
(defun dtache--session-active-p (session)
"Return t if SESSION is active."
(file-exists-p
- (dtache-session-file session 'socket)))
+ (dtache--session-file session 'socket)))
(defun dtache--session-deactivated-p (session)
"Return t if SESSION has been deactivated."
(and
(dtache--session-active session)
- (not (file-exists-p (dtache-session-file session 'socket)))))
+ (not (file-exists-p (dtache--session-file session 'socket)))))
(defun dtache--session-missing-p (session)
"Return t if SESSION is missing."
(not
(file-exists-p
- (dtache-session-file session 'log))))
+ (dtache--session-file session 'log))))
(defun dtache--session-header (session)
"Return header for SESSION."
@@ -862,7 +774,7 @@ Optionally CONCAT the command return command into a string."
(defun dtache--session-filenotify-monitor (session)
"Configure `filenotify' to monitor SESSION activity."
(file-notify-add-watch
- (dtache-session-file session 'socket)
+ (dtache--session-file session 'socket)
'(change)
(lambda (event)
(pcase-let ((`(,_ ,action ,_) event))
@@ -894,6 +806,86 @@ Optionally CONCAT the command return command into a
string."
"Return the session assicated with ITEM."
(cdr (assoc item dtache--session-candidates)))
+(defun dtache--update-sessions ()
+ "Update `dtache' sessions.
+
+Sessions running on current host or localhost are updated."
+ (let ((current-host (dtache--host)))
+ (seq-do (lambda (it)
+ (if (and (or (string= current-host (dtache--session-host it))
+ (string= "localhost" (dtache--session-host it)))
+ (or (dtache--session-active it)
+ (dtache--session-deactivated-p it)))
+ (dtache--update-session it)))
+ (dtache--db-get-sessions))))
+
+(defun dtache--update-session (session)
+ "Update SESSION."
+ (if (or (dtache--session-deactivated-p session)
+ (dtache--session-missing-p session))
+ (dtache--session-final-update session)
+ (setf (dtache--session-output-size session)
+ (file-attribute-size (file-attributes
+ (dtache--session-file session 'log))))
+ (dtache--db-update-entry session)))
+
+(defun dtache--session-file (session file &optional local)
+ "Return the full path to SESSION's FILE.
+
+Optionally make the path LOCAL to host."
+ (let* ((file-name
+ (concat
+ (symbol-name
+ (dtache--session-id session))
+ (pcase file
+ ('socket ".socket")
+ ('log ".log"))))
+ (remote (file-remote-p (dtache--session-working-directory session)))
+ (directory (concat
+ remote
+ (dtache--session-session-directory session))))
+ (if (and local remote)
+ (string-remove-prefix remote (expand-file-name file-name directory))
+ (expand-file-name file-name directory))))
+
+(defun dtache--cleanup-host-sessions (host)
+ "Run cleanuup on HOST sessions."
+ (thread-last (dtache--db-get-sessions)
+ (seq-filter (lambda (it) (string= host (dtache--session-host
it))))
+ (seq-filter #'dtache--session-missing-p)
+ (seq-do #'dtache--db-remove-entry)))
+
+(defun dtache--session-output (session)
+ "Return content of SESSION's output."
+ (let* ((filename (dtache--session-file session 'log))
+ (dtache-message (rx (regexp "\n?\nDtache session ") (or "finished"
"exited"))))
+ (with-temp-buffer
+ (insert-file-contents filename)
+ (goto-char (point-min))
+ (let ((beginning (point))
+ (end (if (search-forward-regexp dtache-message nil t)
+ (match-beginning 0)
+ (point-max))))
+ (buffer-substring beginning end)))))
+
+(defun dtache--create-session-directory ()
+ "Create session directory if it doesn't exist."
+ (let ((directory
+ (concat
+ (file-remote-p default-directory)
+ dtache-session-directory)))
+ (unless (file-exists-p directory)
+ (make-directory directory t))))
+
+(defun dtache--get-working-directory ()
+ "Return an abreviated working directory path."
+ (let* ((remote (file-remote-p default-directory))
+ (full-home (if remote (expand-file-name remote) (expand-file-name
"~")))
+ (short-home (if remote (concat remote "~/") "~")))
+ (replace-regexp-in-string full-home
+ short-home
+ (expand-file-name default-directory))))
+
;;;;; Database
(defun dtache--db-initialize ()
@@ -957,7 +949,7 @@ Optionally CONCAT the command return command into a string."
(setf (dtache--session-output-size session)
(file-attribute-size
(file-attributes
- (dtache-session-file session 'log))))
+ (dtache--session-file session 'log))))
(setf (dtache--session-active session) nil)
(setf (dtache--session-duration session)
@@ -992,7 +984,7 @@ Optionally CONCAT the command return command into a string."
If SESSION is redirect-only fallback to a command that doesn't rely on tee.
Otherwise use tee to log stdout and stderr individually."
- (let* ((log (dtache-session-file session 'log t))
+ (let* ((log (dtache--session-file session 'log t))
(redirect
(if (dtache--session-redirect-only session)
(format "&> %s" log)
@@ -1017,7 +1009,7 @@ the current time is used."
(- (time-to-seconds
(file-attribute-modification-time
(file-attributes
- (dtache-session-file session 'log))))
+ (dtache--session-file session 'log))))
(dtache--session-creation-time session)))
(defun dtache--create-id (command)
@@ -1037,6 +1029,14 @@ the current time is used."
"Remove `dtache--dtach-detached-message' in STR."
(replace-regexp-in-string (format "\n?%s\n" dtache--dtach-detached-message)
"" str))
+(defun dtache--start-session-monitor (session)
+ "Start to monitor SESSION activity."
+ (if (file-remote-p (dtache--session-working-directory session))
+ (dtache--session-timer-monitor session)
+ (if (eq system-type 'darwin)
+ (dtache--session-macos-monitor session)
+ (dtache--session-filenotify-monitor session))))
+
;;;;; UI
(defun dtache--metadata-str (session)
diff --git a/test/dtache-test.el b/test/dtache-test.el
index 85a7a08d0a..2982d5bba3 100644
--- a/test/dtache-test.el
+++ b/test/dtache-test.el
@@ -55,12 +55,12 @@
(pcase state
('activate
(dolist (type `(socket log))
- (with-temp-file (dtache-session-file session type))))
+ (with-temp-file (dtache--session-file session type))))
('deactivate
- (delete-file (dtache-session-file session 'socket)))
+ (delete-file (dtache--session-file session 'socket)))
('kill
- (delete-file (dtache-session-file session 'socket))
- (delete-file (dtache-session-file session 'log)))))
+ (delete-file (dtache--session-file session 'socket))
+ (delete-file (dtache--session-file session 'log)))))
;;;; Tests
@@ -74,25 +74,25 @@
(lambda (_)
session)))
(let* ((dtache-session-mode 'create)
- (expected `("-c" ,(dtache-session-file session 'socket t)
+ (expected `("-c" ,(dtache--session-file session 'socket t)
"-z" ,dtache-shell-program
"-c"
,(format "{ dtache-env ls\\ -la; } 2>&1 | tee %s"
- (dtache-session-file session 'log t))))
+ (dtache--session-file session 'log t))))
(expected-concat (format "%s -c %s -z %s -c %s"
dtach-program
- (dtache-session-file session 'socket t)
+ (dtache--session-file session 'socket t)
dtache-shell-program
(shell-quote-argument
(format "{ dtache-env ls\\ -la; } 2>&1 |
tee %s"
- (dtache-session-file session
'log t))))))
+ (dtache--session-file session
'log t))))))
(should (equal expected (dtache-dtach-command session)))
(should (equal expected-concat (dtache-dtach-command session t))))
(let* ((dtache-session-mode 'attach)
- (expected `("-a" ,(dtache-session-file session 'socket t)))
+ (expected `("-a" ,(dtache--session-file session 'socket t)))
(expected-concat (format "%s -a %s"
dtach-program
- (dtache-session-file session 'socket t))))
+ (dtache--session-file session 'socket
t))))
(should (equal expected (dtache-dtach-command session)))
(should (equal expected-concat (dtache-dtach-command session t)))))))
@@ -114,15 +114,15 @@
(cl-letf* (((symbol-function #'expand-file-name) (lambda (file directory)
(concat directory file)))
((symbol-function #'file-remote-p) (lambda (_directory) nil))
(session (dtache--session-create :id 's12345 :session-directory
"/home/user/tmp/")))
- (should (string= "/home/user/tmp/s12345.log" (dtache-session-file session
'log)))
- (should (string= "/home/user/tmp/s12345.socket" (dtache-session-file
session 'socket))))
+ (should (string= "/home/user/tmp/s12345.log" (dtache--session-file session
'log)))
+ (should (string= "/home/user/tmp/s12345.socket" (dtache--session-file
session 'socket))))
;; Remote files
(cl-letf* (((symbol-function #'expand-file-name) (lambda (file directory)
(concat directory file)))
((symbol-function #'file-remote-p) (lambda (_directory)
"/ssh:foo:"))
(session (dtache--session-create :id 's12345 :session-directory
"/home/user/tmp/")))
- (should (string= "/ssh:foo:/home/user/tmp/s12345.log" (dtache-session-file
session 'log)))
- (should (string= "/ssh:foo:/home/user/tmp/s12345.socket"
(dtache-session-file session 'socket)))))
+ (should (string= "/ssh:foo:/home/user/tmp/s12345.log"
(dtache--session-file session 'log)))
+ (should (string= "/ssh:foo:/home/user/tmp/s12345.socket"
(dtache--session-file session 'socket)))))
(ert-deftest dtache-test-session-truncate-command ()
(let ((dtache-max-command-length 7))
@@ -169,7 +169,7 @@
;; One inactive, one missing, one active
(dtache-test--change-session-state session1 'deactivate)
(dtache-test--change-session-state session2 'kill)
- (dtache-cleanup-host-sessions host)
+ (dtache--cleanup-host-sessions host)
(should (seq-set-equal-p
(dtache--db-get-sessions)
`(,session1 ,session3))))))
- [elpa] externals/dtache 7ddd1e29ef 146/158: Fix error on remote hosts, (continued)
- [elpa] externals/dtache 7ddd1e29ef 146/158: Fix error on remote hosts, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 9e0acd552d 150/158: Fix typo in dtache-test-dtach-command test, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache b8ab11cda6 091/158: Make sure to set current session in shell command, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache b1e4ead73e 094/158: Remove start-process advice, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 2c4520a3c5 015/158: Add missing variable to tail-mode, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache b247ddc6dd 077/158: Rewrite dtache-dtach-command, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 471a2f57c7 058/158: Update dtache-session-annotation, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache e3a12a9dc8 073/158: Add connection local variable to timer, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 9b7e7ffd2e 086/158: Rename session-type to session-origin, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache e8bc20f563 095/158: Fix error in dtache-shell-command, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache c40f0b2203 102/158: Make some public functions private,
ELPA Syncer <=
- [elpa] externals/dtache 9c16dd3751 109/158: Update active to state, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 3cc493e6b0 115/158: Add missing dtache-log-mode to detach-dwim, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache ebf9b491bd 117/158: Add variable for dtache-shell-command buffer, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache e9f6794621 129/158: Rename log-directory to directory, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 3969524f23 125/158: Improve dtache session header, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache e0a45c055c 133/158: Address error in eshell/shell extension, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 34c7d23346 088/158: Make dtache-eshell compatible with recent changes, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 2354197acb 096/158: Fix error in dtache-compile, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 5da693be75 100/158: Update CHANGELOG, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 0c8241a33d 107/158: Update actions from defvar to defcustom, ELPA Syncer, 2022/01/19