aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2017-06-11 23:16:13 +0200
committerMichael Albinus2017-06-11 23:16:13 +0200
commit87958db425812ec7cacf9ad3f8db22a91e3db4e4 (patch)
tree05ab907b0bd20ae3d3bffe070f15a2c2a8684e55
parentee051688c18b3bd7bb7c7a01100f09f7dd402ba6 (diff)
downloademacs-87958db425812ec7cacf9ad3f8db22a91e3db4e4.tar.gz
emacs-87958db425812ec7cacf9ad3f8db22a91e3db4e4.zip
Some further improvements for tramp-gvfs.el
* lisp/net/tramp-gvfs.el (tramp-gvfs-handle-expand-file-name) (tramp-gvfs-get-file-attributes) (tramp-gvfs-maybe-open-connection): Handle davs? properly. (tramp-gvfs-handler-askquestion): Improve `yes-or-no-p' prompt. Show question also in batch mode. Cache result. * test/lisp/net/tramp-tests.el (tramp-test24-file-name-completion): Support completion for host names and ports.
-rw-r--r--lisp/net/tramp-gvfs.el85
-rw-r--r--test/lisp/net/tramp-tests.el2
2 files changed, 53 insertions, 34 deletions
diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el
index 119efa53f36..7aac7c66e37 100644
--- a/lisp/net/tramp-gvfs.el
+++ b/lisp/net/tramp-gvfs.el
@@ -805,7 +805,7 @@ file names."
805 (unless (tramp-run-real-handler 'file-name-absolute-p (list localname)) 805 (unless (tramp-run-real-handler 'file-name-absolute-p (list localname))
806 (setq localname (concat "/" localname))) 806 (setq localname (concat "/" localname)))
807 ;; We do not pass "/..". 807 ;; We do not pass "/..".
808 (if (string-match "^\\(afp\\|smb\\)$" method) 808 (if (string-match "^\\(afp\\|davs?\\|smb\\)$" method)
809 (when (string-match "^/[^/]+\\(/\\.\\./?\\)" localname) 809 (when (string-match "^/[^/]+\\(/\\.\\./?\\)" localname)
810 (setq localname (replace-match "/" t t localname 1))) 810 (setq localname (replace-match "/" t t localname 1)))
811 (when (string-match "^/\\.\\./?" localname) 811 (when (string-match "^/\\.\\./?" localname)
@@ -886,10 +886,9 @@ file names."
886 (setq filename (directory-file-name (expand-file-name filename))) 886 (setq filename (directory-file-name (expand-file-name filename)))
887 (with-parsed-tramp-file-name filename nil 887 (with-parsed-tramp-file-name filename nil
888 (setq localname (tramp-compat-file-name-unquote localname)) 888 (setq localname (tramp-compat-file-name-unquote localname))
889 (if (or 889 (if (or (and (string-match "^\\(afp\\|davs?\\|smb\\)$" method)
890 (and (string-match "^\\(afp\\|smb\\)$" method) 890 (string-match "^/?\\([^/]+\\)$" localname))
891 (string-match "^/?\\([^/]+\\)$" localname)) 891 (string-equal localname "/"))
892 (string-equal localname "/"))
893 (tramp-gvfs-get-root-attributes filename) 892 (tramp-gvfs-get-root-attributes filename)
894 (assoc 893 (assoc
895 (file-name-nondirectory filename) 894 (file-name-nondirectory filename)
@@ -1326,36 +1325,50 @@ ADDRESS can have the form \"xx:xx:xx:xx:xx:xx\" or \"[xx:xx:xx:xx:xx:xx]\"."
1326 "Implementation for the \"org.gtk.vfs.MountOperation.askQuestion\" method." 1325 "Implementation for the \"org.gtk.vfs.MountOperation.askQuestion\" method."
1327 (save-window-excursion 1326 (save-window-excursion
1328 (let ((enable-recursive-minibuffers t) 1327 (let ((enable-recursive-minibuffers t)
1329 choice) 1328 (use-dialog-box (and use-dialog-box (null noninteractive)))
1329 result)
1330 1330
1331 (condition-case nil 1331 (with-parsed-tramp-file-name
1332 (with-parsed-tramp-file-name 1332 (tramp-gvfs-file-name (dbus-event-path-name last-input-event)) nil
1333 (tramp-gvfs-file-name (dbus-event-path-name last-input-event)) nil 1333 (tramp-message v 6 "%S %S" message choices)
1334 (tramp-message v 6 "%S %S" message choices) 1334
1335 1335 (setq result
1336 ;; In theory, there can be several choices. Until now, 1336 (condition-case nil
1337 ;; there is only the question whether to accept an unknown 1337 (list
1338 ;; host signature. 1338 t ;; handled.
1339 (with-temp-buffer 1339 nil ;; no abort of D-Bus.
1340 ;; Preserve message for `progress-reporter'. 1340 (with-tramp-connection-property
1341 (with-temp-message "" 1341 (tramp-get-connection-process v) message
1342 (insert message) 1342 ;; In theory, there can be several choices.
1343 (pop-to-buffer (current-buffer)) 1343 ;; Until now, there is only the question whether
1344 (setq choice (if (yes-or-no-p (concat (car choices) " ")) 0 1)) 1344 ;; to accept an unknown host signature.
1345 (tramp-message v 6 "%d" choice))) 1345 (with-temp-buffer
1346 1346 ;; Preserve message for `progress-reporter'.
1347 ;; When the choice is "no", we set a dummy fuse-mountpoint 1347 (with-temp-message ""
1348 ;; in order to leave the timeout. 1348 (insert message)
1349 (unless (zerop choice) 1349 (goto-char (point-max))
1350 (tramp-set-file-property v "/" "fuse-mountpoint" "/")) 1350 (if noninteractive
1351 1351 (message "%s" message)
1352 (list 1352 (pop-to-buffer (current-buffer)))
1353 t ;; handled. 1353 (if (yes-or-no-p
1354 nil ;; no abort of D-Bus. 1354 (concat
1355 choice)) 1355 (buffer-substring
1356 1356 (line-beginning-position) (point))
1357 ;; When QUIT is raised, we shall return this information to D-Bus. 1357 " "))
1358 (quit (list nil t 0)))))) 1358 0 1)))))
1359
1360 ;; When QUIT is raised, we shall return this
1361 ;; information to D-Bus.
1362 (quit (list nil t 1))))
1363
1364 (tramp-message v 6 "%s" result)
1365
1366 ;; When the choice is "no", we set a dummy fuse-mountpoint in
1367 ;; order to leave the timeout.
1368 (unless (zerop (cl-caddr result))
1369 (tramp-set-file-property v "/" "fuse-mountpoint" "/"))
1370
1371 result))))
1359 1372
1360(defun tramp-gvfs-handler-mounted-unmounted (mount-info) 1373(defun tramp-gvfs-handler-mounted-unmounted (mount-info)
1361 "Signal handler for the \"org.gtk.vfs.MountTracker.mounted\" and 1374 "Signal handler for the \"org.gtk.vfs.MountTracker.mounted\" and
@@ -1638,6 +1651,10 @@ connection if a previous connection has died for some reason."
1638 (string-equal localname "/")) 1651 (string-equal localname "/"))
1639 (tramp-error vec 'file-error "Filename must contain an AFP volume")) 1652 (tramp-error vec 'file-error "Filename must contain an AFP volume"))
1640 1653
1654 (when (and (string-match method "davs?")
1655 (string-equal localname "/"))
1656 (tramp-error vec 'file-error "Filename must contain a WebDAV share"))
1657
1641 (when (and (string-equal method "smb") 1658 (when (and (string-equal method "smb")
1642 (string-equal localname "/")) 1659 (string-equal localname "/"))
1643 (tramp-error vec 'file-error "Filename must contain a Windows share")) 1660 (tramp-error vec 'file-error "Filename must contain a Windows share"))
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index 6876f20d41c..28147c48d6c 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -2501,6 +2501,8 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
2501 (let ((method (file-remote-p tramp-test-temporary-file-directory 'method)) 2501 (let ((method (file-remote-p tramp-test-temporary-file-directory 'method))
2502 (host (file-remote-p tramp-test-temporary-file-directory 'host)) 2502 (host (file-remote-p tramp-test-temporary-file-directory 'host))
2503 (orig-syntax tramp-syntax)) 2503 (orig-syntax tramp-syntax))
2504 (when (and (stringp host) (string-match tramp-host-with-port-regexp host))
2505 (setq host (match-string 1 host)))
2504 2506
2505 (unwind-protect 2507 (unwind-protect
2506 (dolist 2508 (dolist