]> git.eshelyaron.com Git - emacs.git/commitdiff
Simplify Tramp autoloading.
authorMichael Albinus <michael.albinus@gmx.de>
Sat, 25 Mar 2017 14:42:39 +0000 (15:42 +0100)
committerMichael Albinus <michael.albinus@gmx.de>
Sat, 25 Mar 2017 14:42:39 +0000 (15:42 +0100)
* lisp/net/tramp.el (tramp-completion-file-name-handler):
Simplify autoloading.  Give it the `operations' property.
(tramp-completion-handle-expand-file-name): Remove.

lisp/net/tramp.el

index a9254693adb725590c77a4b8fdc71e08cba7dfae..a7c36c09e08419f5e2392b8a68946e83adea6a4f 100644 (file)
@@ -1055,8 +1055,7 @@ means to use always cached values for the directory contents."
 
 ;;;###autoload
 (defconst tramp-completion-file-name-handler-alist
-  '(;(expand-file-name . tramp-completion-handle-expand-file-name)
-    (file-name-all-completions
+  '((file-name-all-completions
      . tramp-completion-handle-file-name-all-completions)
     (file-name-completion . tramp-completion-handle-file-name-completion))
   "Alist of completion handler functions.
@@ -2113,20 +2112,7 @@ preventing reentrant calls of Tramp.")
 Together with `tramp-locked', this implements a locking mechanism
 preventing reentrant calls of Tramp.")
 
-;; Avoid recursive loading of tramp.el.
-;; FIXME: This must go better.  Checking for `operation' is wrong.
-;;;###autoload(defun tramp-completion-file-name-handler (operation &rest args)
-;;;###autoload  (let ((fn
-;;;###autoload         (assoc
-;;;###autoload          operation tramp-completion-file-name-handler-alist)))
-;;;###autoload    (if (and
-;;;###autoload         tramp-mode fn (null load-in-progress)
-;;;###autoload         (member
-;;;###autoload          operation
-;;;###autoload          '(file-name-all-completions file-name-completion)))
-;;;###autoload        (apply 'tramp-autoload-file-name-handler operation args)
-;;;###autoload      (tramp-run-real-handler operation args))))
-
+;;;###autoload
 (defun tramp-completion-file-name-handler (operation &rest args)
   "Invoke Tramp file name completion handler.
 Falls back to normal file name handler if no Tramp file name handler exists."
@@ -2135,6 +2121,11 @@ Falls back to normal file name handler if no Tramp file name handler exists."
        (save-match-data (apply (cdr fn) args))
       (tramp-run-real-handler operation args))))
 
+;; Mark `operations' the handler is responsible for.
+;;;###autoload
+(put 'tramp-completion-file-name-handler 'operations
+     (mapcar 'car tramp-completion-file-name-handler-alist))
+
 ;;;###autoload
 (progn (defun tramp-autoload-file-name-handler (operation &rest args)
   "Load Tramp file name handler, and perform OPERATION."
@@ -2258,15 +2249,6 @@ not in completion mode."
              (tramp-get-connection-process
               (tramp-dissect-file-name filename)))))))
 
-(defun tramp-completion-handle-expand-file-name (name &optional dir)
-  "Like `expand-file-name' for Tramp files."
-  ;; If DIR is not given, use `default-directory' or "/".
-  (setq dir (or dir default-directory "/"))
-  (cond
-   ((file-name-absolute-p name) name)
-   ((zerop (length name)) dir)
-   (t (concat (file-name-as-directory dir) name))))
-
 ;; Method, host name and user name completion.
 ;; `tramp-completion-dissect-file-name' returns a list of
 ;; tramp-file-name structures. For all of them we return possible completions.