[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dape 4393b10a53 2/2: Infer host in tramp context #16
From: |
ELPA Syncer |
Subject: |
[elpa] externals/dape 4393b10a53 2/2: Infer host in tramp context #16 |
Date: |
Fri, 5 Jan 2024 09:57:41 -0500 (EST) |
branch: externals/dape
commit 4393b10a53b10c1e73ec13652f69e72a260b2bbe
Author: Daniel Pettersson <daniel@dpettersson.net>
Commit: Daniel Pettersson <daniel@dpettersson.net>
Infer host in tramp context #16
---
dape.el | 36 +++++++++++++++++++++---------------
1 file changed, 21 insertions(+), 15 deletions(-)
diff --git a/dape.el b/dape.el
index ff709ec750..368398ab7b 100644
--- a/dape.el
+++ b/dape.el
@@ -775,21 +775,27 @@ Replaces symbol and string occurences of \"autoport\"."
(plist-put 'command-args command-args)))))
(defun dape-config-tramp (config)
- "Apply tramp file prefix on CONFIG if started in tramp context."
- (if-let* (((and (not (plist-get config 'prefix-local))
- (not (plist-get config 'prefix-remote))
- (plist-get config 'command)))
- (default-directory (or (plist-get config 'command-cwd)
- default-directory))
- ((tramp-tramp-file-p default-directory))
- (parts (tramp-dissect-file-name default-directory))
- (tramp-prefix
- (tramp-completion-make-tramp-file-name (tramp-file-name-method
parts)
- (tramp-file-name-user
parts)
- (tramp-file-name-host
parts)
- "")))
- (plist-put config 'prefix-local tramp-prefix)
- config))
+ "Infer `prefix-local' and `host' on CONFIG if in tramp context."
+ (when-let* ((default-directory
+ (or (plist-get config 'command-cwd)
+ default-directory))
+ ((tramp-tramp-file-p default-directory))
+ (parts (tramp-dissect-file-name default-directory)))
+ (when (and (not (plist-get config 'prefix-local))
+ (not (plist-get config 'prefix-remote))
+ (plist-get config 'command))
+ (plist-put config 'prefix-local
+ (tramp-completion-make-tramp-file-name
+ (tramp-file-name-method parts)
+ (tramp-file-name-user parts)
+ (tramp-file-name-host parts)
+ "")))
+ (when (and (plist-get config 'command)
+ (plist-get config 'port)
+ (not (plist-get config 'host))
+ (equal (tramp-file-name-method parts) "ssh"))
+ (plist-put config 'host (file-remote-p default-directory 'host))))
+ config)
(defun dape-ensure-command (config)
"Ensure that `command' from CONFIG exist system."