mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-16 17:24:23 +00:00
Optimize file-equal-p' and file-in-directory-p' in Tramp
* lisp/net/tramp.el (tramp-handle-file-equal-p) (tramp-handle-file-in-directory-p): New defuns. Suggested by Harvey Chapman <hchapman@3gfp.com> * lisp/net/tramp-adb.el (tramp-adb-file-name-handler-alist): * lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist): * lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist): * lisp/net/tramp-smb.el (tramp-smb-file-name-handler-alist): Use them.
This commit is contained in:
parent
25775a12c5
commit
ef75c3b56b
5 changed files with 28 additions and 8 deletions
|
|
@ -117,11 +117,11 @@ It is used for TCP/IP devices."
|
|||
(file-acl . ignore)
|
||||
(file-attributes . tramp-adb-handle-file-attributes)
|
||||
(file-directory-p . tramp-adb-handle-file-directory-p)
|
||||
;; `file-equal-p' performed by default handler.
|
||||
(file-equal-p . tramp-handle-file-equal-p)
|
||||
;; FIXME: This is too sloppy.
|
||||
(file-executable-p . tramp-handle-file-exists-p)
|
||||
(file-exists-p . tramp-handle-file-exists-p)
|
||||
;; `file-in-directory-p' performed by default handler.
|
||||
(file-in-directory-p . tramp-handle-file-in-directory-p)
|
||||
(file-local-copy . tramp-adb-handle-file-local-copy)
|
||||
(file-modes . tramp-handle-file-modes)
|
||||
(file-name-all-completions . tramp-adb-handle-file-name-all-completions)
|
||||
|
|
|
|||
|
|
@ -430,10 +430,10 @@ Every entry is a list (NAME ADDRESS).")
|
|||
(file-acl . ignore)
|
||||
(file-attributes . tramp-gvfs-handle-file-attributes)
|
||||
(file-directory-p . tramp-gvfs-handle-file-directory-p)
|
||||
;; `file-equal-p' performed by default handler.
|
||||
(file-equal-p . tramp-handle-file-equal-p)
|
||||
(file-executable-p . tramp-gvfs-handle-file-executable-p)
|
||||
(file-exists-p . tramp-handle-file-exists-p)
|
||||
;; `file-in-directory-p' performed by default handler.
|
||||
(file-in-directory-p . tramp-handle-file-in-directory-p)
|
||||
(file-local-copy . tramp-gvfs-handle-file-local-copy)
|
||||
(file-modes . tramp-handle-file-modes)
|
||||
(file-name-all-completions . tramp-gvfs-handle-file-name-all-completions)
|
||||
|
|
|
|||
|
|
@ -993,10 +993,10 @@ of command line.")
|
|||
(file-acl . tramp-sh-handle-file-acl)
|
||||
(file-attributes . tramp-sh-handle-file-attributes)
|
||||
(file-directory-p . tramp-sh-handle-file-directory-p)
|
||||
;; `file-equal-p' performed by default handler.
|
||||
(file-equal-p . tramp-handle-file-equal-p)
|
||||
(file-executable-p . tramp-sh-handle-file-executable-p)
|
||||
(file-exists-p . tramp-sh-handle-file-exists-p)
|
||||
;; `file-in-directory-p' performed by default handler.
|
||||
(file-in-directory-p . tramp-handle-file-in-directory-p)
|
||||
(file-local-copy . tramp-sh-handle-file-local-copy)
|
||||
(file-modes . tramp-handle-file-modes)
|
||||
(file-name-all-completions . tramp-sh-handle-file-name-all-completions)
|
||||
|
|
|
|||
|
|
@ -232,10 +232,10 @@ See `tramp-actions-before-shell' for more info.")
|
|||
(file-acl . tramp-smb-handle-file-acl)
|
||||
(file-attributes . tramp-smb-handle-file-attributes)
|
||||
(file-directory-p . tramp-smb-handle-file-directory-p)
|
||||
;; `file-equal-p' performed by default handler.
|
||||
(file-file-equal-p . tramp-handle-file-equal-p)
|
||||
(file-executable-p . tramp-handle-file-exists-p)
|
||||
(file-exists-p . tramp-handle-file-exists-p)
|
||||
;; `file-in-directory-p' performed by default handler.
|
||||
(file-in-directory-p . tramp-handle-file-in-directory-p)
|
||||
(file-local-copy . tramp-smb-handle-file-local-copy)
|
||||
(file-modes . tramp-handle-file-modes)
|
||||
(file-name-all-completions . tramp-smb-handle-file-name-all-completions)
|
||||
|
|
|
|||
|
|
@ -2910,10 +2910,30 @@ User is always nil."
|
|||
(and (file-directory-p filename)
|
||||
(file-readable-p filename)))
|
||||
|
||||
(defun tramp-handle-file-equal-p (filename1 filename2)
|
||||
"Like `file-equalp-p' for Tramp files."
|
||||
;; Native `file-equalp-p' calls `file-truename', which requires a
|
||||
;; remote connection. This can be avoided, if FILENAME1 and
|
||||
;; FILENAME2 are not located on the same remote host.
|
||||
(when (string-equal
|
||||
(file-remote-p (expand-file-name filename1))
|
||||
(file-remote-p (expand-file-name filename2)))
|
||||
(tramp-run-real-handler 'file-equal-p (list filename1 filename2))))
|
||||
|
||||
(defun tramp-handle-file-exists-p (filename)
|
||||
"Like `file-exists-p' for Tramp files."
|
||||
(not (null (file-attributes filename))))
|
||||
|
||||
(defun tramp-handle-file-in-directory-p (filename directory)
|
||||
"Like `file-in-directory-p' for Tramp files."
|
||||
;; Native `file-in-directory-p' calls `file-truename', which
|
||||
;; requires a remote connection. This can be avoided, if FILENAME
|
||||
;; and DIRECTORY are not located on the same remote host.
|
||||
(when (string-equal
|
||||
(file-remote-p (expand-file-name filename))
|
||||
(file-remote-p (expand-file-name directory)))
|
||||
(tramp-run-real-handler 'file-in-directory-p (list filename directory))))
|
||||
|
||||
(defun tramp-handle-file-modes (filename)
|
||||
"Like `file-modes' for Tramp files."
|
||||
(let ((truename (or (file-truename filename) filename)))
|
||||
|
|
|
|||
Loading…
Reference in a new issue