[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 1997d09: Fix Bug#10085
From: |
Michael Albinus |
Subject: |
[Emacs-diffs] master 1997d09: Fix Bug#10085 |
Date: |
Mon, 02 May 2016 07:02:42 +0000 |
branch: master
commit 1997d09f78b9b7a5c2d4068e0a7c7282978742fa
Author: Michael Albinus <address@hidden>
Commit: Michael Albinus <address@hidden>
Fix Bug#10085
* lisp/net/tramp.el (tramp-find-foreign-file-name-handler):
Add optional arguments OPERATION and COMPETION. Handle
`file-name-as-directory', `file-name-directory' and
`file-name-nondirectory' also in completion mode.
(tramp-file-name-handler): Use it. (Bug#10085)
* test/lisp/net/tramp-tests.el (tramp-test06-directory-file-name):
Extend test.
---
lisp/net/tramp.el | 17 +++++++++++++----
test/lisp/net/tramp-tests.el | 14 +++++++++++++-
2 files changed, 26 insertions(+), 5 deletions(-)
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 4edca5a..3da60e9 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -1944,7 +1944,8 @@ ARGS are the arguments OPERATION has been called with."
;; Unknown file primitive.
(t (error "unknown file I/O primitive: %s" operation))))
-(defun tramp-find-foreign-file-name-handler (filename)
+(defun tramp-find-foreign-file-name-handler
+ (filename &optional operation completion)
"Return foreign file name handler if exists."
(when (tramp-tramp-file-p filename)
(let ((v (tramp-dissect-file-name filename t))
@@ -1952,11 +1953,17 @@ ARGS are the arguments OPERATION has been called with."
elt res)
;; When we are not fully sure that filename completion is safe,
;; we should not return a handler.
- (when (or (tramp-file-name-method v) (tramp-file-name-user v)
+ (when (or (not completion)
+ (tramp-file-name-method v) (tramp-file-name-user v)
(and (tramp-file-name-host v)
(not (member (tramp-file-name-host v)
(mapcar 'car tramp-methods))))
- (not (tramp-completion-mode-p)))
+ ;; Some operations are safe by default.
+ (member
+ operation
+ '(file-name-as-directory
+ file-name-directory
+ file-name-nondirectory)))
(while handler
(setq elt (car handler)
handler (cdr handler))
@@ -1984,7 +1991,9 @@ Falls back to normal file name handler if no Tramp file
name handler exists."
(tramp-replace-environment-variables
(apply 'tramp-file-name-for-operation operation args)))
(completion (tramp-completion-mode-p))
- (foreign (tramp-find-foreign-file-name-handler filename))
+ (foreign
+ (tramp-find-foreign-file-name-handler
+ filename operation completion))
result)
(with-parsed-tramp-file-name filename nil
;; Call the backend function.
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index a12ee38..5090a5b 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -637,7 +637,19 @@ This checks also `file-name-as-directory',
`file-name-directory',
(should
(string-equal (file-name-nondirectory "/method:host:/path/to/file/") ""))
(should-not
- (unhandled-file-name-directory "/method:host:/path/to/file")))
+ (unhandled-file-name-directory "/method:host:/path/to/file"))
+
+ ;; Bug#10085.
+ (dolist (n-e '(nil t))
+ (let ((non-essential n-e))
+ (dolist (file
+ `(,(file-remote-p tramp-test-temporary-file-directory 'method)
+ ,(file-remote-p tramp-test-temporary-file-directory 'host)))
+ (setq file (format "/%s:" file))
+ (should (string-equal (directory-file-name file) file))
+ (should (string-equal (file-name-as-directory file) (concat file "./")))
+ (should (string-equal (file-name-directory file) file))
+ (should (string-equal (file-name-nondirectory file) ""))))))
(ert-deftest tramp-test07-file-exists-p ()
"Check `file-exist-p', `write-region' and `delete-file'."
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 1997d09: Fix Bug#10085,
Michael Albinus <=