emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

feature/android c4c34f72a12 01/10: Merge remote-tracking branch 'origin/


From: Po Lu
Subject: feature/android c4c34f72a12 01/10: Merge remote-tracking branch 'origin/master' into feature/android
Date: Wed, 15 Feb 2023 09:53:28 -0500 (EST)

branch: feature/android
commit c4c34f72a123c4177a21c934c4e414cfe9e3c553
Merge: dc120c7ad62 67dea8143f1
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Merge remote-tracking branch 'origin/master' into feature/android
---
 lisp/net/tramp.el            | 18 +++++++++++++++---
 test/lisp/net/tramp-tests.el | 20 +++++++++++++++++---
 2 files changed, 32 insertions(+), 6 deletions(-)

diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index b75a1816fdb..36305dda496 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -2948,9 +2948,21 @@ not in completion mode."
 
 (defun tramp-completion-handle-expand-file-name (filename &optional directory)
   "Like `expand-file-name' for partial Tramp files."
-  (if (file-name-absolute-p filename)
-      filename
-    (concat (or directory default-directory "/") filename)))
+  ;; We need special handling only when a method is needed.  Then we
+  ;; check, whether DIRECTORY is "/method:" or "/[method/".
+  (let ((dir (or directory default-directory "/")))
+    (cond
+     ((file-name-absolute-p filename) filename)
+     ((and (eq tramp-syntax 'simplified)
+           (string-match-p (rx (regexp tramp-postfix-host-regexp) eos) dir))
+      (concat dir filename))
+     ((string-match-p
+       (rx bos (regexp tramp-prefix-regexp)
+          (? (regexp tramp-method-regexp) (regexp tramp-postfix-method-regexp))
+          eos)
+       dir)
+      (concat dir filename))
+     (t (tramp-run-real-handler #'expand-file-name (list filename 
directory))))))
 
 (defun tramp-completion-handle-file-exists-p (filename)
   "Like `file-exists-p' for partial Tramp files."
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index eea59843d47..85714e79bc0 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -4641,7 +4641,9 @@ This tests also `make-symbolic-link', `file-truename' and 
`add-name-to-file'."
 ;; TODO: Add tests for user names and multi-hop file names.
 (ert-deftest tramp-test26-interactive-file-name-completion ()
   "Check interactive completion with different `completion-styles'."
-  ;; Method and host name in completion mode.  This kind of completion
+  (tramp-cleanup-connection tramp-test-vec nil 'keep-password)
+
+;; Method and host name in completion mode.  This kind of completion
   ;; does not work on MS Windows.
   (unless (memq system-type '(cygwin windows-nt))
     (let ((method (file-remote-p ert-remote-temporary-file-directory 'method))
@@ -4695,7 +4697,7 @@ This tests also `make-symbolic-link', `file-truename' and 
`add-name-to-file'."
                               tramp-prefix-format
                               (substring-no-properties method 0 2))
                         unread-command-events
-                        (mapcar #'identity (concat test "\t\n"))
+                        (mapcar #'identity (concat test "\t\t\n"))
                         completions nil
                         result (read-file-name "Prompt: "))
                   (if (not (get-buffer "*Completions*"))
@@ -4708,6 +4710,12 @@ This tests also `make-symbolic-link', `file-truename' 
and `add-name-to-file'."
                           (concat tramp-prefix-format method-string)
                           result)))
                     (with-current-buffer "*Completions*"
+                     ;; We must remove leading `default-directory'.
+                     (goto-char (point-min))
+                     (let ((inhibit-read-only t))
+                       (while (re-search-forward "//" nil 'noerror)
+                         (delete-region (line-beginning-position) (point))))
+                     (goto-char (point-min))
                      (re-search-forward
                        (rx bol (1+ nonl) "possible completions:" eol))
                      (forward-line 1)
@@ -4729,7 +4737,7 @@ This tests also `make-symbolic-link', `file-truename' and 
`add-name-to-file'."
                               tramp-prefix-format method-string
                               (substring-no-properties host 0 2))
                         unread-command-events
-                        (mapcar #'identity (concat test "\t\n"))
+                        (mapcar #'identity (concat test "\t\t\n"))
                         completions nil
                         result (read-file-name "Prompt: "))
                   (if (not (get-buffer "*Completions*"))
@@ -4744,6 +4752,12 @@ This tests also `make-symbolic-link', `file-truename' 
and `add-name-to-file'."
                           ipv6-prefix host ipv6-postfix 
tramp-postfix-host-format)
                           result)))
                     (with-current-buffer "*Completions*"
+                     ;; We must remove leading `default-directory'.
+                     (goto-char (point-min))
+                     (let ((inhibit-read-only t))
+                       (while (re-search-forward "//" nil 'noerror)
+                         (delete-region (line-beginning-position) (point))))
+                     (goto-char (point-min))
                      (re-search-forward
                        (rx bol (1+ nonl) "possible completions:" eol))
                      (forward-line 1)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]