[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dtache 2a9b299de3 1/3: Add dtache-local-session option
From: |
ELPA Syncer |
Subject: |
[elpa] externals/dtache 2a9b299de3 1/3: Add dtache-local-session option |
Date: |
Tue, 8 Feb 2022 15:57:29 -0500 (EST) |
branch: externals/dtache
commit 2a9b299de30fcce3201d9c352c633cd255035acd
Author: Niklas Eklund <niklas.eklund@posteo.net>
Commit: Niklas Eklund <niklas.eklund@posteo.net>
Add dtache-local-session option
Add variable to control wether a session should be forced to run on
the local host. This feature is required in order to support
integration with a package such as dired-rsync. It needs to run a
local session even if we are copying remote files.
---
dtache.el | 29 +++++++++++++++++++++++------
1 file changed, 23 insertions(+), 6 deletions(-)
diff --git a/dtache.el b/dtache.el
index b5ec254f41..1a58cdb773 100644
--- a/dtache.el
+++ b/dtache.el
@@ -157,6 +157,8 @@ Valid values are: create, new and attach")
"A property list of actions for a session.")
(defvar dtache-shell-command-history nil
"History of commands run with `dtache-shell-command'.")
+(defvar dtache-local-session nil
+ "If set to t enforces a local session.")
(defvar dtache-compile-session-hooks nil
"Hooks to run when compiling a session.")
@@ -270,6 +272,17 @@ This version is encoded as [package-version].[revision].")
(size nil)
(state nil))
+;;;; Macros
+
+(defmacro dtache-connection-local-variables (&rest body)
+ "A macro that conditionally use `connection-local-variables' when executing
BODY."
+ `(if dtache-local-session
+ (progn
+ ,@body)
+ (with-connection-local-variables
+ (progn
+ ,@body))))
+
;;;; Commands
;;;###autoload
@@ -545,7 +558,7 @@ nil before closing."
(defun dtache-create-session (command)
"Create a `dtache' session from COMMAND."
- (with-connection-local-variables
+ (dtache-connection-local-variables
(dtache--create-session-directory)
(let ((session
(dtache--session-create :id (intern (dtache--create-id command))
@@ -557,7 +570,8 @@ nil before closing."
:time `(:start ,(time-to-seconds
(current-time)) :end 0.0 :duration 0.0 :offset 0.0)
:status '(unknown . 0)
:size 0
- :directory (concat (file-remote-p
default-directory) dtache-session-directory)
+ :directory (if dtache-local-session
dtache-session-directory
+ (concat (file-remote-p
default-directory) dtache-session-directory))
:host (dtache--host)
:metadata (dtache-metadata)
:state 'unknown)))
@@ -580,8 +594,11 @@ Optionally SUPPRESS-OUTPUT."
(not (dtache--session-attachable
dtache--current-session)))))
(dtache-session-mode 'create))
(progn (setq dtache-enabled nil)
- (apply #'start-file-process-shell-command
- `("dtache" nil ,(dtache-dtach-command
dtache--current-session t))))
+ (if dtache-local-session
+ (apply #'start-process-shell-command
+ `("dtache" nil ,(dtache-dtach-command
dtache--current-session t)))
+ (apply #'start-file-process-shell-command
+ `("dtache" nil ,(dtache-dtach-command
dtache--current-session t)))))
(cl-letf* ((dtache-session-mode 'create-and-attach)
((symbol-function #'set-process-sentinel) #'ignore)
(buffer (get-buffer-create dtache--shell-command-buffer)))
@@ -760,7 +777,7 @@ Optionally CONCAT the command return command into a string."
"Return dtach command for SESSION.
Optionally CONCAT the command return command into a string."
- (with-connection-local-variables
+ (dtache-connection-local-variables
(let* ((dtache-session-mode (cond ((eq dtache-session-mode 'attach) 'attach)
((not (dtache--session-attachable
session)) 'create)
(t dtache-session-mode)))
@@ -965,7 +982,7 @@ Optionally make the path LOCAL to host."
(make-directory directory t))))
(defun dtache--get-working-directory ()
- "Return an abreviated working directory path."
+ "Return an abbreviated working directory path."
(if-let (remote (file-remote-p default-directory))
(replace-regexp-in-string (expand-file-name remote)
(concat remote "~/")