From afd8c762b7bb534f5686a0273f42cb7cd08e0d6f Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Fri, 12 May 2017 18:36:41 +0200 Subject: [PATCH] Make Tramp backward compatible * lisp/net/tramp-cmds.el (tramp-change-syntax): Set tramp-autoload cookie. * lisp/net/tramp-compat.el: Run `tramp-change-syntax' at startup, if necessary. * lisp/net/tramp.el (tramp-syntax): Use `tramp-compat-user-error'. (tramp-register-autoload-file-name-handlers): Do not mark `operations' for `tramp-file-name-handler'. (tramp-register-file-name-handlers): Remove also `tramp-autoload-file-name-handler' for backward compatibility. (tramp-register-foreign-file-name-handler): Use `delete-dups'. * test/lisp/net/tramp-tests.el (tramp-change-syntax): Declare. --- lisp/net/tramp-cmds.el | 2 +- lisp/net/tramp-compat.el | 6 ++++++ lisp/net/tramp.el | 11 +++++------ test/lisp/net/tramp-tests.el | 1 + 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/lisp/net/tramp-cmds.el b/lisp/net/tramp-cmds.el index a11908af63e..4007b65c3af 100644 --- a/lisp/net/tramp-cmds.el +++ b/lisp/net/tramp-cmds.el @@ -37,7 +37,7 @@ (defvar reporter-eval-buffer) (defvar reporter-prompt-for-summary-p) -;;;###autoload +;;;###tramp-autoload (defun tramp-change-syntax (&optional syntax) "Change Tramp syntax. SYNTAX can be one of the symbols `default' (default), diff --git a/lisp/net/tramp-compat.el b/lisp/net/tramp-compat.el index 322e9c36895..53266e806c0 100644 --- a/lisp/net/tramp-compat.el +++ b/lisp/net/tramp-compat.el @@ -384,6 +384,12 @@ If NAME is a remote file name, the local part of NAME is unquoted." ((eq tramp-syntax 'sep) 'separate) (t tramp-syntax))) +;; Older Emacsen keep incompatible autoloaded values of `tramp-syntax'. +(eval-after-load 'tramp + '(unless + (memq tramp-syntax (tramp-compat-funcall (quote tramp-syntax-values))) + (tramp-change-syntax (tramp-compat-tramp-syntax)))) + (provide 'tramp-compat) ;;; TODO: diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 071114a0157..8c317df9767 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -683,7 +683,7 @@ Do not change the value by `setq', it must be changed only by :set (lambda (symbol value) ;; Check allowed values. (unless (memq value (tramp-syntax-values)) - (user-error "Wrong `tramp-syntax' %s" tramp-syntax)) + (tramp-compat-user-error "Wrong `tramp-syntax' %s" tramp-syntax)) ;; Cleanup existing buffers. (unless (eq (symbol-value symbol) value) (tramp-cleanup-all-buffers)) @@ -2196,9 +2196,6 @@ Falls back to normal file name handler if no Tramp file name handler exists." (add-to-list 'file-name-handler-alist (cons tramp-initial-file-name-regexp 'tramp-file-name-handler)) (put 'tramp-file-name-handler 'safe-magic t) - ;; Mark `operations' the handler is responsible for. It's a short list ... - (put 'tramp-file-name-handler 'operations - '(file-name-all-completions file-name-completion file-remote-p)) (add-to-list 'file-name-handler-alist (cons tramp-initial-completion-file-name-regexp @@ -2216,7 +2213,9 @@ Falls back to normal file name handler if no Tramp file name handler exists." ;; Remove autoloaded handlers from file name handler alist. Useful, ;; if `tramp-syntax' has been changed. (dolist (fnh '(tramp-file-name-handler - tramp-completion-file-name-handler)) + tramp-completion-file-name-handler + ;; This is autoloaded in Emacs 24 & 25. + tramp-autoload-file-name-handler)) (let ((a1 (rassq fnh file-name-handler-alist))) (setq file-name-handler-alist (delq a1 file-name-handler-alist)))) @@ -2256,7 +2255,7 @@ Add operations defined in `HANDLER-alist' to `tramp-file-name-handler'." ;; Mark `operations' the handler is responsible for. (put 'tramp-file-name-handler 'operations - (cl-delete-duplicates + (delete-dups (append (get 'tramp-file-name-handler 'operations) (mapcar diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index a380e95c1a1..d3a93d27b29 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el @@ -45,6 +45,7 @@ (require 'vc-git) (require 'vc-hg) +(declare-function tramp-change-syntax "tramp-cmds") (declare-function tramp-find-executable "tramp-sh") (declare-function tramp-get-remote-path "tramp-sh") (declare-function tramp-get-remote-stat "tramp-sh") -- 2.39.2