diff options
| author | Michael Albinus | 2017-05-12 18:36:41 +0200 |
|---|---|---|
| committer | Michael Albinus | 2017-05-12 18:36:41 +0200 |
| commit | afd8c762b7bb534f5686a0273f42cb7cd08e0d6f (patch) | |
| tree | fcd553664e85d26b13479ee3fc2600afed0ccd6e | |
| parent | e5c71dcaf7481cd5f19706e6bea3361f5c1a83e7 (diff) | |
| download | emacs-afd8c762b7bb534f5686a0273f42cb7cd08e0d6f.tar.gz emacs-afd8c762b7bb534f5686a0273f42cb7cd08e0d6f.zip | |
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.
| -rw-r--r-- | lisp/net/tramp-cmds.el | 2 | ||||
| -rw-r--r-- | lisp/net/tramp-compat.el | 6 | ||||
| -rw-r--r-- | lisp/net/tramp.el | 11 | ||||
| -rw-r--r-- | 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 @@ | |||
| 37 | (defvar reporter-eval-buffer) | 37 | (defvar reporter-eval-buffer) |
| 38 | (defvar reporter-prompt-for-summary-p) | 38 | (defvar reporter-prompt-for-summary-p) |
| 39 | 39 | ||
| 40 | ;;;###autoload | 40 | ;;;###tramp-autoload |
| 41 | (defun tramp-change-syntax (&optional syntax) | 41 | (defun tramp-change-syntax (&optional syntax) |
| 42 | "Change Tramp syntax. | 42 | "Change Tramp syntax. |
| 43 | SYNTAX can be one of the symbols `default' (default), | 43 | 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." | |||
| 384 | ((eq tramp-syntax 'sep) 'separate) | 384 | ((eq tramp-syntax 'sep) 'separate) |
| 385 | (t tramp-syntax))) | 385 | (t tramp-syntax))) |
| 386 | 386 | ||
| 387 | ;; Older Emacsen keep incompatible autoloaded values of `tramp-syntax'. | ||
| 388 | (eval-after-load 'tramp | ||
| 389 | '(unless | ||
| 390 | (memq tramp-syntax (tramp-compat-funcall (quote tramp-syntax-values))) | ||
| 391 | (tramp-change-syntax (tramp-compat-tramp-syntax)))) | ||
| 392 | |||
| 387 | (provide 'tramp-compat) | 393 | (provide 'tramp-compat) |
| 388 | 394 | ||
| 389 | ;;; TODO: | 395 | ;;; 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 | |||
| 683 | :set (lambda (symbol value) | 683 | :set (lambda (symbol value) |
| 684 | ;; Check allowed values. | 684 | ;; Check allowed values. |
| 685 | (unless (memq value (tramp-syntax-values)) | 685 | (unless (memq value (tramp-syntax-values)) |
| 686 | (user-error "Wrong `tramp-syntax' %s" tramp-syntax)) | 686 | (tramp-compat-user-error "Wrong `tramp-syntax' %s" tramp-syntax)) |
| 687 | ;; Cleanup existing buffers. | 687 | ;; Cleanup existing buffers. |
| 688 | (unless (eq (symbol-value symbol) value) | 688 | (unless (eq (symbol-value symbol) value) |
| 689 | (tramp-cleanup-all-buffers)) | 689 | (tramp-cleanup-all-buffers)) |
| @@ -2196,9 +2196,6 @@ Falls back to normal file name handler if no Tramp file name handler exists." | |||
| 2196 | (add-to-list 'file-name-handler-alist | 2196 | (add-to-list 'file-name-handler-alist |
| 2197 | (cons tramp-initial-file-name-regexp 'tramp-file-name-handler)) | 2197 | (cons tramp-initial-file-name-regexp 'tramp-file-name-handler)) |
| 2198 | (put 'tramp-file-name-handler 'safe-magic t) | 2198 | (put 'tramp-file-name-handler 'safe-magic t) |
| 2199 | ;; Mark `operations' the handler is responsible for. It's a short list ... | ||
| 2200 | (put 'tramp-file-name-handler 'operations | ||
| 2201 | '(file-name-all-completions file-name-completion file-remote-p)) | ||
| 2202 | 2199 | ||
| 2203 | (add-to-list 'file-name-handler-alist | 2200 | (add-to-list 'file-name-handler-alist |
| 2204 | (cons tramp-initial-completion-file-name-regexp | 2201 | (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." | |||
| 2216 | ;; Remove autoloaded handlers from file name handler alist. Useful, | 2213 | ;; Remove autoloaded handlers from file name handler alist. Useful, |
| 2217 | ;; if `tramp-syntax' has been changed. | 2214 | ;; if `tramp-syntax' has been changed. |
| 2218 | (dolist (fnh '(tramp-file-name-handler | 2215 | (dolist (fnh '(tramp-file-name-handler |
| 2219 | tramp-completion-file-name-handler)) | 2216 | tramp-completion-file-name-handler |
| 2217 | ;; This is autoloaded in Emacs 24 & 25. | ||
| 2218 | tramp-autoload-file-name-handler)) | ||
| 2220 | (let ((a1 (rassq fnh file-name-handler-alist))) | 2219 | (let ((a1 (rassq fnh file-name-handler-alist))) |
| 2221 | (setq file-name-handler-alist (delq a1 file-name-handler-alist)))) | 2220 | (setq file-name-handler-alist (delq a1 file-name-handler-alist)))) |
| 2222 | 2221 | ||
| @@ -2256,7 +2255,7 @@ Add operations defined in `HANDLER-alist' to `tramp-file-name-handler'." | |||
| 2256 | ;; Mark `operations' the handler is responsible for. | 2255 | ;; Mark `operations' the handler is responsible for. |
| 2257 | (put 'tramp-file-name-handler | 2256 | (put 'tramp-file-name-handler |
| 2258 | 'operations | 2257 | 'operations |
| 2259 | (cl-delete-duplicates | 2258 | (delete-dups |
| 2260 | (append | 2259 | (append |
| 2261 | (get 'tramp-file-name-handler 'operations) | 2260 | (get 'tramp-file-name-handler 'operations) |
| 2262 | (mapcar | 2261 | (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 @@ | |||
| 45 | (require 'vc-git) | 45 | (require 'vc-git) |
| 46 | (require 'vc-hg) | 46 | (require 'vc-hg) |
| 47 | 47 | ||
| 48 | (declare-function tramp-change-syntax "tramp-cmds") | ||
| 48 | (declare-function tramp-find-executable "tramp-sh") | 49 | (declare-function tramp-find-executable "tramp-sh") |
| 49 | (declare-function tramp-get-remote-path "tramp-sh") | 50 | (declare-function tramp-get-remote-path "tramp-sh") |
| 50 | (declare-function tramp-get-remote-stat "tramp-sh") | 51 | (declare-function tramp-get-remote-stat "tramp-sh") |