aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2013-08-01 13:10:31 +0200
committerMichael Albinus2013-08-01 13:10:31 +0200
commita43dc4243c667d2033a9e7fe5cc1d499b35a1651 (patch)
treef9cab97ff342267ad27a6032ec159d96460ec99c
parentfdb396e222923dc98d46c170381c6b33dc1e8d99 (diff)
downloademacs-a43dc4243c667d2033a9e7fe5cc1d499b35a1651.tar.gz
emacs-a43dc4243c667d2033a9e7fe5cc1d499b35a1651.zip
Complete file name handlers.
* net/tramp.el (tramp-handle-set-visited-file-modtime) (tramp-handle-verify-visited-file-modtime) (tramp-handle-file-notify-rm-watch): New functions. (tramp-call-process): Do not bind `default-directory'. * net/tramp-adb.el (tramp-adb-file-name-handler-alist): Order alphabetically. [access-file, add-name-to-file, dired-call-process]: [dired-compress-file, file-acl, file-notify-rm-watch]: [file-ownership-preserved-p, file-selinux-context]: [make-directory-internal, make-symbolic-link, set-file-acl]: [set-file-selinux-context, set-visited-file-modtime]: [verify-visited-file-modtime]: Add handler. (tramp-adb-handle-write-region): Apply `set-visited-file-modtime'. * net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist) [file-notify-add-watch, file-notify-rm-watch]: [set-file-times, set-visited-file-modtime]: [verify-visited-file-modtime]: Add handler. (with-tramp-gvfs-error-message) (tramp-gvfs-handle-set-visited-file-modtime) (tramp-gvfs-fuse-file-name): Remove. (tramp-gvfs-handle-file-notify-add-watch) (tramp-gvfs-file-gvfs-monitor-file-process-filter): New defuns. (tramp-gvfs-handle-write-region): Fix error in moving tmpfile. * net/tramp-sh.el (tramp-sh-file-name-handler-alist): Order alphabetically. [file-notify-rm-watch ]: Use default Tramp handler. [executable-find]: Remove private handler. (tramp-do-copy-or-rename-file-out-of-band): Do not bind `default-directory'. (tramp-sh-handle-executable-find) (tramp-sh-handle-file-notify-rm-watch): Remove functions. (tramp-sh-file-gvfs-monitor-dir-process-filter) (tramp-sh-file-inotifywait-process-filter, tramp-set-remote-path): Do not use `format' in `tramp-message'. * net/tramp-smb.el (tramp-smb-file-name-handler-alist) [file-notify-rm-watch, set-visited-file-modtime]: [verify-visited-file-modtime]: Add handler. (tramp-smb-call-winexe): Do not bind `default-directory'.
-rw-r--r--lisp/ChangeLog47
-rw-r--r--lisp/net/tramp-adb.el86
-rw-r--r--lisp/net/tramp-gvfs.el136
-rw-r--r--lisp/net/tramp-sh.el137
-rw-r--r--lisp/net/tramp-smb.el19
-rw-r--r--lisp/net/tramp.el88
6 files changed, 318 insertions, 195 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 4a7e0e13bd1..e80c34d3842 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,50 @@
12013-08-01 Michael Albinus <michael.albinus@gmx.de>
2
3 Complete file name handlers.
4
5 * net/tramp.el (tramp-handle-set-visited-file-modtime)
6 (tramp-handle-verify-visited-file-modtime)
7 (tramp-handle-file-notify-rm-watch): New functions.
8 (tramp-call-process): Do not bind `default-directory'.
9
10 * net/tramp-adb.el (tramp-adb-file-name-handler-alist): Order
11 alphabetically.
12 [access-file, add-name-to-file, dired-call-process]:
13 [dired-compress-file, file-acl, file-notify-rm-watch]:
14 [file-ownership-preserved-p, file-selinux-context]:
15 [make-directory-internal, make-symbolic-link, set-file-acl]:
16 [set-file-selinux-context, set-visited-file-modtime]:
17 [verify-visited-file-modtime]: Add handler.
18 (tramp-adb-handle-write-region): Apply `set-visited-file-modtime'.
19
20 * net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist)
21 [file-notify-add-watch, file-notify-rm-watch]:
22 [set-file-times, set-visited-file-modtime]:
23 [verify-visited-file-modtime]: Add handler.
24 (with-tramp-gvfs-error-message)
25 (tramp-gvfs-handle-set-visited-file-modtime)
26 (tramp-gvfs-fuse-file-name): Remove.
27 (tramp-gvfs-handle-file-notify-add-watch)
28 (tramp-gvfs-file-gvfs-monitor-file-process-filter): New defuns.
29 (tramp-gvfs-handle-write-region): Fix error in moving tmpfile.
30
31 * net/tramp-sh.el (tramp-sh-file-name-handler-alist): Order
32 alphabetically.
33 [file-notify-rm-watch ]: Use default Tramp handler.
34 [executable-find]: Remove private handler.
35 (tramp-do-copy-or-rename-file-out-of-band): Do not bind
36 `default-directory'.
37 (tramp-sh-handle-executable-find)
38 (tramp-sh-handle-file-notify-rm-watch): Remove functions.
39 (tramp-sh-file-gvfs-monitor-dir-process-filter)
40 (tramp-sh-file-inotifywait-process-filter, tramp-set-remote-path):
41 Do not use `format' in `tramp-message'.
42
43 * net/tramp-smb.el (tramp-smb-file-name-handler-alist)
44 [file-notify-rm-watch, set-visited-file-modtime]:
45 [verify-visited-file-modtime]: Add handler.
46 (tramp-smb-call-winexe): Do not bind `default-directory'.
47
12013-08-01 Xue Fuqiao <xfq.free@gmail.com> 482013-08-01 Xue Fuqiao <xfq.free@gmail.com>
2 49
3 * vc/vc-hooks.el (vc-menu-map): Fix menu entry for vc-ignore. 50 * vc/vc-hooks.el (vc-menu-map): Fix menu entry for vc-ignore.
diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el
index 82b017fa230..33e9e5aa44b 100644
--- a/lisp/net/tramp-adb.el
+++ b/lisp/net/tramp-adb.el
@@ -85,53 +85,74 @@
85 (cons 'tramp-adb-file-name-p 'tramp-adb-file-name-handler)) 85 (cons 'tramp-adb-file-name-p 'tramp-adb-file-name-handler))
86 86
87(defconst tramp-adb-file-name-handler-alist 87(defconst tramp-adb-file-name-handler-alist
88 '((directory-file-name . tramp-handle-directory-file-name) 88 '((access-file . ignore)
89 (add-name-to-file . tramp-adb-handle-copy-file)
90 ;; `byte-compiler-base-file-name' performed by default handler.
91 ;; `copy-directory' performed by default handler.
92 (copy-file . tramp-adb-handle-copy-file)
93 (delete-directory . tramp-adb-handle-delete-directory)
94 (delete-file . tramp-adb-handle-delete-file)
95 ;; `diff-latest-backup-file' performed by default handler.
96 (directory-file-name . tramp-handle-directory-file-name)
97 (directory-files . tramp-handle-directory-files)
98 (directory-files-and-attributes
99 . tramp-adb-handle-directory-files-and-attributes)
100 (dired-call-process . ignore)
101 (dired-compress-file . ignore)
89 (dired-uncache . tramp-handle-dired-uncache) 102 (dired-uncache . tramp-handle-dired-uncache)
103 (expand-file-name . tramp-adb-handle-expand-file-name)
104 (file-accessible-directory-p . tramp-handle-file-accessible-directory-p)
105 (file-acl . ignore)
106 (file-attributes . tramp-adb-handle-file-attributes)
107 (file-directory-p . tramp-adb-handle-file-directory-p)
108 ;; `file-equal-p' performed by default handler.
109 ;; FIXME: This is too sloppy.
110 (file-executable-p . tramp-handle-file-exists-p)
111 (file-exists-p . tramp-handle-file-exists-p)
112 ;; `file-in-directory-p' performed by default handler.
113 (file-local-copy . tramp-adb-handle-file-local-copy)
114 (file-modes . tramp-handle-file-modes)
115 (file-name-all-completions . tramp-adb-handle-file-name-all-completions)
90 (file-name-as-directory . tramp-handle-file-name-as-directory) 116 (file-name-as-directory . tramp-handle-file-name-as-directory)
91 (file-name-completion . tramp-handle-file-name-completion) 117 (file-name-completion . tramp-handle-file-name-completion)
92 (file-name-all-completions . tramp-adb-handle-file-name-all-completions)
93 (file-attributes . tramp-adb-handle-file-attributes)
94 (file-name-directory . tramp-handle-file-name-directory) 118 (file-name-directory . tramp-handle-file-name-directory)
95 (file-name-nondirectory . tramp-handle-file-name-nondirectory) 119 (file-name-nondirectory . tramp-handle-file-name-nondirectory)
96 (file-truename . tramp-adb-handle-file-truename) 120 ;; `file-name-sans-versions' performed by default handler.
97 (file-newer-than-file-p . tramp-handle-file-newer-than-file-p) 121 (file-newer-than-file-p . tramp-handle-file-newer-than-file-p)
98 (file-name-as-directory . tramp-handle-file-name-as-directory) 122 (file-notify-add-watch . tramp-handle-file-notify-add-watch)
123 (file-notify-rm-watch . tramp-handle-file-notify-rm-watch)
124 (file-ownership-preserved-p . ignore)
125 (file-readable-p . tramp-handle-file-exists-p)
99 (file-regular-p . tramp-handle-file-regular-p) 126 (file-regular-p . tramp-handle-file-regular-p)
100 (file-remote-p . tramp-handle-file-remote-p) 127 (file-remote-p . tramp-handle-file-remote-p)
101 (file-accessible-directory-p . tramp-handle-file-accessible-directory-p) 128 (file-selinux-context . ignore)
102 (file-directory-p . tramp-adb-handle-file-directory-p)
103 (file-symlink-p . tramp-handle-file-symlink-p) 129 (file-symlink-p . tramp-handle-file-symlink-p)
104 ;; FIXME: This is too sloppy. 130 (file-truename . tramp-adb-handle-file-truename)
105 (file-executable-p . tramp-handle-file-exists-p)
106 (file-exists-p . tramp-handle-file-exists-p)
107 (file-readable-p . tramp-handle-file-exists-p)
108 (file-writable-p . tramp-adb-handle-file-writable-p) 131 (file-writable-p . tramp-adb-handle-file-writable-p)
109 (file-local-copy . tramp-adb-handle-file-local-copy)
110 (file-modes . tramp-handle-file-modes)
111 (file-notify-add-watch . tramp-handle-file-notify-add-watch)
112 (file-notify-rm-watch . ignore)
113 (expand-file-name . tramp-adb-handle-expand-file-name)
114 (find-backup-file-name . tramp-handle-find-backup-file-name) 132 (find-backup-file-name . tramp-handle-find-backup-file-name)
115 (directory-files . tramp-handle-directory-files) 133 ;; `find-file-noselect' performed by default handler.
116 (directory-files-and-attributes 134 ;; `get-file-buffer' performed by default handler.
117 . tramp-adb-handle-directory-files-and-attributes)
118 (make-directory . tramp-adb-handle-make-directory)
119 (delete-directory . tramp-adb-handle-delete-directory)
120 (delete-file . tramp-adb-handle-delete-file)
121 (load . tramp-handle-load)
122 (insert-directory . tramp-adb-handle-insert-directory) 135 (insert-directory . tramp-adb-handle-insert-directory)
123 (insert-file-contents . tramp-handle-insert-file-contents) 136 (insert-file-contents . tramp-handle-insert-file-contents)
124 (substitute-in-file-name . tramp-handle-substitute-in-file-name) 137 (load . tramp-handle-load)
125 (unhandled-file-name-directory . tramp-handle-unhandled-file-name-directory) 138 ;; `make-auto-save-file-name' performed by default handler.
126 (vc-registered . ignore) ;no vc control files on Android devices 139 (make-directory . tramp-adb-handle-make-directory)
127 (write-region . tramp-adb-handle-write-region) 140 (make-directory-internal . ignore)
141 (make-symbolic-link . ignore)
142 (process-file . tramp-adb-handle-process-file)
143 (rename-file . tramp-adb-handle-rename-file)
144 (set-file-acl . ignore)
128 (set-file-modes . tramp-adb-handle-set-file-modes) 145 (set-file-modes . tramp-adb-handle-set-file-modes)
146 (set-file-selinux-context . ignore)
129 (set-file-times . tramp-adb-handle-set-file-times) 147 (set-file-times . tramp-adb-handle-set-file-times)
130 (copy-file . tramp-adb-handle-copy-file) 148 (set-visited-file-modtime . tramp-handle-set-visited-file-modtime)
131 (rename-file . tramp-adb-handle-rename-file)
132 (process-file . tramp-adb-handle-process-file)
133 (shell-command . tramp-adb-handle-shell-command) 149 (shell-command . tramp-adb-handle-shell-command)
134 (start-file-process . tramp-adb-handle-start-file-process)) 150 (start-file-process . tramp-adb-handle-start-file-process)
151 (substitute-in-file-name . tramp-handle-substitute-in-file-name)
152 (unhandled-file-name-directory . tramp-handle-unhandled-file-name-directory)
153 (vc-registered . ignore)
154 (verify-visited-file-modtime . tramp-handle-verify-visited-file-modtime)
155 (write-region . tramp-adb-handle-write-region))
135 "Alist of handler functions for Tramp ADB method.") 156 "Alist of handler functions for Tramp ADB method.")
136 157
137;; It must be a `defsubst' in order to push the whole code into 158;; It must be a `defsubst' in order to push the whole code into
@@ -599,6 +620,9 @@ But handle the case, if the \"test\" command is not available."
599 (tramp-error v 'file-error "Cannot write: `%s' filename")) 620 (tramp-error v 'file-error "Cannot write: `%s' filename"))
600 (delete-file tmpfile))) 621 (delete-file tmpfile)))
601 622
623 (when (or (eq visit t) (stringp visit))
624 (set-visited-file-modtime))
625
602 (unless (equal curbuf (current-buffer)) 626 (unless (equal curbuf (current-buffer))
603 (tramp-error 627 (tramp-error
604 v 'file-error 628 v 'file-error
diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el
index e25c9bd4caf..5bb30b04643 100644
--- a/lisp/net/tramp-gvfs.el
+++ b/lisp/net/tramp-gvfs.el
@@ -403,10 +403,10 @@ Every entry is a list (NAME ADDRESS).")
403 403
404;; New handlers should be added here. 404;; New handlers should be added here.
405(defconst tramp-gvfs-file-name-handler-alist 405(defconst tramp-gvfs-file-name-handler-alist
406 '( 406 '((access-file . ignore)
407 (access-file . ignore)
408 (add-name-to-file . tramp-gvfs-handle-copy-file) 407 (add-name-to-file . tramp-gvfs-handle-copy-file)
409 ;; `byte-compiler-base-file-name' performed by default handler. 408 ;; `byte-compiler-base-file-name' performed by default handler.
409 ;; `copy-directory' performed by default handler.
410 (copy-file . tramp-gvfs-handle-copy-file) 410 (copy-file . tramp-gvfs-handle-copy-file)
411 (delete-directory . tramp-gvfs-handle-delete-directory) 411 (delete-directory . tramp-gvfs-handle-delete-directory)
412 (delete-file . tramp-gvfs-handle-delete-file) 412 (delete-file . tramp-gvfs-handle-delete-file)
@@ -418,14 +418,15 @@ Every entry is a list (NAME ADDRESS).")
418 (dired-call-process . ignore) 418 (dired-call-process . ignore)
419 (dired-compress-file . ignore) 419 (dired-compress-file . ignore)
420 (dired-uncache . tramp-handle-dired-uncache) 420 (dired-uncache . tramp-handle-dired-uncache)
421 ;; `executable-find' is not official yet. performed by default handler.
422 (expand-file-name . tramp-gvfs-handle-expand-file-name) 421 (expand-file-name . tramp-gvfs-handle-expand-file-name)
423 (file-accessible-directory-p . tramp-handle-file-accessible-directory-p) 422 (file-accessible-directory-p . tramp-handle-file-accessible-directory-p)
424 (file-acl . ignore) 423 (file-acl . ignore)
425 (file-attributes . tramp-gvfs-handle-file-attributes) 424 (file-attributes . tramp-gvfs-handle-file-attributes)
426 (file-directory-p . tramp-gvfs-handle-file-directory-p) 425 (file-directory-p . tramp-gvfs-handle-file-directory-p)
426 ;; `file-equal-p' performed by default handler.
427 (file-executable-p . tramp-gvfs-handle-file-executable-p) 427 (file-executable-p . tramp-gvfs-handle-file-executable-p)
428 (file-exists-p . tramp-handle-file-exists-p) 428 (file-exists-p . tramp-handle-file-exists-p)
429 ;; `file-in-directory-p' performed by default handler.
429 (file-local-copy . tramp-gvfs-handle-file-local-copy) 430 (file-local-copy . tramp-gvfs-handle-file-local-copy)
430 (file-modes . tramp-handle-file-modes) 431 (file-modes . tramp-handle-file-modes)
431 (file-name-all-completions . tramp-gvfs-handle-file-name-all-completions) 432 (file-name-all-completions . tramp-gvfs-handle-file-name-all-completions)
@@ -435,8 +436,8 @@ Every entry is a list (NAME ADDRESS).")
435 (file-name-nondirectory . tramp-handle-file-name-nondirectory) 436 (file-name-nondirectory . tramp-handle-file-name-nondirectory)
436 ;; `file-name-sans-versions' performed by default handler. 437 ;; `file-name-sans-versions' performed by default handler.
437 (file-newer-than-file-p . tramp-handle-file-newer-than-file-p) 438 (file-newer-than-file-p . tramp-handle-file-newer-than-file-p)
438 (file-notify-add-watch . tramp-handle-file-notify-add-watch) 439 (file-notify-add-watch . tramp-gvfs-handle-file-notify-add-watch)
439 (file-notify-rm-watch . ignore) 440 (file-notify-rm-watch . tramp-handle-file-notify-rm-watch)
440 (file-ownership-preserved-p . ignore) 441 (file-ownership-preserved-p . ignore)
441 (file-readable-p . tramp-gvfs-handle-file-readable-p) 442 (file-readable-p . tramp-gvfs-handle-file-readable-p)
442 (file-regular-p . tramp-handle-file-regular-p) 443 (file-regular-p . tramp-handle-file-regular-p)
@@ -451,6 +452,7 @@ Every entry is a list (NAME ADDRESS).")
451 (insert-directory . tramp-gvfs-handle-insert-directory) 452 (insert-directory . tramp-gvfs-handle-insert-directory)
452 (insert-file-contents . tramp-gvfs-handle-insert-file-contents) 453 (insert-file-contents . tramp-gvfs-handle-insert-file-contents)
453 (load . tramp-handle-load) 454 (load . tramp-handle-load)
455 ;; `make-auto-save-file-name' performed by default handler.
454 (make-directory . tramp-gvfs-handle-make-directory) 456 (make-directory . tramp-gvfs-handle-make-directory)
455 (make-directory-internal . ignore) 457 (make-directory-internal . ignore)
456 (make-symbolic-link . ignore) 458 (make-symbolic-link . ignore)
@@ -459,15 +461,15 @@ Every entry is a list (NAME ADDRESS).")
459 (set-file-acl . ignore) 461 (set-file-acl . ignore)
460 (set-file-modes . ignore) 462 (set-file-modes . ignore)
461 (set-file-selinux-context . ignore) 463 (set-file-selinux-context . ignore)
462 (set-visited-file-modtime . tramp-gvfs-handle-set-visited-file-modtime) 464 (set-file-times . ignore)
465 (set-visited-file-modtime . tramp-handle-set-visited-file-modtime)
463 (shell-command . ignore) 466 (shell-command . ignore)
464 (start-file-process . ignore) 467 (start-file-process . ignore)
465 (substitute-in-file-name . tramp-handle-substitute-in-file-name) 468 (substitute-in-file-name . tramp-handle-substitute-in-file-name)
466 (unhandled-file-name-directory . tramp-handle-unhandled-file-name-directory) 469 (unhandled-file-name-directory . tramp-handle-unhandled-file-name-directory)
467 (vc-registered . ignore) 470 (vc-registered . ignore)
468 ;; `verify-visited-file-modtime' performed by default handler. 471 (verify-visited-file-modtime . tramp-handle-verify-visited-file-modtime)
469 (write-region . tramp-gvfs-handle-write-region) 472 (write-region . tramp-gvfs-handle-write-region))
470)
471 "Alist of handler functions for Tramp GVFS method. 473 "Alist of handler functions for Tramp GVFS method.
472Operations not mentioned here will be handled by the default Emacs primitives.") 474Operations not mentioned here will be handled by the default Emacs primitives.")
473 475
@@ -555,28 +557,6 @@ will be traced by Tramp with trace level 6."
555(tramp-compat-font-lock-add-keywords 557(tramp-compat-font-lock-add-keywords
556 'emacs-lisp-mode '("\\<with-tramp-dbus-call-method\\>")) 558 'emacs-lisp-mode '("\\<with-tramp-dbus-call-method\\>"))
557 559
558(defmacro with-tramp-gvfs-error-message (filename handler &rest args)
559 "Apply a Tramp GVFS `handler'.
560In case of an error, modify the error message by replacing
561`filename' with its GVFS mounted name."
562 `(let ((fuse-file-name (regexp-quote (tramp-gvfs-fuse-file-name ,filename)))
563 elt)
564 (condition-case err
565 (tramp-compat-funcall ,handler ,@args)
566 (error
567 (setq elt (cdr err))
568 (while elt
569 (when (and (stringp (car elt))
570 (string-match fuse-file-name (car elt)))
571 (setcar elt (replace-match ,filename t t (car elt))))
572 (setq elt (cdr elt)))
573 (signal (car err) (cdr err))))))
574
575(put 'with-tramp-gvfs-error-message 'lisp-indent-function 2)
576(put 'with-tramp-gvfs-error-message 'edebug-form-spec '(form symbolp body))
577(tramp-compat-font-lock-add-keywords
578 'emacs-lisp-mode '("\\<with-tramp-gvfs-error-message\\>"))
579
580(defvar tramp-gvfs-dbus-event-vector nil 560(defvar tramp-gvfs-dbus-event-vector nil
581 "Current Tramp file name to be used, as vector. 561 "Current Tramp file name to be used, as vector.
582It is needed when D-Bus signals or errors arrive, because there 562It is needed when D-Bus signals or errors arrive, because there
@@ -943,6 +923,64 @@ is no information where to trace the message.")
943 v (concat localname filename) 923 v (concat localname filename)
944 "file-name-all-completions" result)))))))) 924 "file-name-all-completions" result))))))))
945 925
926(defun tramp-gvfs-handle-file-notify-add-watch (file-name flags callback)
927 "Like `file-notify-add-watch' for Tramp files."
928 (setq file-name (expand-file-name file-name))
929 (with-parsed-tramp-file-name file-name nil
930 (let ((p (start-process
931 "gvfs-monitor-file" (generate-new-buffer " *gvfs-monitor-file*")
932 "gvfs-monitor-file" (tramp-gvfs-url-file-name file-name))))
933 (if (not (processp p))
934 (tramp-error
935 v 'file-notify-error "gvfs-monitor-file failed to start")
936 (tramp-compat-set-process-query-on-exit-flag p nil)
937 (set-process-filter p 'tramp-gvfs-file-gvfs-monitor-file-process-filter)
938 (with-current-buffer (process-buffer p)
939 (setq default-directory (file-name-directory file-name)))
940 p))))
941
942(defun tramp-gvfs-file-gvfs-monitor-file-process-filter (proc string)
943 "Read output from \"gvfs-monitor-file\" and add corresponding file-notify events."
944 (let* ((rest-string (tramp-compat-process-get proc 'rest-string))
945 (dd (with-current-buffer (process-buffer proc) default-directory))
946 (ddu (regexp-quote (tramp-gvfs-url-file-name dd))))
947 (when rest-string
948 (tramp-message proc 10 "Previous string:\n%s" rest-string))
949 (tramp-message proc 6 "%S\n%s" proc string)
950 (setq string (concat rest-string string)
951 ;; Attribute change is returned in unused wording.
952 string (replace-regexp-in-string
953 "ATTRIB CHANGED" "ATTRIBUTE_CHANGED" string))
954
955 (while (string-match
956 (concat "^[\n\r]*"
957 "File Monitor Event:[\n\r]+"
958 "File = \\([^\n\r]+\\)[\n\r]+"
959 "Event = \\([^[:blank:]]+\\)[\n\r]+")
960 string)
961 (let ((action (intern-soft
962 (replace-regexp-in-string
963 "_" "-" (downcase (match-string 2 string)))))
964 (file (match-string 1 string)))
965 (setq string (replace-match "" nil nil string))
966 ;; File names are returned as URL paths. We must convert them.
967 (when (string-match ddu file)
968 (setq file (replace-match dd nil nil file)))
969 (while (string-match "%\\([0-9A-F]\\{2\\}\\)" file)
970 (setq file
971 (replace-match
972 (char-to-string (string-to-number (match-string 1 file) 16))
973 nil nil file)))
974 ;; Usually, we would add an Emacs event now. Unfortunately,
975 ;; `unread-command-events' does not accept several events at
976 ;; once. Therefore, we apply the callback directly.
977 (tramp-compat-funcall 'file-notify-callback (list proc action file))))
978
979 ;; Save rest of the string.
980 (when (zerop (length string)) (setq string nil))
981 (when string (tramp-message proc 10 "Rest string:\n%s" string))
982 (tramp-compat-process-put proc 'rest-string string)))
983
946(defun tramp-gvfs-handle-file-readable-p (filename) 984(defun tramp-gvfs-handle-file-readable-p (filename)
947 "Like `file-readable-p' for Tramp files." 985 "Like `file-readable-p' for Tramp files."
948 (with-parsed-tramp-file-name filename nil 986 (with-parsed-tramp-file-name filename nil
@@ -1054,22 +1092,6 @@ is no information where to trace the message.")
1054 (tramp-flush-file-property v (file-name-directory localname)) 1092 (tramp-flush-file-property v (file-name-directory localname))
1055 (tramp-flush-file-property v localname)))))) 1093 (tramp-flush-file-property v localname))))))
1056 1094
1057(defun tramp-gvfs-handle-set-visited-file-modtime (&optional time-list)
1058 "Like `set-visited-file-modtime' for Tramp files."
1059 (unless (buffer-file-name)
1060 (error "Can't set-visited-file-modtime: buffer `%s' not visiting a file"
1061 (buffer-name)))
1062 (unless time-list
1063 (let ((f (buffer-file-name)))
1064 (with-parsed-tramp-file-name f nil
1065 (let ((remote-file-name-inhibit-cache t)
1066 (attr (file-attributes f)))
1067 ;; '(-1 65535) means file doesn't exists yet.
1068 (setq time-list (or (nth 5 attr) '(-1 65535)))))))
1069 ;; We use '(0 0) as a don't-know value.
1070 (unless (not (equal time-list '(0 0)))
1071 (tramp-run-real-handler 'set-visited-file-modtime (list time-list))))
1072
1073(defun tramp-gvfs-handle-write-region 1095(defun tramp-gvfs-handle-write-region
1074 (start end filename &optional append visit lockname confirm) 1096 (start end filename &optional append visit lockname confirm)
1075 "Like `write-region' for Tramp files." 1097 "Like `write-region' for Tramp files."
@@ -1082,7 +1104,7 @@ is no information where to trace the message.")
1082 (let ((tmpfile (tramp-compat-make-temp-file filename))) 1104 (let ((tmpfile (tramp-compat-make-temp-file filename)))
1083 (write-region start end tmpfile) 1105 (write-region start end tmpfile)
1084 (condition-case nil 1106 (condition-case nil
1085 (rename-file tmpfile filename) 1107 (rename-file tmpfile filename 'ok-if-already-exists)
1086 (error 1108 (error
1087 (delete-file tmpfile) 1109 (delete-file tmpfile)
1088 (tramp-error 1110 (tramp-error
@@ -1137,24 +1159,6 @@ is no information where to trace the message.")
1137 (dbus-unescape-from-identifier 1159 (dbus-unescape-from-identifier
1138 (replace-regexp-in-string "^.*/\\([^/]+\\)$" "\\1" object-path))) 1160 (replace-regexp-in-string "^.*/\\([^/]+\\)$" "\\1" object-path)))
1139 1161
1140(defun tramp-gvfs-fuse-file-name (filename)
1141 "Return FUSE file name, which is directly accessible."
1142 (with-parsed-tramp-file-name (expand-file-name filename) nil
1143 (tramp-gvfs-maybe-open-connection v)
1144 (let ((prefix (tramp-get-file-property v "/" "prefix" ""))
1145 (fuse-mountpoint
1146 (tramp-get-file-property v "/" "fuse-mountpoint" nil)))
1147 (unless fuse-mountpoint
1148 (tramp-error
1149 v 'file-error "There is no FUSE mount point for `%s'" filename))
1150 ;; We must hide the prefix, if any.
1151 (when (string-match (concat "^" (regexp-quote prefix)) localname)
1152 (setq localname (replace-match "" t t localname)))
1153 (tramp-message
1154 v 10 "remote file `%s' is local file `%s'"
1155 filename (concat fuse-mountpoint localname))
1156 (concat fuse-mountpoint localname))))
1157
1158(defun tramp-bluez-address (device) 1162(defun tramp-bluez-address (device)
1159 "Return bluetooth device address from a given bluetooth DEVICE name." 1163 "Return bluetooth device address from a given bluetooth DEVICE name."
1160 (when (stringp device) 1164 (when (stringp device)
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index 441849fd2af..f9e68d0dad0 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -801,73 +801,78 @@ existence, and file readability. Input shall be read via
801here-document, otherwise the command could exceed maximum length 801here-document, otherwise the command could exceed maximum length
802of command line.") 802of command line.")
803 803
804;; New handlers should be added here. The following operations can be 804;; New handlers should be added here.
805;; handled using the normal primitives: file-name-sans-versions,
806;; get-file-buffer.
807(defconst tramp-sh-file-name-handler-alist 805(defconst tramp-sh-file-name-handler-alist
808 '((load . tramp-handle-load) 806 '(;; `access-file' performed by default handler.
809 (make-symbolic-link . tramp-sh-handle-make-symbolic-link)
810 (file-name-as-directory . tramp-handle-file-name-as-directory)
811 (file-name-directory . tramp-handle-file-name-directory)
812 (file-name-nondirectory . tramp-handle-file-name-nondirectory)
813 (file-truename . tramp-sh-handle-file-truename)
814 (file-exists-p . tramp-sh-handle-file-exists-p)
815 (file-accessible-directory-p . tramp-handle-file-accessible-directory-p)
816 (file-directory-p . tramp-sh-handle-file-directory-p)
817 (file-executable-p . tramp-sh-handle-file-executable-p)
818 (file-readable-p . tramp-sh-handle-file-readable-p)
819 (file-regular-p . tramp-handle-file-regular-p)
820 (file-symlink-p . tramp-handle-file-symlink-p)
821 (file-writable-p . tramp-sh-handle-file-writable-p)
822 (file-ownership-preserved-p . tramp-sh-handle-file-ownership-preserved-p)
823 (file-newer-than-file-p . tramp-sh-handle-file-newer-than-file-p)
824 (file-attributes . tramp-sh-handle-file-attributes)
825 (file-modes . tramp-handle-file-modes)
826 (directory-files . tramp-handle-directory-files)
827 (directory-files-and-attributes
828 . tramp-sh-handle-directory-files-and-attributes)
829 (file-name-all-completions . tramp-sh-handle-file-name-all-completions)
830 (file-name-completion . tramp-handle-file-name-completion)
831 (add-name-to-file . tramp-sh-handle-add-name-to-file) 807 (add-name-to-file . tramp-sh-handle-add-name-to-file)
832 (copy-file . tramp-sh-handle-copy-file) 808 ;; `byte-compiler-base-file-name' performed by default handler.
833 (copy-directory . tramp-sh-handle-copy-directory) 809 (copy-directory . tramp-sh-handle-copy-directory)
834 (rename-file . tramp-sh-handle-rename-file) 810 (copy-file . tramp-sh-handle-copy-file)
835 (set-file-modes . tramp-sh-handle-set-file-modes)
836 (set-file-times . tramp-sh-handle-set-file-times)
837 (make-directory . tramp-sh-handle-make-directory)
838 (delete-directory . tramp-sh-handle-delete-directory) 811 (delete-directory . tramp-sh-handle-delete-directory)
839 (delete-file . tramp-sh-handle-delete-file) 812 (delete-file . tramp-sh-handle-delete-file)
813 ;; `diff-latest-backup-file' performed by default handler.
840 (directory-file-name . tramp-handle-directory-file-name) 814 (directory-file-name . tramp-handle-directory-file-name)
841 ;; `executable-find' is not official yet. 815 (directory-files . tramp-handle-directory-files)
842 (executable-find . tramp-sh-handle-executable-find) 816 (directory-files-and-attributes
843 (start-file-process . tramp-sh-handle-start-file-process) 817 . tramp-sh-handle-directory-files-and-attributes)
844 (process-file . tramp-sh-handle-process-file) 818 ;; `dired-call-process' performed by default handler.
845 (shell-command . tramp-handle-shell-command) 819 (dired-compress-file . tramp-sh-handle-dired-compress-file)
846 (insert-directory . tramp-sh-handle-insert-directory) 820 (dired-recursive-delete-directory
821 . tramp-sh-handle-dired-recursive-delete-directory)
822 (dired-uncache . tramp-handle-dired-uncache)
847 (expand-file-name . tramp-sh-handle-expand-file-name) 823 (expand-file-name . tramp-sh-handle-expand-file-name)
848 (substitute-in-file-name . tramp-handle-substitute-in-file-name) 824 (file-accessible-directory-p . tramp-handle-file-accessible-directory-p)
825 (file-acl . tramp-sh-handle-file-acl)
826 (file-attributes . tramp-sh-handle-file-attributes)
827 (file-directory-p . tramp-sh-handle-file-directory-p)
828 ;; `file-equal-p' performed by default handler.
829 (file-executable-p . tramp-sh-handle-file-executable-p)
830 (file-exists-p . tramp-sh-handle-file-exists-p)
831 ;; `file-in-directory-p' performed by default handler.
849 (file-local-copy . tramp-sh-handle-file-local-copy) 832 (file-local-copy . tramp-sh-handle-file-local-copy)
833 (file-modes . tramp-handle-file-modes)
834 (file-name-all-completions . tramp-sh-handle-file-name-all-completions)
835 (file-name-as-directory . tramp-handle-file-name-as-directory)
836 (file-name-completion . tramp-handle-file-name-completion)
837 (file-name-directory . tramp-handle-file-name-directory)
838 (file-name-nondirectory . tramp-handle-file-name-nondirectory)
839 ;; `file-name-sans-versions' performed by default handler.
840 (file-newer-than-file-p . tramp-sh-handle-file-newer-than-file-p)
841 (file-notify-add-watch . tramp-sh-handle-file-notify-add-watch)
842 (file-notify-rm-watch . tramp-handle-file-notify-rm-watch)
843 (file-ownership-preserved-p . tramp-sh-handle-file-ownership-preserved-p)
844 (file-readable-p . tramp-sh-handle-file-readable-p)
845 (file-regular-p . tramp-handle-file-regular-p)
850 (file-remote-p . tramp-handle-file-remote-p) 846 (file-remote-p . tramp-handle-file-remote-p)
847 (file-selinux-context . tramp-sh-handle-file-selinux-context)
848 (file-symlink-p . tramp-handle-file-symlink-p)
849 (file-truename . tramp-sh-handle-file-truename)
850 (file-writable-p . tramp-sh-handle-file-writable-p)
851 (find-backup-file-name . tramp-handle-find-backup-file-name)
852 ;; `find-file-noselect' performed by default handler.
853 ;; `get-file-buffer' performed by default handler.
854 (insert-directory . tramp-sh-handle-insert-directory)
851 (insert-file-contents . tramp-handle-insert-file-contents) 855 (insert-file-contents . tramp-handle-insert-file-contents)
852 (insert-file-contents-literally 856 (insert-file-contents-literally
853 . tramp-sh-handle-insert-file-contents-literally) 857 . tramp-sh-handle-insert-file-contents-literally)
854 (write-region . tramp-sh-handle-write-region) 858 (load . tramp-handle-load)
855 (find-backup-file-name . tramp-handle-find-backup-file-name)
856 (make-auto-save-file-name . tramp-sh-handle-make-auto-save-file-name) 859 (make-auto-save-file-name . tramp-sh-handle-make-auto-save-file-name)
857 (unhandled-file-name-directory . tramp-handle-unhandled-file-name-directory) 860 (make-directory . tramp-sh-handle-make-directory)
858 (dired-compress-file . tramp-sh-handle-dired-compress-file) 861 (make-symbolic-link . tramp-sh-handle-make-symbolic-link)
859 (dired-recursive-delete-directory 862 (process-file . tramp-sh-handle-process-file)
860 . tramp-sh-handle-dired-recursive-delete-directory) 863 (rename-file . tramp-sh-handle-rename-file)
861 (dired-uncache . tramp-handle-dired-uncache)
862 (set-visited-file-modtime . tramp-sh-handle-set-visited-file-modtime)
863 (verify-visited-file-modtime . tramp-sh-handle-verify-visited-file-modtime)
864 (file-selinux-context . tramp-sh-handle-file-selinux-context)
865 (set-file-selinux-context . tramp-sh-handle-set-file-selinux-context)
866 (file-acl . tramp-sh-handle-file-acl)
867 (set-file-acl . tramp-sh-handle-set-file-acl) 864 (set-file-acl . tramp-sh-handle-set-file-acl)
865 (set-file-modes . tramp-sh-handle-set-file-modes)
866 (set-file-selinux-context . tramp-sh-handle-set-file-selinux-context)
867 (set-file-times . tramp-sh-handle-set-file-times)
868 (set-visited-file-modtime . tramp-sh-handle-set-visited-file-modtime)
869 (shell-command . tramp-handle-shell-command)
870 (start-file-process . tramp-sh-handle-start-file-process)
871 (substitute-in-file-name . tramp-handle-substitute-in-file-name)
872 (unhandled-file-name-directory . tramp-handle-unhandled-file-name-directory)
868 (vc-registered . tramp-sh-handle-vc-registered) 873 (vc-registered . tramp-sh-handle-vc-registered)
869 (file-notify-add-watch . tramp-sh-handle-file-notify-add-watch) 874 (verify-visited-file-modtime . tramp-sh-handle-verify-visited-file-modtime)
870 (file-notify-rm-watch . tramp-sh-handle-file-notify-rm-watch)) 875 (write-region . tramp-sh-handle-write-region))
871 "Alist of handler functions. 876 "Alist of handler functions.
872Operations not mentioned here will be handled by the normal Emacs functions.") 877Operations not mentioned here will be handled by the normal Emacs functions.")
873 878
@@ -2284,9 +2289,7 @@ The method used must be an out-of-band method."
2284 (tramp-get-method-parameter method 'tramp-copy-env)))) 2289 (tramp-get-method-parameter method 'tramp-copy-env))))
2285 2290
2286 ;; Check for program. 2291 ;; Check for program.
2287 (unless (let ((default-directory 2292 (unless (executable-find copy-program)
2288 (tramp-compat-temporary-file-directory)))
2289 (executable-find copy-program))
2290 (tramp-error 2293 (tramp-error
2291 v 'file-error "Cannot find copy program: %s" copy-program)) 2294 v 'file-error "Cannot find copy program: %s" copy-program))
2292 2295
@@ -2667,11 +2670,6 @@ the result will be a local, non-Tramp, filename."
2667 2670
2668;;; Remote commands: 2671;;; Remote commands:
2669 2672
2670(defun tramp-sh-handle-executable-find (command)
2671 "Like `executable-find' for Tramp files."
2672 (with-parsed-tramp-file-name default-directory nil
2673 (tramp-find-executable v command (tramp-get-remote-path v) t)))
2674
2675(defun tramp-process-sentinel (proc event) 2673(defun tramp-process-sentinel (proc event)
2676 "Flush file caches." 2674 "Flush file caches."
2677 (unless (memq (process-status proc) '(run open)) 2675 (unless (memq (process-status proc) '(run open))
@@ -3430,8 +3428,8 @@ Fall back to normal file name handler if no Tramp handler exists."
3430 (file-remote-p default-directory))) 3428 (file-remote-p default-directory)))
3431 (rest-string (tramp-compat-process-get proc 'rest-string))) 3429 (rest-string (tramp-compat-process-get proc 'rest-string)))
3432 (when rest-string 3430 (when rest-string
3433 (tramp-message proc 10 (format "Previous string:\n%s" rest-string))) 3431 (tramp-message proc 10 "Previous string:\n%s" rest-string))
3434 (tramp-message proc 6 (format "%S\n%s" proc string)) 3432 (tramp-message proc 6 "%S\n%s" proc string)
3435 (setq string (concat rest-string string) 3433 (setq string (concat rest-string string)
3436 ;; Attribute change is returned in unused wording. 3434 ;; Attribute change is returned in unused wording.
3437 string (replace-regexp-in-string 3435 string (replace-regexp-in-string
@@ -3463,12 +3461,12 @@ Fall back to normal file name handler if no Tramp handler exists."
3463 3461
3464 ;; Save rest of the string. 3462 ;; Save rest of the string.
3465 (when (zerop (length string)) (setq string nil)) 3463 (when (zerop (length string)) (setq string nil))
3466 (when string (tramp-message proc 10 (format "Rest string:\n%s" string))) 3464 (when string (tramp-message proc 10 "Rest string:\n%s" string))
3467 (tramp-compat-process-put proc 'rest-string string))) 3465 (tramp-compat-process-put proc 'rest-string string)))
3468 3466
3469(defun tramp-sh-file-inotifywait-process-filter (proc string) 3467(defun tramp-sh-file-inotifywait-process-filter (proc string)
3470 "Read output from \"inotifywait\" and add corresponding file-notify events." 3468 "Read output from \"inotifywait\" and add corresponding file-notify events."
3471 (tramp-message proc 6 (format "%S\n%s" proc string)) 3469 (tramp-message proc 6 "%S\n%s" proc string)
3472 (dolist (line (split-string string "[\n\r]+" 'omit-nulls)) 3470 (dolist (line (split-string string "[\n\r]+" 'omit-nulls))
3473 ;; Check, whether there is a problem. 3471 ;; Check, whether there is a problem.
3474 (unless 3472 (unless
@@ -3492,15 +3490,6 @@ Fall back to normal file name handler if no Tramp handler exists."
3492 ;; once. Therefore, we apply the callback directly. 3490 ;; once. Therefore, we apply the callback directly.
3493 (tramp-compat-funcall 'file-notify-callback object)))) 3491 (tramp-compat-funcall 'file-notify-callback object))))
3494 3492
3495(defvar file-notify-descriptors)
3496(defun tramp-sh-handle-file-notify-rm-watch (proc)
3497 "Like `file-notify-rm-watch' for Tramp files."
3498 ;; The descriptor must be a process object.
3499 (unless (and (processp proc) (gethash proc file-notify-descriptors))
3500 (tramp-error proc 'file-notify-error "Not a valid descriptor %S" proc))
3501 (tramp-message proc 6 (format "Kill %S" proc))
3502 (kill-process proc))
3503
3504;;; Internal Functions: 3493;;; Internal Functions:
3505 3494
3506(defun tramp-maybe-send-script (vec script name) 3495(defun tramp-maybe-send-script (vec script name)
@@ -3618,7 +3607,7 @@ This function expects to be in the right *tramp* buffer."
3618I.e., for each directory in `tramp-remote-path', it is tested 3607I.e., for each directory in `tramp-remote-path', it is tested
3619whether it exists and if so, it is added to the environment 3608whether it exists and if so, it is added to the environment
3620variable PATH." 3609variable PATH."
3621 (tramp-message vec 5 (format "Setting $PATH environment variable")) 3610 (tramp-message vec 5 "Setting $PATH environment variable")
3622 (tramp-send-command 3611 (tramp-send-command
3623 vec (format "PATH=%s; export PATH" 3612 vec (format "PATH=%s; export PATH"
3624 (mapconcat 'identity (tramp-get-remote-path vec) ":")))) 3613 (mapconcat 'identity (tramp-get-remote-path vec) ":"))))
diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el
index fee34f856dd..29847556dfe 100644
--- a/lisp/net/tramp-smb.el
+++ b/lisp/net/tramp-smb.el
@@ -177,8 +177,7 @@ See `tramp-actions-before-shell' for more info.")
177 177
178;; New handlers should be added here. 178;; New handlers should be added here.
179(defconst tramp-smb-file-name-handler-alist 179(defconst tramp-smb-file-name-handler-alist
180 '( 180 '(;; `access-file' performed by default handler.
181 ;; `access-file' performed by default handler.
182 (add-name-to-file . tramp-smb-handle-add-name-to-file) 181 (add-name-to-file . tramp-smb-handle-add-name-to-file)
183 ;; `byte-compiler-base-file-name' performed by default handler. 182 ;; `byte-compiler-base-file-name' performed by default handler.
184 (copy-directory . tramp-smb-handle-copy-directory) 183 (copy-directory . tramp-smb-handle-copy-directory)
@@ -198,8 +197,10 @@ See `tramp-actions-before-shell' for more info.")
198 (file-acl . tramp-smb-handle-file-acl) 197 (file-acl . tramp-smb-handle-file-acl)
199 (file-attributes . tramp-smb-handle-file-attributes) 198 (file-attributes . tramp-smb-handle-file-attributes)
200 (file-directory-p . tramp-smb-handle-file-directory-p) 199 (file-directory-p . tramp-smb-handle-file-directory-p)
200 ;; `file-equal-p' performed by default handler.
201 (file-executable-p . tramp-handle-file-exists-p) 201 (file-executable-p . tramp-handle-file-exists-p)
202 (file-exists-p . tramp-handle-file-exists-p) 202 (file-exists-p . tramp-handle-file-exists-p)
203 ;; `file-in-directory-p' performed by default handler.
203 (file-local-copy . tramp-smb-handle-file-local-copy) 204 (file-local-copy . tramp-smb-handle-file-local-copy)
204 (file-modes . tramp-handle-file-modes) 205 (file-modes . tramp-handle-file-modes)
205 (file-name-all-completions . tramp-smb-handle-file-name-all-completions) 206 (file-name-all-completions . tramp-smb-handle-file-name-all-completions)
@@ -210,7 +211,7 @@ See `tramp-actions-before-shell' for more info.")
210 ;; `file-name-sans-versions' performed by default handler. 211 ;; `file-name-sans-versions' performed by default handler.
211 (file-newer-than-file-p . tramp-handle-file-newer-than-file-p) 212 (file-newer-than-file-p . tramp-handle-file-newer-than-file-p)
212 (file-notify-add-watch . tramp-handle-file-notify-add-watch) 213 (file-notify-add-watch . tramp-handle-file-notify-add-watch)
213 (file-notify-rm-watch . ignore) 214 (file-notify-rm-watch . tramp-handle-file-notify-rm-watch)
214 (file-ownership-preserved-p . ignore) 215 (file-ownership-preserved-p . ignore)
215 (file-readable-p . tramp-handle-file-exists-p) 216 (file-readable-p . tramp-handle-file-exists-p)
216 (file-regular-p . tramp-handle-file-regular-p) 217 (file-regular-p . tramp-handle-file-regular-p)
@@ -225,6 +226,7 @@ See `tramp-actions-before-shell' for more info.")
225 (insert-directory . tramp-smb-handle-insert-directory) 226 (insert-directory . tramp-smb-handle-insert-directory)
226 (insert-file-contents . tramp-handle-insert-file-contents) 227 (insert-file-contents . tramp-handle-insert-file-contents)
227 (load . tramp-handle-load) 228 (load . tramp-handle-load)
229 ;; `make-auto-save-file-name' performed by default handler.
228 (make-directory . tramp-smb-handle-make-directory) 230 (make-directory . tramp-smb-handle-make-directory)
229 (make-directory-internal . tramp-smb-handle-make-directory-internal) 231 (make-directory-internal . tramp-smb-handle-make-directory-internal)
230 (make-symbolic-link . tramp-smb-handle-make-symbolic-link) 232 (make-symbolic-link . tramp-smb-handle-make-symbolic-link)
@@ -234,15 +236,14 @@ See `tramp-actions-before-shell' for more info.")
234 (set-file-modes . tramp-smb-handle-set-file-modes) 236 (set-file-modes . tramp-smb-handle-set-file-modes)
235 (set-file-selinux-context . ignore) 237 (set-file-selinux-context . ignore)
236 (set-file-times . ignore) 238 (set-file-times . ignore)
237 (set-visited-file-modtime . ignore) 239 (set-visited-file-modtime . tramp-handle-set-visited-file-modtime)
238 (shell-command . tramp-handle-shell-command) 240 (shell-command . tramp-handle-shell-command)
239 (start-file-process . tramp-smb-handle-start-file-process) 241 (start-file-process . tramp-smb-handle-start-file-process)
240 (substitute-in-file-name . tramp-smb-handle-substitute-in-file-name) 242 (substitute-in-file-name . tramp-smb-handle-substitute-in-file-name)
241 (unhandled-file-name-directory . tramp-handle-unhandled-file-name-directory) 243 (unhandled-file-name-directory . tramp-handle-unhandled-file-name-directory)
242 (vc-registered . ignore) 244 (vc-registered . ignore)
243 (verify-visited-file-modtime . ignore) 245 (verify-visited-file-modtime . tramp-handle-verify-visited-file-modtime)
244 (write-region . tramp-smb-handle-write-region) 246 (write-region . tramp-smb-handle-write-region))
245)
246 "Alist of handler functions for Tramp SMB method. 247 "Alist of handler functions for Tramp SMB method.
247Operations not mentioned here will be handled by the default Emacs primitives.") 248Operations not mentioned here will be handled by the default Emacs primitives.")
248 249
@@ -1786,9 +1787,7 @@ Returns nil if an error message has appeared."
1786 (tramp-get-buffer vec) 1787 (tramp-get-buffer vec)
1787 1788
1788 ;; Check for program. 1789 ;; Check for program.
1789 (unless (let ((default-directory 1790 (unless (executable-find tramp-smb-winexe-program)
1790 (tramp-compat-temporary-file-directory)))
1791 (executable-find tramp-smb-winexe-program))
1792 (tramp-error 1791 (tramp-error
1793 vec 'file-error "Cannot find program: %s" tramp-smb-winexe-program)) 1792 vec 'file-error "Cannot find program: %s" tramp-smb-winexe-program))
1794 1793
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 48e13004c36..8ce5f2eae9b 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -1975,11 +1975,11 @@ ARGS are the arguments OPERATION has been called with."
1975 'dired-compress-file 'dired-uncache 1975 'dired-compress-file 'dired-uncache
1976 'file-accessible-directory-p 'file-attributes 1976 'file-accessible-directory-p 'file-attributes
1977 'file-directory-p 'file-executable-p 'file-exists-p 1977 'file-directory-p 'file-executable-p 'file-exists-p
1978 'file-local-copy 'file-remote-p 'file-modes 1978 'file-local-copy 'file-modes
1979 'file-name-as-directory 'file-name-directory 1979 'file-name-as-directory 'file-name-directory
1980 'file-name-nondirectory 'file-name-sans-versions 1980 'file-name-nondirectory 'file-name-sans-versions
1981 'file-ownership-preserved-p 'file-readable-p 1981 'file-ownership-preserved-p 'file-readable-p
1982 'file-regular-p 'file-symlink-p 'file-truename 1982 'file-regular-p 'file-remote-p 'file-symlink-p 'file-truename
1983 'file-writable-p 'find-backup-file-name 'find-file-noselect 1983 'file-writable-p 'find-backup-file-name 'find-file-noselect
1984 'get-file-buffer 'insert-directory 'insert-file-contents 1984 'get-file-buffer 'insert-directory 'insert-file-contents
1985 'load 'make-directory 'make-directory-internal 1985 'load 'make-directory 'make-directory-internal
@@ -2008,7 +2008,7 @@ ARGS are the arguments OPERATION has been called with."
2008 ;; Emacs 23+ only. 2008 ;; Emacs 23+ only.
2009 'copy-directory 2009 'copy-directory
2010 ;; Emacs 24+ only. 2010 ;; Emacs 24+ only.
2011 'file-in-directory-p 'file-equal-p 2011 'file-equal-p 'file-in-directory-p
2012 ;; XEmacs only. 2012 ;; XEmacs only.
2013 'dired-make-relative-symlink 2013 'dired-make-relative-symlink
2014 'vm-imap-move-mail 'vm-pop-move-mail 'vm-spool-move-mail)) 2014 'vm-imap-move-mail 'vm-pop-move-mail 'vm-spool-move-mail))
@@ -3287,14 +3287,78 @@ beginning of local filename are not substituted."
3287 ;; for backward compatibility. 3287 ;; for backward compatibility.
3288 (expand-file-name "~/")) 3288 (expand-file-name "~/"))
3289 3289
3290(defun tramp-handle-set-visited-file-modtime (&optional time-list)
3291 "Like `set-visited-file-modtime' for Tramp files."
3292 (unless (buffer-file-name)
3293 (error "Can't set-visited-file-modtime: buffer `%s' not visiting a file"
3294 (buffer-name)))
3295 (unless time-list
3296 (let ((remote-file-name-inhibit-cache t))
3297 ;; '(-1 65535) means file doesn't exists yet.
3298 (setq time-list
3299 (or (nth 5 (file-attributes (buffer-file-name))) '(-1 65535)))))
3300 ;; We use '(0 0) as a don't-know value.
3301 (unless (equal time-list '(0 0))
3302 (tramp-run-real-handler 'set-visited-file-modtime (list time-list))))
3303
3304(defun tramp-handle-verify-visited-file-modtime (&optional buf)
3305 "Like `verify-visited-file-modtime' for Tramp files.
3306At the time `verify-visited-file-modtime' calls this function, we
3307already know that the buffer is visiting a file and that
3308`visited-file-modtime' does not return 0. Do not call this
3309function directly, unless those two cases are already taken care
3310of."
3311 (with-current-buffer (or buf (current-buffer))
3312 (let ((f (buffer-file-name)))
3313 ;; There is no file visiting the buffer, or the buffer has no
3314 ;; recorded last modification time, or there is no established
3315 ;; connection.
3316 (if (or (not f)
3317 (eq (visited-file-modtime) 0)
3318 (not (tramp-file-name-handler 'file-remote-p f nil 'connected)))
3319 t
3320 (with-parsed-tramp-file-name f nil
3321 (let* ((remote-file-name-inhibit-cache t)
3322 (attr (file-attributes f))
3323 (modtime (nth 5 attr))
3324 (mt (visited-file-modtime)))
3325
3326 (cond
3327 ;; File exists, and has a known modtime.
3328 ((and attr (not (equal modtime '(0 0))))
3329 (< (abs (tramp-time-diff
3330 modtime
3331 ;; For compatibility, deal with both the old
3332 ;; (HIGH . LOW) and the new (HIGH LOW) return
3333 ;; values of `visited-file-modtime'.
3334 (if (atom (cdr mt))
3335 (list (car mt) (cdr mt))
3336 mt)))
3337 2))
3338 ;; Modtime has the don't know value.
3339 (attr t)
3340 ;; If file does not exist, say it is not modified if and
3341 ;; only if that agrees with the buffer's record.
3342 (t (equal mt '(-1 65535))))))))))
3343
3290(defun tramp-handle-file-notify-add-watch (filename flags callback) 3344(defun tramp-handle-file-notify-add-watch (filename flags callback)
3291 "Like `file-notify-add-watch' for Tramp files." 3345 "Like `file-notify-add-watch' for Tramp files."
3292 ;; This is the default handler. Some packages might have its own one. 3346 ;; This is the default handler. tramp-gvfs.el and tramp-sh.el have
3347 ;; its own one.
3293 (setq filename (expand-file-name filename)) 3348 (setq filename (expand-file-name filename))
3294 (with-parsed-tramp-file-name filename nil 3349 (with-parsed-tramp-file-name filename nil
3295 (tramp-error 3350 (tramp-error
3296 v 'file-notify-error "File notification not supported for `%s'" filename))) 3351 v 'file-notify-error "File notification not supported for `%s'" filename)))
3297 3352
3353(defvar file-notify-descriptors)
3354(defun tramp-handle-file-notify-rm-watch (proc)
3355 "Like `file-notify-rm-watch' for Tramp files."
3356 ;; The descriptor must be a process object.
3357 (unless (and (processp proc) (gethash proc file-notify-descriptors))
3358 (tramp-error proc 'file-notify-error "Not a valid descriptor %S" proc))
3359 (tramp-message proc 6 "Kill %S" proc)
3360 (kill-process proc))
3361
3298;;; Functions for establishing connection: 3362;;; Functions for establishing connection:
3299 3363
3300;; The following functions are actions to be taken when seeing certain 3364;; The following functions are actions to be taken when seeing certain
@@ -3951,16 +4015,12 @@ This is needed because for some Emacs flavors Tramp has
3951defadvised `call-process' to behave like `process-file'. The 4015defadvised `call-process' to behave like `process-file'. The
3952Lisp error raised when PROGRAM is nil is trapped also, returning 1. 4016Lisp error raised when PROGRAM is nil is trapped also, returning 1.
3953Furthermore, traces are written with verbosity of 6." 4017Furthermore, traces are written with verbosity of 6."
3954 (let ((default-directory 4018 (tramp-message
3955 (if (file-remote-p default-directory) 4019 (vector tramp-current-method tramp-current-user tramp-current-host nil nil)
3956 (tramp-compat-temporary-file-directory) 4020 6 "%s %s %s" program infile args)
3957 default-directory))) 4021 (if (executable-find program)
3958 (tramp-message 4022 (apply 'call-process program infile destination display args)
3959 (vector tramp-current-method tramp-current-user tramp-current-host nil nil) 4023 1))
3960 6 "%s %s %s" program infile args)
3961 (if (executable-find program)
3962 (apply 'call-process program infile destination display args)
3963 1)))
3964 4024
3965;;;###tramp-autoload 4025;;;###tramp-autoload
3966(defun tramp-read-passwd (proc &optional prompt) 4026(defun tramp-read-passwd (proc &optional prompt)