Commit b7d61609 authored by Michael Albinus's avatar Michael Albinus
Browse files

Tune Tramp syntax

* lisp/net/tramp-cmds.el (tramp-change-syntax):
Use `tramp-syntax-values'.

* lisp/net/tramp-compat.el (tramp-compat-tramp-syntax): New defsubst.

* lisp/net/tramp.el (tramp-syntax): Rename possible values.
(tramp-syntax-values): New defun.
(tramp-prefix-format, tramp-method-regexp)
(tramp-postfix-method-format, tramp-prefix-ipv6-format)
(tramp-postfix-ipv6-format, tramp-postfix-host-format)
(tramp-completion-file-name-regexp): Use `tramp-compat-tramp-syntax'
and changed values.
(tramp-completion-file-name-regexp-default): Rename from
`tramp-completion-file-name-regexp-unified'.  Adapt docstring.
(tramp-completion-file-name-regexp-simplified): Rename from
`tramp-completion-file-name-regexp-old-style'.  Adapt docstring.
(tramp-initial-completion-file-name-regexp):
Use `tramp-completion-file-name-regexp-default'.
(tramp-run-real-handler): Do not autoload any longer.
parent c5f319eb
...@@ -40,11 +40,11 @@ ...@@ -40,11 +40,11 @@
;;;###autoload ;;;###autoload
(defun tramp-change-syntax (&optional syntax) (defun tramp-change-syntax (&optional syntax)
"Change Tramp syntax. "Change Tramp syntax.
SYNTAX can be one of the symbols `def' (default), `ftp' (ange-ftp like) SYNTAX can be one of the symbols `default' (default),
or `sep' (XEmacs like)." `simplified' (ange-ftp like) or `separate' (XEmacs like)."
(interactive (interactive
(let ((input (completing-read (let ((input (completing-read
"Enter Tramp syntax: " '(def ftp sep) nil t "Enter Tramp syntax: " (tramp-syntax-values) nil t
(symbol-name tramp-syntax)))) (symbol-name tramp-syntax))))
(unless (string-equal input "") (unless (string-equal input "")
(list (intern input))))) (list (intern input)))))
......
...@@ -379,6 +379,14 @@ If NAME is a remote file name, the local part of NAME is unquoted." ...@@ -379,6 +379,14 @@ If NAME is a remote file name, the local part of NAME is unquoted."
(if (= (length localname) 2) "/" "") nil t localname))) (if (= (length localname) 2) "/" "") nil t localname)))
(concat (file-remote-p name) localname)))))) (concat (file-remote-p name) localname))))))
;; `tramp-syntax' has changed its meaning in Emacs 26. We still
;; support old settings.
(defsubst tramp-compat-tramp-syntax ()
"Return proper value of `tramp-syntax'."
(cond ((eq tramp-syntax 'ftp) 'default)
((eq tramp-syntax 'sep) 'separate)
(t tramp-syntax)))
(provide 'tramp-compat) (provide 'tramp-compat)
;;; TODO: ;;; TODO:
......
...@@ -662,29 +662,26 @@ Useful for \"rsync\" like methods.") ...@@ -662,29 +662,26 @@ Useful for \"rsync\" like methods.")
(put 'tramp-temp-buffer-file-name 'permanent-local t) (put 'tramp-temp-buffer-file-name 'permanent-local t)
;;;###autoload ;;;###autoload
(defcustom tramp-syntax 'def (defcustom tramp-syntax 'default
"Tramp filename syntax to be used. "Tramp filename syntax to be used.
It can have the following values: It can have the following values:
`def' -- Default syntax `default' -- Default syntax
`ftp' -- Ange-FTP like syntax `simplified' -- Ange-FTP like syntax
`sep' -- Syntax as defined for XEmacs originally." `separate' -- Syntax as defined for XEmacs originally."
:group 'tramp :group 'tramp
:version "26.1" :version "26.1"
:package-version '(Tramp . "2.3.2") :package-version '(Tramp . "2.3.2")
:type '(choice (const :tag "Default" def) :type '(choice (const :tag "Default" default)
(const :tag "Ange-FTP" ftp) (const :tag "Ange-FTP" simplified)
(const :tag "XEmacs" sep)) (const :tag "XEmacs" separate))
:require 'tramp :require 'tramp
:initialize 'custom-initialize-set :initialize 'custom-initialize-set
:set (lambda (symbol value) :set (lambda (symbol value)
;; Check allowed values. ;; Check allowed values.
(let ((values (cdr (get symbol 'custom-type)))) (unless (memq value (tramp-syntax-values))
(setq values (mapcar 'last values) (user-error "Wrong `tramp-syntax' %s" tramp-syntax))
values (mapcar 'car values))
(unless (member value values)
(user-error "Wrong `tramp-syntax' %s defined" tramp-syntax)))
;; Cleanup existing buffers. ;; Cleanup existing buffers.
(unless (eq (symbol-value symbol) value) (unless (eq (symbol-value symbol) value)
(tramp-cleanup-all-buffers)) (tramp-cleanup-all-buffers))
...@@ -693,13 +690,19 @@ It can have the following values: ...@@ -693,13 +690,19 @@ It can have the following values:
;; Rearrange file name handlers. ;; Rearrange file name handlers.
(tramp-register-file-name-handlers))) (tramp-register-file-name-handlers)))
(defun tramp-syntax-values ()
"Return possible values of `tramp-syntax', a list"
(let ((values (cdr (get 'tramp-syntax 'custom-type))))
(setq values (mapcar 'last values)
values (mapcar 'car values))))
(defun tramp-prefix-format () (defun tramp-prefix-format ()
"String matching the very beginning of Tramp file names. "String matching the very beginning of Tramp file names.
Used in `tramp-make-tramp-file-name'." Used in `tramp-make-tramp-file-name'."
(cond ((eq tramp-syntax 'def) "/") (cond ((eq (tramp-compat-tramp-syntax) 'default) "/")
((eq tramp-syntax 'ftp) "/") ((eq (tramp-compat-tramp-syntax) 'simplified) "/")
((eq tramp-syntax 'sep) "/[") ((eq (tramp-compat-tramp-syntax) 'separate) "/[")
(t (error "Wrong `tramp-syntax' %s defined" tramp-syntax)))) (t (error "Wrong `tramp-syntax' %s" tramp-syntax))))
(defun tramp-prefix-regexp () (defun tramp-prefix-regexp ()
"Regexp matching the very beginning of Tramp file names. "Regexp matching the very beginning of Tramp file names.
...@@ -709,16 +712,16 @@ Should always start with \"^\". Derived from `tramp-prefix-format'." ...@@ -709,16 +712,16 @@ Should always start with \"^\". Derived from `tramp-prefix-format'."
(defun tramp-method-regexp () (defun tramp-method-regexp ()
"Regexp matching methods identifiers. "Regexp matching methods identifiers.
The `ftp' syntax does not support methods." The `ftp' syntax does not support methods."
(if (eq tramp-syntax 'ftp) "" "[a-zA-Z0-9-]+")) (if (eq (tramp-compat-tramp-syntax) 'simplified) "" "[a-zA-Z0-9-]+"))
(defun tramp-postfix-method-format () (defun tramp-postfix-method-format ()
"String matching delimiter between method and user or host names. "String matching delimiter between method and user or host names.
The `ftp' syntax does not support methods. The `ftp' syntax does not support methods.
Used in `tramp-make-tramp-file-name'." Used in `tramp-make-tramp-file-name'."
(cond ((eq tramp-syntax 'def) ":") (cond ((eq (tramp-compat-tramp-syntax) 'default) ":")
((eq tramp-syntax 'ftp) "") ((eq (tramp-compat-tramp-syntax) 'simplified) "")
((eq tramp-syntax 'sep) "/") ((eq (tramp-compat-tramp-syntax) 'separate) "/")
(t (error "Wrong `tramp-syntax' %s defined" tramp-syntax)))) (t (error "Wrong `tramp-syntax' %s" tramp-syntax))))
(defun tramp-postfix-method-regexp () (defun tramp-postfix-method-regexp ()
"Regexp matching delimiter between method and user or host names. "Regexp matching delimiter between method and user or host names.
...@@ -762,10 +765,10 @@ Derived from `tramp-postfix-user-format'.") ...@@ -762,10 +765,10 @@ Derived from `tramp-postfix-user-format'.")
(defun tramp-prefix-ipv6-format () (defun tramp-prefix-ipv6-format ()
"String matching left hand side of IPv6 addresses. "String matching left hand side of IPv6 addresses.
Used in `tramp-make-tramp-file-name'." Used in `tramp-make-tramp-file-name'."
(cond ((eq tramp-syntax 'def) "[") (cond ((eq (tramp-compat-tramp-syntax) 'default) "[")
((eq tramp-syntax 'ftp) "[") ((eq (tramp-compat-tramp-syntax) 'simplified) "[")
((eq tramp-syntax 'sep) "") ((eq (tramp-compat-tramp-syntax) 'separate) "")
(t (error "Wrong `tramp-syntax' %s defined" tramp-syntax)))) (t (error "Wrong `tramp-syntax' %s" tramp-syntax))))
(defun tramp-prefix-ipv6-regexp () (defun tramp-prefix-ipv6-regexp ()
"Regexp matching left hand side of IPv6 addresses. "Regexp matching left hand side of IPv6 addresses.
...@@ -782,10 +785,10 @@ Derived from `tramp-prefix-ipv6-format'." ...@@ -782,10 +785,10 @@ Derived from `tramp-prefix-ipv6-format'."
(defun tramp-postfix-ipv6-format () (defun tramp-postfix-ipv6-format ()
"String matching right hand side of IPv6 addresses. "String matching right hand side of IPv6 addresses.
Used in `tramp-make-tramp-file-name'." Used in `tramp-make-tramp-file-name'."
(cond ((eq tramp-syntax 'def) "]") (cond ((eq (tramp-compat-tramp-syntax) 'default) "]")
((eq tramp-syntax 'ftp) "]") ((eq (tramp-compat-tramp-syntax) 'simplified) "]")
((eq tramp-syntax 'sep) "") ((eq (tramp-compat-tramp-syntax) 'separate) "")
(t (error "Wrong `tramp-syntax' %s defined" tramp-syntax)))) (t (error "Wrong `tramp-syntax' %s" tramp-syntax))))
(defun tramp-postfix-ipv6-regexp () (defun tramp-postfix-ipv6-regexp ()
"Regexp matching right hand side of IPv6 addresses. "Regexp matching right hand side of IPv6 addresses.
...@@ -820,10 +823,10 @@ Derived from `tramp-postfix-hop-format'.") ...@@ -820,10 +823,10 @@ Derived from `tramp-postfix-hop-format'.")
(defun tramp-postfix-host-format () (defun tramp-postfix-host-format ()
"String matching delimiter between host names and localnames. "String matching delimiter between host names and localnames.
Used in `tramp-make-tramp-file-name'." Used in `tramp-make-tramp-file-name'."
(cond ((eq tramp-syntax 'def) ":") (cond ((eq (tramp-compat-tramp-syntax) 'default) ":")
((eq tramp-syntax 'ftp) ":") ((eq (tramp-compat-tramp-syntax) 'simplified) ":")
((eq tramp-syntax 'sep) "]") ((eq (tramp-compat-tramp-syntax) 'separate) "]")
(t (error "Wrong `tramp-syntax' %s defined" tramp-syntax)))) (t (error "Wrong `tramp-syntax' %s" tramp-syntax))))
(defun tramp-postfix-host-regexp () (defun tramp-postfix-host-regexp ()
"Regexp matching delimiter between host names and localnames. "Regexp matching delimiter between host names and localnames.
...@@ -890,7 +893,7 @@ This regexp should match Tramp file names but no other file names." ...@@ -890,7 +893,7 @@ This regexp should match Tramp file names but no other file names."
It must match the initial `tramp-syntax' settings.") It must match the initial `tramp-syntax' settings.")
;;;###autoload ;;;###autoload
(defconst tramp-completion-file-name-regexp-unified (defconst tramp-completion-file-name-regexp-default
(concat (concat
"\\`/\\(" "\\`/\\("
;; Optional multi hop. ;; Optional multi hop.
...@@ -904,12 +907,12 @@ It must match the initial `tramp-syntax' settings.") ...@@ -904,12 +907,12 @@ It must match the initial `tramp-syntax' settings.")
;; Method separator, user name and host name. ;; Method separator, user name and host name.
"\\(:[^/|:]*\\)?" "\\(:[^/|:]*\\)?"
"\\)?\\'") "\\)?\\'")
"Value for `tramp-completion-file-name-regexp' for unified remoting. "Value for `tramp-completion-file-name-regexp' for default remoting.
See `tramp-file-name-structure' for more explanations. See `tramp-file-name-structure' for more explanations.
On W32 systems, the volume letter must be ignored.") On W32 systems, the volume letter must be ignored.")
(defconst tramp-completion-file-name-regexp-old-style (defconst tramp-completion-file-name-regexp-simplified
(concat (concat
"\\`/\\(" "\\`/\\("
;; Optional multi hop. ;; Optional multi hop.
...@@ -921,7 +924,7 @@ On W32 systems, the volume letter must be ignored.") ...@@ -921,7 +924,7 @@ On W32 systems, the volume letter must be ignored.")
;; At least one character. ;; At least one character.
"[^/|:]+") "[^/|:]+")
"\\)?\\'") "\\)?\\'")
"Value for `tramp-completion-file-name-regexp' for ange-ftp style remoting. "Value for `tramp-completion-file-name-regexp' for simplified style remoting.
See `tramp-file-name-structure' for more explanations. See `tramp-file-name-structure' for more explanations.
On W32 systems, the volume letter must be ignored.") On W32 systems, the volume letter must be ignored.")
...@@ -941,14 +944,17 @@ before loading tramp.el. Alternatively, `file-name-handler-alist' can be ...@@ -941,14 +944,17 @@ before loading tramp.el. Alternatively, `file-name-handler-alist' can be
updated after changing this variable. updated after changing this variable.
Also see `tramp-file-name-structure'." Also see `tramp-file-name-structure'."
(cond ((eq tramp-syntax 'def) tramp-completion-file-name-regexp-unified) (cond ((eq (tramp-compat-tramp-syntax) 'default)
((eq tramp-syntax 'ftp) tramp-completion-file-name-regexp-old-style) tramp-completion-file-name-regexp-default)
((eq tramp-syntax 'sep) tramp-completion-file-name-regexp-separate) ((eq (tramp-compat-tramp-syntax) 'simplified)
(t (error "Wrong `tramp-syntax' %s defined" tramp-syntax)))) tramp-completion-file-name-regexp-simplified)
((eq (tramp-compat-tramp-syntax) 'separate)
tramp-completion-file-name-regexp-separate)
(t (error "Wrong `tramp-syntax' %s" tramp-syntax))))
;;;###autoload ;;;###autoload
(defconst tramp-initial-completion-file-name-regexp (defconst tramp-initial-completion-file-name-regexp
tramp-completion-file-name-regexp-unified tramp-completion-file-name-regexp-default
"Value for `tramp-completion-file-name-regexp' for autoload. "Value for `tramp-completion-file-name-regexp' for autoload.
It must match the initial `tramp-syntax' settings.") It must match the initial `tramp-syntax' settings.")
...@@ -1911,8 +1917,7 @@ coding system might not be determined. This function repairs it." ...@@ -1911,8 +1917,7 @@ coding system might not be determined. This function repairs it."
;; as regexp. ;; as regexp.
(push (cons (regexp-quote tmpname) (cdr elt)) result))))) (push (cons (regexp-quote tmpname) (cdr elt)) result)))))
;;;###autoload (defun tramp-run-real-handler (operation args)
(progn (defun tramp-run-real-handler (operation args)
"Invoke normal file name handler for OPERATION. "Invoke normal file name handler for OPERATION.
First arg specifies the OPERATION, second arg is a list of arguments to First arg specifies the OPERATION, second arg is a list of arguments to
pass to the OPERATION." pass to the OPERATION."
...@@ -1926,7 +1931,7 @@ pass to the OPERATION." ...@@ -1926,7 +1931,7 @@ pass to the OPERATION."
,(and (eq inhibit-file-name-operation operation) ,(and (eq inhibit-file-name-operation operation)
inhibit-file-name-handlers))) inhibit-file-name-handlers)))
(inhibit-file-name-operation operation)) (inhibit-file-name-operation operation))
(apply operation args)))) (apply operation args)))
;; We handle here all file primitives. Most of them have the file ;; We handle here all file primitives. Most of them have the file
;; name as first parameter; nevertheless we check for them explicitly ;; name as first parameter; nevertheless we check for them explicitly
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment