branch: externals/dtache
commit 2e5a097da4ddbff3bc8d373a3e18bdc337d7e0e5
Author: Niklas Eklund <[email protected]>
Commit: Niklas Eklund <[email protected]>
Implement dtache-compile-open
---
dtache-compile.el | 16 ++++++++++++----
dtache.el | 9 +++++----
2 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/dtache-compile.el b/dtache-compile.el
index a2f4bd6f58..ce5a480a35 100644
--- a/dtache-compile.el
+++ b/dtache-compile.el
@@ -87,10 +87,18 @@ Optionally EDIT-COMMAND."
(defun dtache-compile-attach (session)
"Attach to SESSION with `compile'."
- (let* ((dtache-compile-command t)
- (dtache--dtach-mode 'attach)
- (dtache--current-session session))
- (compilation-start nil)))
+ (when (dtache-valid-session session)
+ (let* ((dtache-compile-command t)
+ (dtache--dtach-mode 'attach)
+ (dtache--current-session session))
+ (compilation-start nil))))
+
+(defun dtache-compile-open (session)
+ "Open SESSION with `dtache-compile'."
+ (when (dtache-valid-session session)
+ (if (dtache--session-active session)
+ (dtache-compile-attach session)
+ (dtache-compile-session session))))
;;;###autoload
(defun dtache-compile-setup ()
diff --git a/dtache.el b/dtache.el
index 364cf355ee..ecf2077a74 100644
--- a/dtache.el
+++ b/dtache.el
@@ -90,7 +90,7 @@
(defvar dtache-type-open-dispatch '((shell-command .
dtache-shell-command-attach)
(shell . dtache-shell-command-attach)
(eshell . dtache-shell-command-attach)
- (compile . dtache-compile-attach))
+ (compile . dtache-compile-open))
"How to open an active session based on type.")
(defvar dtache-annotation-format
@@ -640,9 +640,10 @@ If session is not valid trigger an automatic cleanup on
SESSION's host."
(defun dtache-shell-command-attach (session)
"Attach to `dtache' SESSION."
- (let* ((dtache--current-session session)
- (dtache--dtach-mode 'attach))
- (dtache-start-session nil)))
+ (when (dtache-valid-session session)
+ (let* ((dtache--current-session session)
+ (dtache--dtach-mode 'attach))
+ (dtache-start-session nil))))
;;;;; Other