branch: externals/dtache commit e0a45c055cabd7b074b88cd4ed8c5a3fc19039c5 Author: Niklas Eklund <niklas.ekl...@posteo.net> Commit: Niklas Eklund <niklas.ekl...@posteo.net>
Address error in eshell/shell extension --- dtache-eshell.el | 6 ++++-- dtache-shell.el | 2 +- dtache.el | 2 +- test/dtache-test.el | 10 ++++++++++ 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/dtache-eshell.el b/dtache-eshell.el index c7ab36dbf7..8fbde70a49 100644 --- a/dtache-eshell.el +++ b/dtache-eshell.el @@ -108,12 +108,14 @@ If prefix-argument directly DETACH from the session." (defun dtache-eshell--maybe-create-session () "Create a session if `dtache-eshell-command' value is t." (when dtache-enabled - (let* ((dtache-session-mode 'create-and-attach) - (dtache-session-action dtache-eshell-session-action) + (let* ((dtache-session-action dtache-eshell-session-action) (command (mapconcat #'identity `(,eshell-last-command-name ,@eshell-last-arguments) " ")) + (dtache-session-mode (if (dtache-attachable-command-p command) + dtache-session-mode + 'create)) (session (dtache-create-session command))) (setq eshell-last-arguments (dtache-dtach-command session)) (setq dtache--buffer-session session) diff --git a/dtache-shell.el b/dtache-shell.el index 5161068823..5851465d3d 100644 --- a/dtache-shell.el +++ b/dtache-shell.el @@ -106,7 +106,7 @@ cluttering the comint-history with dtach commands." (with-connection-local-variables (let* ((command (substring-no-properties string)) (dtache-session-mode (if (dtache-attachable-command-p command) - 'create-and-attach + dtache-session-mode 'create)) (dtach-command (dtache-dtach-command command t))) (comint-simple-send proc dtach-command)))) diff --git a/dtache.el b/dtache.el index bfb1558618..83d5c9b976 100644 --- a/dtache.el +++ b/dtache.el @@ -1009,7 +1009,7 @@ Optionally make the path LOCAL to host." ('create "-n") ('create-and-attach "-c") ('attach "-a") - (_ "-n"))) + (_ (error "`dtache-session-mode' has an unknown value.")))) (defun dtache--session-state-transition-update (session) "Update SESSION due to state transition." diff --git a/test/dtache-test.el b/test/dtache-test.el index 8916fd9f79..1099fdd20a 100644 --- a/test/dtache-test.el +++ b/test/dtache-test.el @@ -174,6 +174,16 @@ (dtache--db-get-sessions) `(,session1 ,session3)))))) +(ert-deftest dtache-test-dtach-arg () + (let ((dtache-session-mode 'create)) + (should (string= "-n" (dtache--dtach-arg)))) + (let ((dtache-session-mode 'create-and-attach)) + (should (string= "-c" (dtache--dtach-arg)))) + (let ((dtache-session-mode 'attach)) + (should (string= "-a" (dtache--dtach-arg)))) + (let ((dtache-session-mode nil)) + (should-error (dtache--dtach-arg)))) + ;;;;; Database (ert-deftest dtache-test-db-insert-session ()