aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2017-04-08 18:35:06 +0200
committerMichael Albinus2017-04-08 18:35:06 +0200
commitb7d61609bd2a5a97b63733a4c16194850e48de2a (patch)
tree56f5ed751724e069ecaf1f073b9c85cb37427dd0
parentc5f319eb3a2e0ad97867c8dc61bfc140333fb11d (diff)
downloademacs-b7d61609bd2a5a97b63733a4c16194850e48de2a.tar.gz
emacs-b7d61609bd2a5a97b63733a4c16194850e48de2a.zip
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.
-rw-r--r--lisp/net/tramp-cmds.el6
-rw-r--r--lisp/net/tramp-compat.el8
-rw-r--r--lisp/net/tramp.el95
3 files changed, 61 insertions, 48 deletions
diff --git a/lisp/net/tramp-cmds.el b/lisp/net/tramp-cmds.el
index df6a5c507f0..99fc0cc7098 100644
--- a/lisp/net/tramp-cmds.el
+++ b/lisp/net/tramp-cmds.el
@@ -40,11 +40,11 @@
40;;;###autoload 40;;;###autoload
41(defun tramp-change-syntax (&optional syntax) 41(defun tramp-change-syntax (&optional syntax)
42 "Change Tramp syntax. 42 "Change Tramp syntax.
43SYNTAX can be one of the symbols `def' (default), `ftp' (ange-ftp like) 43SYNTAX can be one of the symbols `default' (default),
44or `sep' (XEmacs like)." 44`simplified' (ange-ftp like) or `separate' (XEmacs like)."
45 (interactive 45 (interactive
46 (let ((input (completing-read 46 (let ((input (completing-read
47 "Enter Tramp syntax: " '(def ftp sep) nil t 47 "Enter Tramp syntax: " (tramp-syntax-values) nil t
48 (symbol-name tramp-syntax)))) 48 (symbol-name tramp-syntax))))
49 (unless (string-equal input "") 49 (unless (string-equal input "")
50 (list (intern input))))) 50 (list (intern input)))))
diff --git a/lisp/net/tramp-compat.el b/lisp/net/tramp-compat.el
index 8f346eb4409..732922b60ec 100644
--- a/lisp/net/tramp-compat.el
+++ b/lisp/net/tramp-compat.el
@@ -379,6 +379,14 @@ If NAME is a remote file name, the local part of NAME is unquoted."
379 (if (= (length localname) 2) "/" "") nil t localname))) 379 (if (= (length localname) 2) "/" "") nil t localname)))
380 (concat (file-remote-p name) localname)))))) 380 (concat (file-remote-p name) localname))))))
381 381
382;; `tramp-syntax' has changed its meaning in Emacs 26. We still
383;; support old settings.
384(defsubst tramp-compat-tramp-syntax ()
385 "Return proper value of `tramp-syntax'."
386 (cond ((eq tramp-syntax 'ftp) 'default)
387 ((eq tramp-syntax 'sep) 'separate)
388 (t tramp-syntax)))
389
382(provide 'tramp-compat) 390(provide 'tramp-compat)
383 391
384;;; TODO: 392;;; TODO:
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index a6d3e78cfe2..818054676e4 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -662,29 +662,26 @@ Useful for \"rsync\" like methods.")
662(put 'tramp-temp-buffer-file-name 'permanent-local t) 662(put 'tramp-temp-buffer-file-name 'permanent-local t)
663 663
664;;;###autoload 664;;;###autoload
665(defcustom tramp-syntax 'def 665(defcustom tramp-syntax 'default
666 "Tramp filename syntax to be used. 666 "Tramp filename syntax to be used.
667 667
668It can have the following values: 668It can have the following values:
669 669
670 `def' -- Default syntax 670 `default' -- Default syntax
671 `ftp' -- Ange-FTP like syntax 671 `simplified' -- Ange-FTP like syntax
672 `sep' -- Syntax as defined for XEmacs originally." 672 `separate' -- Syntax as defined for XEmacs originally."
673 :group 'tramp 673 :group 'tramp
674 :version "26.1" 674 :version "26.1"
675 :package-version '(Tramp . "2.3.2") 675 :package-version '(Tramp . "2.3.2")
676 :type '(choice (const :tag "Default" def) 676 :type '(choice (const :tag "Default" default)
677 (const :tag "Ange-FTP" ftp) 677 (const :tag "Ange-FTP" simplified)
678 (const :tag "XEmacs" sep)) 678 (const :tag "XEmacs" separate))
679 :require 'tramp 679 :require 'tramp
680 :initialize 'custom-initialize-set 680 :initialize 'custom-initialize-set
681 :set (lambda (symbol value) 681 :set (lambda (symbol value)
682 ;; Check allowed values. 682 ;; Check allowed values.
683 (let ((values (cdr (get symbol 'custom-type)))) 683 (unless (memq value (tramp-syntax-values))
684 (setq values (mapcar 'last values) 684 (user-error "Wrong `tramp-syntax' %s" tramp-syntax))
685 values (mapcar 'car values))
686 (unless (member value values)
687 (user-error "Wrong `tramp-syntax' %s defined" tramp-syntax)))
688 ;; Cleanup existing buffers. 685 ;; Cleanup existing buffers.
689 (unless (eq (symbol-value symbol) value) 686 (unless (eq (symbol-value symbol) value)
690 (tramp-cleanup-all-buffers)) 687 (tramp-cleanup-all-buffers))
@@ -693,13 +690,19 @@ It can have the following values:
693 ;; Rearrange file name handlers. 690 ;; Rearrange file name handlers.
694 (tramp-register-file-name-handlers))) 691 (tramp-register-file-name-handlers)))
695 692
693(defun tramp-syntax-values ()
694 "Return possible values of `tramp-syntax', a list"
695 (let ((values (cdr (get 'tramp-syntax 'custom-type))))
696 (setq values (mapcar 'last values)
697 values (mapcar 'car values))))
698
696(defun tramp-prefix-format () 699(defun tramp-prefix-format ()
697 "String matching the very beginning of Tramp file names. 700 "String matching the very beginning of Tramp file names.
698Used in `tramp-make-tramp-file-name'." 701Used in `tramp-make-tramp-file-name'."
699 (cond ((eq tramp-syntax 'def) "/") 702 (cond ((eq (tramp-compat-tramp-syntax) 'default) "/")
700 ((eq tramp-syntax 'ftp) "/") 703 ((eq (tramp-compat-tramp-syntax) 'simplified) "/")
701 ((eq tramp-syntax 'sep) "/[") 704 ((eq (tramp-compat-tramp-syntax) 'separate) "/[")
702 (t (error "Wrong `tramp-syntax' %s defined" tramp-syntax)))) 705 (t (error "Wrong `tramp-syntax' %s" tramp-syntax))))
703 706
704(defun tramp-prefix-regexp () 707(defun tramp-prefix-regexp ()
705 "Regexp matching the very beginning of Tramp file names. 708 "Regexp matching the very beginning of Tramp file names.
@@ -709,16 +712,16 @@ Should always start with \"^\". Derived from `tramp-prefix-format'."
709(defun tramp-method-regexp () 712(defun tramp-method-regexp ()
710 "Regexp matching methods identifiers. 713 "Regexp matching methods identifiers.
711The `ftp' syntax does not support methods." 714The `ftp' syntax does not support methods."
712 (if (eq tramp-syntax 'ftp) "" "[a-zA-Z0-9-]+")) 715 (if (eq (tramp-compat-tramp-syntax) 'simplified) "" "[a-zA-Z0-9-]+"))
713 716
714(defun tramp-postfix-method-format () 717(defun tramp-postfix-method-format ()
715 "String matching delimiter between method and user or host names. 718 "String matching delimiter between method and user or host names.
716The `ftp' syntax does not support methods. 719The `ftp' syntax does not support methods.
717Used in `tramp-make-tramp-file-name'." 720Used in `tramp-make-tramp-file-name'."
718 (cond ((eq tramp-syntax 'def) ":") 721 (cond ((eq (tramp-compat-tramp-syntax) 'default) ":")
719 ((eq tramp-syntax 'ftp) "") 722 ((eq (tramp-compat-tramp-syntax) 'simplified) "")
720 ((eq tramp-syntax 'sep) "/") 723 ((eq (tramp-compat-tramp-syntax) 'separate) "/")
721 (t (error "Wrong `tramp-syntax' %s defined" tramp-syntax)))) 724 (t (error "Wrong `tramp-syntax' %s" tramp-syntax))))
722 725
723(defun tramp-postfix-method-regexp () 726(defun tramp-postfix-method-regexp ()
724 "Regexp matching delimiter between method and user or host names. 727 "Regexp matching delimiter between method and user or host names.
@@ -762,10 +765,10 @@ Derived from `tramp-postfix-user-format'.")
762(defun tramp-prefix-ipv6-format () 765(defun tramp-prefix-ipv6-format ()
763 "String matching left hand side of IPv6 addresses. 766 "String matching left hand side of IPv6 addresses.
764Used in `tramp-make-tramp-file-name'." 767Used in `tramp-make-tramp-file-name'."
765 (cond ((eq tramp-syntax 'def) "[") 768 (cond ((eq (tramp-compat-tramp-syntax) 'default) "[")
766 ((eq tramp-syntax 'ftp) "[") 769 ((eq (tramp-compat-tramp-syntax) 'simplified) "[")
767 ((eq tramp-syntax 'sep) "") 770 ((eq (tramp-compat-tramp-syntax) 'separate) "")
768 (t (error "Wrong `tramp-syntax' %s defined" tramp-syntax)))) 771 (t (error "Wrong `tramp-syntax' %s" tramp-syntax))))
769 772
770(defun tramp-prefix-ipv6-regexp () 773(defun tramp-prefix-ipv6-regexp ()
771 "Regexp matching left hand side of IPv6 addresses. 774 "Regexp matching left hand side of IPv6 addresses.
@@ -782,10 +785,10 @@ Derived from `tramp-prefix-ipv6-format'."
782(defun tramp-postfix-ipv6-format () 785(defun tramp-postfix-ipv6-format ()
783 "String matching right hand side of IPv6 addresses. 786 "String matching right hand side of IPv6 addresses.
784Used in `tramp-make-tramp-file-name'." 787Used in `tramp-make-tramp-file-name'."
785 (cond ((eq tramp-syntax 'def) "]") 788 (cond ((eq (tramp-compat-tramp-syntax) 'default) "]")
786 ((eq tramp-syntax 'ftp) "]") 789 ((eq (tramp-compat-tramp-syntax) 'simplified) "]")
787 ((eq tramp-syntax 'sep) "") 790 ((eq (tramp-compat-tramp-syntax) 'separate) "")
788 (t (error "Wrong `tramp-syntax' %s defined" tramp-syntax)))) 791 (t (error "Wrong `tramp-syntax' %s" tramp-syntax))))
789 792
790(defun tramp-postfix-ipv6-regexp () 793(defun tramp-postfix-ipv6-regexp ()
791 "Regexp matching right hand side of IPv6 addresses. 794 "Regexp matching right hand side of IPv6 addresses.
@@ -820,10 +823,10 @@ Derived from `tramp-postfix-hop-format'.")
820(defun tramp-postfix-host-format () 823(defun tramp-postfix-host-format ()
821 "String matching delimiter between host names and localnames. 824 "String matching delimiter between host names and localnames.
822Used in `tramp-make-tramp-file-name'." 825Used in `tramp-make-tramp-file-name'."
823 (cond ((eq tramp-syntax 'def) ":") 826 (cond ((eq (tramp-compat-tramp-syntax) 'default) ":")
824 ((eq tramp-syntax 'ftp) ":") 827 ((eq (tramp-compat-tramp-syntax) 'simplified) ":")
825 ((eq tramp-syntax 'sep) "]") 828 ((eq (tramp-compat-tramp-syntax) 'separate) "]")
826 (t (error "Wrong `tramp-syntax' %s defined" tramp-syntax)))) 829 (t (error "Wrong `tramp-syntax' %s" tramp-syntax))))
827 830
828(defun tramp-postfix-host-regexp () 831(defun tramp-postfix-host-regexp ()
829 "Regexp matching delimiter between host names and localnames. 832 "Regexp matching delimiter between host names and localnames.
@@ -890,7 +893,7 @@ This regexp should match Tramp file names but no other file names."
890It must match the initial `tramp-syntax' settings.") 893It must match the initial `tramp-syntax' settings.")
891 894
892;;;###autoload 895;;;###autoload
893(defconst tramp-completion-file-name-regexp-unified 896(defconst tramp-completion-file-name-regexp-default
894 (concat 897 (concat
895 "\\`/\\(" 898 "\\`/\\("
896 ;; Optional multi hop. 899 ;; Optional multi hop.
@@ -904,12 +907,12 @@ It must match the initial `tramp-syntax' settings.")
904 ;; Method separator, user name and host name. 907 ;; Method separator, user name and host name.
905 "\\(:[^/|:]*\\)?" 908 "\\(:[^/|:]*\\)?"
906 "\\)?\\'") 909 "\\)?\\'")
907 "Value for `tramp-completion-file-name-regexp' for unified remoting. 910 "Value for `tramp-completion-file-name-regexp' for default remoting.
908See `tramp-file-name-structure' for more explanations. 911See `tramp-file-name-structure' for more explanations.
909 912
910On W32 systems, the volume letter must be ignored.") 913On W32 systems, the volume letter must be ignored.")
911 914
912(defconst tramp-completion-file-name-regexp-old-style 915(defconst tramp-completion-file-name-regexp-simplified
913 (concat 916 (concat
914 "\\`/\\(" 917 "\\`/\\("
915 ;; Optional multi hop. 918 ;; Optional multi hop.
@@ -921,7 +924,7 @@ On W32 systems, the volume letter must be ignored.")
921 ;; At least one character. 924 ;; At least one character.
922 "[^/|:]+") 925 "[^/|:]+")
923 "\\)?\\'") 926 "\\)?\\'")
924 "Value for `tramp-completion-file-name-regexp' for ange-ftp style remoting. 927 "Value for `tramp-completion-file-name-regexp' for simplified style remoting.
925See `tramp-file-name-structure' for more explanations. 928See `tramp-file-name-structure' for more explanations.
926 929
927On W32 systems, the volume letter must be ignored.") 930On W32 systems, the volume letter must be ignored.")
@@ -941,14 +944,17 @@ before loading tramp.el. Alternatively, `file-name-handler-alist' can be
941updated after changing this variable. 944updated after changing this variable.
942 945
943Also see `tramp-file-name-structure'." 946Also see `tramp-file-name-structure'."
944 (cond ((eq tramp-syntax 'def) tramp-completion-file-name-regexp-unified) 947 (cond ((eq (tramp-compat-tramp-syntax) 'default)
945 ((eq tramp-syntax 'ftp) tramp-completion-file-name-regexp-old-style) 948 tramp-completion-file-name-regexp-default)
946 ((eq tramp-syntax 'sep) tramp-completion-file-name-regexp-separate) 949 ((eq (tramp-compat-tramp-syntax) 'simplified)
947 (t (error "Wrong `tramp-syntax' %s defined" tramp-syntax)))) 950 tramp-completion-file-name-regexp-simplified)
951 ((eq (tramp-compat-tramp-syntax) 'separate)
952 tramp-completion-file-name-regexp-separate)
953 (t (error "Wrong `tramp-syntax' %s" tramp-syntax))))
948 954
949;;;###autoload 955;;;###autoload
950(defconst tramp-initial-completion-file-name-regexp 956(defconst tramp-initial-completion-file-name-regexp
951 tramp-completion-file-name-regexp-unified 957 tramp-completion-file-name-regexp-default
952 "Value for `tramp-completion-file-name-regexp' for autoload. 958 "Value for `tramp-completion-file-name-regexp' for autoload.
953It must match the initial `tramp-syntax' settings.") 959It must match the initial `tramp-syntax' settings.")
954 960
@@ -1911,8 +1917,7 @@ coding system might not be determined. This function repairs it."
1911 ;; as regexp. 1917 ;; as regexp.
1912 (push (cons (regexp-quote tmpname) (cdr elt)) result))))) 1918 (push (cons (regexp-quote tmpname) (cdr elt)) result)))))
1913 1919
1914;;;###autoload 1920(defun tramp-run-real-handler (operation args)
1915(progn (defun tramp-run-real-handler (operation args)
1916 "Invoke normal file name handler for OPERATION. 1921 "Invoke normal file name handler for OPERATION.
1917First arg specifies the OPERATION, second arg is a list of arguments to 1922First arg specifies the OPERATION, second arg is a list of arguments to
1918pass to the OPERATION." 1923pass to the OPERATION."
@@ -1926,7 +1931,7 @@ pass to the OPERATION."
1926 ,(and (eq inhibit-file-name-operation operation) 1931 ,(and (eq inhibit-file-name-operation operation)
1927 inhibit-file-name-handlers))) 1932 inhibit-file-name-handlers)))
1928 (inhibit-file-name-operation operation)) 1933 (inhibit-file-name-operation operation))
1929 (apply operation args)))) 1934 (apply operation args)))
1930 1935
1931;; We handle here all file primitives. Most of them have the file 1936;; We handle here all file primitives. Most of them have the file
1932;; name as first parameter; nevertheless we check for them explicitly 1937;; name as first parameter; nevertheless we check for them explicitly