commit 291b76f91ea991c9fa8e57b55df1b68704931445 (HEAD, refs/remotes/origin/master) Author: Martin Rudalics Date: Tue Apr 11 08:29:41 2017 +0200 Set x_gtk_use_window_move by default for fixing bug#25851 and bug#25943 This activates a change that was installed a few weeks ago but whose ChangeLog was inadvertently dropped during its commit. The proper ChangeLog is included below as part of the present commit. * src/gtkutil.c (xg_set_geometry): When x_gtk_use_window_move is set avoid calling x_gtk_parse_geometry (Bug#25851). (x_wm_set_size_hint): When x_gtk_use_window_move is set, set PPosition, USPosition and USSize flags if requested. * src/xterm.c (x_set_offset): With GTK when x_gtk_use_window_move is set, leave it entirely to gtk_window_move to position the window and skip any post-adjustments (Bug#25851 and Bug#25943). (x_gtk_use_window_move): New variable. diff --git a/src/xterm.c b/src/xterm.c index 4f9eff6c5e..08ccac0700 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -12923,8 +12923,8 @@ transition between the various maximization states. */); DEFVAR_BOOL ("x-gtk-use-window-move", x_gtk_use_window_move, doc: /* Non-nil means rely on gtk_window_move to set frame positions. -If this variable is t, the GTK build uses the function gtk_window_move -to set or store frame positions and disables some time consuming frame -position adjustments. */); - x_gtk_use_window_move = false; +If this variable is t (the default), the GTK build uses the function +gtk_window_move to set or store frame positions and disables some time +consuming frame position adjustments. */); + x_gtk_use_window_move = true; } commit 230e25fd67fd654f04b8c744db0e170353a7f3b3 Author: Alan Mackenzie Date: Mon Apr 10 21:01:38 2017 +0000 Fix a loop in C Mode caused by inadequate analysis of comments. After M-;, and the insertion of the opening "/*", the CC Mode after-change function got confused, since the new comment opener matched the end of a subsequent comment, but moving back over that comment did not come back to the starting point. Fix this. * lisp/progmodes/cc-engine.el (c-end-of-macro): Add a limit parameter, wherer point is left if no end-of-macro is found before it. (c-forward-sws): Change the `safe-start' mechanism. Now `safe-start' is non-nil except where we have an unclosed block comment at the end of a macro. This enables us to populate the cache more fully, at the cost of some run time. diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index de15d1d82f..e7a8962ac2 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el @@ -319,34 +319,41 @@ comment at the start of cc-engine.el for more info." (goto-char here) nil)))))) -(defun c-end-of-macro () +(defun c-end-of-macro (&optional lim) "Go to the end of a preprocessor directive. More accurately, move the point to the end of the closest following line that doesn't end with a line continuation backslash - no check is done that the point is inside a cpp directive to begin with. +If LIM is provided, it is a limit position at which point is left +if the end of the macro doesn't occur earlier. + Note that this function might do hidden buffer changes. See the comment at the start of cc-engine.el for more info." - (if (and (cdr c-macro-cache) - (<= (point) (cdr c-macro-cache)) - (>= (point) (car c-macro-cache))) - (goto-char (cdr c-macro-cache)) - (unless (and (car c-macro-cache) - (<= (point) c-macro-cache-start-pos) - (>= (point) (car c-macro-cache))) - (setq c-macro-cache nil - c-macro-cache-start-pos nil - c-macro-cache-syntactic nil - c-macro-cache-no-comment nil)) - (while (progn - (end-of-line) - (when (and (eq (char-before) ?\\) - (not (eobp))) - (forward-char) - t))) - (when (car c-macro-cache) - (setcdr c-macro-cache (point)) - (setq c-macro-cache-syntactic nil)))) + (save-restriction + (if lim (narrow-to-region (point-min) lim)) + (if (and (cdr c-macro-cache) + (<= (point) (cdr c-macro-cache)) + (>= (point) (car c-macro-cache))) + (goto-char (cdr c-macro-cache)) + (unless (and (car c-macro-cache) + (<= (point) c-macro-cache-start-pos) + (>= (point) (car c-macro-cache))) + (setq c-macro-cache nil + c-macro-cache-start-pos nil + c-macro-cache-syntactic nil + c-macro-cache-no-comment nil)) + (while (progn + (end-of-line) + (when (and (eq (char-before) ?\\) + (not (eobp))) + (forward-char) + t))) + (when (and (car c-macro-cache) + (bolp) + (not (eq (char-before (1- (point))) ?\\))) + (setcdr c-macro-cache (point)) + (setq c-macro-cache-syntactic nil))))) (defun c-syntactic-end-of-macro () ;; Go to the end of a CPP directive, or a "safe" pos just before. @@ -1842,13 +1849,10 @@ comment at the start of cc-engine.el for more info." (let (;; `rung-pos' is set to a position as early as possible in the ;; unmarked part of the simple ws region. (rung-pos (point)) next-rung-pos rung-end-pos last-put-in-sws-pos - rung-is-marked next-rung-is-marked simple-ws-end + rung-is-marked next-rung-is-marked simple-ws-end macro-start macro-end ;; `safe-start' is set when it's safe to cache the start position. - ;; It's not set if we've initially skipped over comments and line - ;; continuations since we might have gone out through the end of a - ;; macro then. This provision makes `c-forward-sws' not populate the - ;; cache in the majority of cases, but otoh is `c-backward-sws' by far - ;; more common. + ;; This is the case except when we have an unterminated block comment + ;; within a macro. safe-start) ;; Skip simple ws and do a quick check on the following character to see @@ -1925,7 +1929,33 @@ comment at the start of cc-engine.el for more info." ;; Now move over any comments (x)or a CPP construct. (setq simple-ws-end (point)) - (c-forward-comments) + (setq safe-start t) + ;; Take elaborate precautions to detect an open block comment at + ;; the end of a macro. If we find one, we set `safe-start' to nil + ;; and break off any further scanning of comments. + (let ((com-begin (point)) com-end in-macro) + (when (and (c-forward-single-comment) + (setq com-end (point)) + (save-excursion + (goto-char com-begin) + (c-beginning-of-macro))) + (setq in-macro t) + (goto-char com-begin) + (if (progn (c-end-of-macro com-end) + (< (point) com-end)) + (setq safe-start nil))) + (if in-macro + (while (and safe-start + com-end (> com-end com-begin) + (setq com-begin (point)) + (when (and (c-forward-single-comment) + (setq com-end (point))) + (goto-char com-begin) + (if (progn (c-end-of-macro com-end) + (< (point) com-end)) + (setq safe-start nil)) + safe-start))) + (c-forward-comments))) (cond ((/= (point) simple-ws-end) @@ -1936,6 +1966,7 @@ comment at the start of cc-engine.el for more info." ((save-excursion (and c-opt-cpp-prefix (looking-at c-opt-cpp-start) + (setq macro-start (point)) (progn (skip-chars-backward " \t") (bolp)) (or (bobp) @@ -1946,8 +1977,20 @@ comment at the start of cc-engine.el for more info." (while (and (eq (char-before) ?\\) (= (forward-line 1) 0)) (end-of-line)) + (setq macro-end (point)) + ;; Check for an open block comment at the end of the macro. + (goto-char macro-start) + (let (s in-block-comment) + (while + (progn + (setq s (parse-partial-sexp (point) macro-end + nil nil s 'syntax-table)) + (< (point) macro-end)) + (setq in-block-comment + (and (elt s 4) ; in a comment + (null (elt s 7))))) ; a block comment + (if in-block-comment (setq safe-start nil))) (forward-line 1) - (setq safe-start t) ;; Don't cache at eob in case the buffer is narrowed. (not (eobp))) @@ -1955,7 +1998,6 @@ comment at the start of cc-engine.el for more info." (looking-at c-noise-macro-name-re)) ;; Skip over a noise macro. (goto-char (match-end 1)) - (setq safe-start t) (not (eobp))))) ;; We've searched over a piece of non-white syntactic ws. See if this @@ -2018,8 +2060,7 @@ comment at the start of cc-engine.el for more info." (if (setq rung-is-marked next-rung-is-marked) (setq rung-pos (1- (c-next-single-property-change rung-is-marked 'c-is-sws nil rung-end-pos))) - (setq rung-pos next-rung-pos)) - (setq safe-start t))) + (setq rung-pos next-rung-pos)))) ;; Make sure that the newly marked `c-in-sws' region doesn't connect to ;; another one after the point (which might occur when editing inside a commit 3ccd0ff1064a2836c379b13c2d5f4b11c5da1f88 Author: Lars Brinkhoff Date: Mon Apr 3 08:42:18 2017 +0200 Add PVSIZE function to return the size of a pseudovector. * src/lisp.h (PVSIZE): New function. * src/chartab.c (copy_char_table): * src/data.c (Ftype_of, Finteractive_form, Faref, Faset): * src/doc.c (Fdocumentation, store_function_docstring): * src/eval.c (Fcommandp, funcall_lambda, lambda_arity, Ffetch_bytecode): * src/fns.c (Flength, Fcopy_sequence): * src/font.h (FONT_SPEC_P, FONT_ENTITY_P, FONT_OBJECT_P): * src/lread.c (substitute_object_recurse): * src/src/print.c (print_object): Use it. diff --git a/src/chartab.c b/src/chartab.c index fa5a8e4116..8392c0c07d 100644 --- a/src/chartab.c +++ b/src/chartab.c @@ -185,7 +185,7 @@ Lisp_Object copy_char_table (Lisp_Object table) { Lisp_Object copy; - int size = XCHAR_TABLE (table)->header.size & PSEUDOVECTOR_SIZE_MASK; + int size = PVSIZE (table); int i; copy = Fmake_vector (make_number (size), Qnil); diff --git a/src/data.c b/src/data.c index 903e809d23..141b26ccf3 100644 --- a/src/data.c +++ b/src/data.c @@ -270,7 +270,7 @@ for example, (type-of 1) returns `integer'. */) case PVEC_RECORD: { Lisp_Object t = AREF (object, 0); - if (RECORDP (t) && 1 < (ASIZE (t) & PSEUDOVECTOR_SIZE_MASK)) + if (RECORDP (t) && 1 < PVSIZE (t)) /* Return the type name field of the class! */ return AREF (t, 1); else @@ -902,7 +902,7 @@ Value, if non-nil, is a list (interactive SPEC). */) } else if (COMPILEDP (fun)) { - if ((ASIZE (fun) & PSEUDOVECTOR_SIZE_MASK) > COMPILED_INTERACTIVE) + if (PVSIZE (fun) > COMPILED_INTERACTIVE) return list2 (Qinteractive, AREF (fun, COMPILED_INTERACTIVE)); } else if (AUTOLOADP (fun)) @@ -2306,7 +2306,7 @@ or a byte-code object. IDX starts at 0. */) if (VECTORP (array)) size = ASIZE (array); else if (COMPILEDP (array) || RECORDP (array)) - size = ASIZE (array) & PSEUDOVECTOR_SIZE_MASK; + size = PVSIZE (array); else wrong_type_argument (Qarrayp, array); @@ -2349,8 +2349,7 @@ bool-vector. IDX starts at 0. */) } else if (RECORDP (array)) { - ptrdiff_t size = ASIZE (array) & PSEUDOVECTOR_SIZE_MASK; - if (idxval < 0 || idxval >= size) + if (idxval < 0 || idxval >= PVSIZE (array)) args_out_of_range (array, idx); ASET (array, idxval, newelt); } diff --git a/src/doc.c b/src/doc.c index 1e7e3fcf6a..dd674e3bc0 100644 --- a/src/doc.c +++ b/src/doc.c @@ -342,7 +342,7 @@ string is passed through `substitute-command-keys'. */) doc = make_number (XSUBR (fun)->doc); else if (COMPILEDP (fun)) { - if ((ASIZE (fun) & PSEUDOVECTOR_SIZE_MASK) <= COMPILED_DOC_STRING) + if (PVSIZE (fun) <= COMPILED_DOC_STRING) return Qnil; else { @@ -500,7 +500,7 @@ store_function_docstring (Lisp_Object obj, EMACS_INT offset) { /* This bytecode object must have a slot for the docstring, since we've found a docstring for it. */ - if ((ASIZE (fun) & PSEUDOVECTOR_SIZE_MASK) > COMPILED_DOC_STRING) + if (PVSIZE (fun) > COMPILED_DOC_STRING) ASET (fun, COMPILED_DOC_STRING, make_number (offset)); else { diff --git a/src/eval.c b/src/eval.c index 16d1cf810e..af0912fd14 100644 --- a/src/eval.c +++ b/src/eval.c @@ -1881,8 +1881,7 @@ then strings and vectors are not accepted. */) have an element whose index is COMPILED_INTERACTIVE, which is where the interactive spec is stored. */ else if (COMPILEDP (fun)) - return ((ASIZE (fun) & PSEUDOVECTOR_SIZE_MASK) > COMPILED_INTERACTIVE - ? Qt : if_prop); + return (PVSIZE (fun) > COMPILED_INTERACTIVE ? Qt : if_prop); /* Strings and vectors are keyboard macros. */ if (STRINGP (fun) || VECTORP (fun)) @@ -2922,7 +2921,7 @@ funcall_lambda (Lisp_Object fun, ptrdiff_t nargs, } else if (COMPILEDP (fun)) { - ptrdiff_t size = ASIZE (fun) & PSEUDOVECTOR_SIZE_MASK; + ptrdiff_t size = PVSIZE (fun); if (size <= COMPILED_STACK_DEPTH) xsignal1 (Qinvalid_function, fun); syms_left = AREF (fun, COMPILED_ARGLIST); @@ -3103,7 +3102,7 @@ lambda_arity (Lisp_Object fun) } else if (COMPILEDP (fun)) { - ptrdiff_t size = ASIZE (fun) & PSEUDOVECTOR_SIZE_MASK; + ptrdiff_t size = PVSIZE (fun); if (size <= COMPILED_STACK_DEPTH) xsignal1 (Qinvalid_function, fun); syms_left = AREF (fun, COMPILED_ARGLIST); @@ -3148,7 +3147,7 @@ DEFUN ("fetch-bytecode", Ffetch_bytecode, Sfetch_bytecode, if (COMPILEDP (object)) { - ptrdiff_t size = ASIZE (object) & PSEUDOVECTOR_SIZE_MASK; + ptrdiff_t size = PVSIZE (object); if (size <= COMPILED_STACK_DEPTH) xsignal1 (Qinvalid_function, object); if (CONSP (AREF (object, COMPILED_BYTECODE))) diff --git a/src/fns.c b/src/fns.c index 2f07c2ccfb..10d35b6112 100644 --- a/src/fns.c +++ b/src/fns.c @@ -107,7 +107,7 @@ To get the number of bytes, use `string-bytes'. */) else if (BOOL_VECTOR_P (sequence)) XSETFASTINT (val, bool_vector_size (sequence)); else if (COMPILEDP (sequence) || RECORDP (sequence)) - XSETFASTINT (val, ASIZE (sequence) & PSEUDOVECTOR_SIZE_MASK); + XSETFASTINT (val, PVSIZE (sequence)); else if (CONSP (sequence)) { intptr_t i = 0; @@ -484,8 +484,7 @@ shared with the original. */) if (RECORDP (arg)) { - ptrdiff_t size = ASIZE (arg) & PSEUDOVECTOR_SIZE_MASK; - return Frecord (size, XVECTOR (arg)->contents); + return Frecord (PVSIZE (arg), XVECTOR (arg)->contents); } if (CHAR_TABLE_P (arg)) diff --git a/src/font.h b/src/font.h index a469b20e4f..53e3fc21a3 100644 --- a/src/font.h +++ b/src/font.h @@ -424,7 +424,7 @@ FONTP (Lisp_Object x) INLINE bool FONT_SPEC_P (Lisp_Object x) { - return FONTP (x) && (ASIZE (x) & PSEUDOVECTOR_SIZE_MASK) == FONT_SPEC_MAX; + return FONTP (x) && PVSIZE (x) == FONT_SPEC_MAX; } /* Like FONT_SPEC_P, but can be used in the garbage collector. */ @@ -438,7 +438,7 @@ GC_FONT_SPEC_P (Lisp_Object x) INLINE bool FONT_ENTITY_P (Lisp_Object x) { - return FONTP (x) && (ASIZE (x) & PSEUDOVECTOR_SIZE_MASK) == FONT_ENTITY_MAX; + return FONTP (x) && PVSIZE (x) == FONT_ENTITY_MAX; } /* Like FONT_ENTITY_P, but can be used in the garbage collector. */ @@ -452,7 +452,7 @@ GC_FONT_ENTITY_P (Lisp_Object x) INLINE bool FONT_OBJECT_P (Lisp_Object x) { - return FONTP (x) && (ASIZE (x) & PSEUDOVECTOR_SIZE_MASK) == FONT_OBJECT_MAX; + return FONTP (x) && PVSIZE (x) == FONT_OBJECT_MAX; } /* Like FONT_OBJECT_P, but can be used in the garbage collector. */ diff --git a/src/lisp.h b/src/lisp.h index 5e7d41bc5d..678e261c1d 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -1401,6 +1401,12 @@ ASIZE (Lisp_Object array) return size; } +INLINE ptrdiff_t +PVSIZE (Lisp_Object pv) +{ + return ASIZE (pv) & PSEUDOVECTOR_SIZE_MASK; +} + INLINE bool VECTORP (Lisp_Object x) { diff --git a/src/lread.c b/src/lread.c index 513f63e431..3b2e123dd3 100644 --- a/src/lread.c +++ b/src/lread.c @@ -3402,7 +3402,7 @@ substitute_object_recurse (Lisp_Object object, Lisp_Object placeholder, Lisp_Obj else if (CHAR_TABLE_P (subtree) || SUB_CHAR_TABLE_P (subtree) || COMPILEDP (subtree) || HASH_TABLE_P (subtree) || RECORDP (subtree)) - length = ASIZE (subtree) & PSEUDOVECTOR_SIZE_MASK; + length = PVSIZE (subtree); else if (VECTORP (subtree)) length = ASIZE (subtree); else diff --git a/src/print.c b/src/print.c index 76f263994e..872103bd4c 100644 --- a/src/print.c +++ b/src/print.c @@ -1966,7 +1966,7 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag) case PVEC_RECORD: { - ptrdiff_t n, size = ASIZE (obj) & PSEUDOVECTOR_SIZE_MASK; + ptrdiff_t n, size = PVSIZE (obj); int i; /* Don't print more elements than the specified maximum. */ commit dd42ca427cf8a890678f574de43685ae70416491 Author: Michael Albinus Date: Mon Apr 10 17:22:13 2017 +0200 Add Tramp tests * lisp/net/tramp.el (tramp-syntax): Adapt docstring. * test/lisp/net/tramp-tests.el (tramp-test01-file-name-syntax-simplified) (tramp-test01-file-name-syntax-separate) (tramp-test02-file-name-dissect-simplified) (tramp-test02-file-name-dissect-separate): New tests. diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index eb32bd6e0e..12169d473e 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -669,7 +669,10 @@ It can have the following values: `default' -- Default syntax `simplified' -- Ange-FTP like syntax - `separate' -- Syntax as defined for XEmacs originally." + `separate' -- Syntax as defined for XEmacs originally + +Do not change the value by `setq', it must be changed only by +`custom-set-variables'. See also `tramp-change-syntax'." :group 'tramp :version "26.1" :package-version '(Tramp . "2.3.2") diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index ba00a96cfd..9dcb3ec976 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el @@ -213,6 +213,115 @@ handled properly. BODY shall not contain a timeout." (should (tramp-tramp-file-p "/-:h:/path/to/file")) (should (tramp-tramp-file-p "/m::/path/to/file")))) +(ert-deftest tramp-test01-file-name-syntax-simplified () + "Check simplified file name syntax." + :tags '(:expensive-test) + (let ((syntax tramp-syntax)) + (unwind-protect + (progn + (tramp-change-syntax 'simplified) + ;; Simple cases. + (should (tramp-tramp-file-p "/host:")) + (should (tramp-tramp-file-p "/user@:")) + (should (tramp-tramp-file-p "/user@host:")) + (should (tramp-tramp-file-p "/user@email@host:")) + + ;; Using a port. + (should (tramp-tramp-file-p "/host#1234:")) + (should (tramp-tramp-file-p "/user@host#1234:")) + + ;; Using an IPv4 address. + (should (tramp-tramp-file-p "/1.2.3.4:")) + (should (tramp-tramp-file-p "/user@1.2.3.4:")) + + ;; Using an IPv6 address. + (should (tramp-tramp-file-p "/[::1]:")) + (should (tramp-tramp-file-p "/user@[::1]:")) + + ;; Local file name part. + (should (tramp-tramp-file-p "/host::")) + (should (tramp-tramp-file-p "/host:/:")) + (should (tramp-tramp-file-p "/host:/path/to/file")) + (should (tramp-tramp-file-p "/host:/:/path/to/file")) + (should (tramp-tramp-file-p "/host:file")) + (should (tramp-tramp-file-p "/host:/:file")) + + ;; Multihop. + (should (tramp-tramp-file-p "/host1|host2:")) + (should (tramp-tramp-file-p "/user1@host1|user2@host2:")) + (should (tramp-tramp-file-p "/user1@host1|user2@host2|user3@host3:")) + + ;; No strings. + (should-not (tramp-tramp-file-p nil)) + (should-not (tramp-tramp-file-p 'symbol)) + ;; Quote with "/:" suppresses file name handlers. + (should-not (tramp-tramp-file-p "/::")) + (should-not (tramp-tramp-file-p "/:@:")) + (should-not (tramp-tramp-file-p "/:[]:"))) + + ;; Exit. + (tramp-change-syntax syntax)))) + +(ert-deftest tramp-test01-file-name-syntax-separate () + "Check separate file name syntax." + :tags '(:expensive-test) + (let ((syntax tramp-syntax)) + (unwind-protect + (progn + (tramp-change-syntax 'separate) + ;; Simple cases. + (should (tramp-tramp-file-p "/[method/]")) + (should (tramp-tramp-file-p "/[method/host]")) + (should (tramp-tramp-file-p "/[method/user@]")) + (should (tramp-tramp-file-p "/[method/user@host]")) + (should (tramp-tramp-file-p "/[method/user@email@host]")) + + ;; Using a port. + (should (tramp-tramp-file-p "/[method/host#1234]")) + (should (tramp-tramp-file-p "/[method/user@host#1234]")) + + ;; Using an IPv4 address. + (should (tramp-tramp-file-p "/[method/1.2.3.4]")) + (should (tramp-tramp-file-p "/[method/user@1.2.3.4]")) + + ;; Using an IPv6 address. + (should (tramp-tramp-file-p "/[method/::1]")) + (should (tramp-tramp-file-p "/[method/user@::1]")) + + ;; Local file name part. + (should (tramp-tramp-file-p "/[method/]")) + (should (tramp-tramp-file-p "/[method/]/:")) + (should (tramp-tramp-file-p "/[method/]/path/to/file")) + (should (tramp-tramp-file-p "/[method/]/:/path/to/file")) + (should (tramp-tramp-file-p "/[method/]file")) + (should (tramp-tramp-file-p "/[method/]/:file")) + + ;; Multihop. + (should (tramp-tramp-file-p "/[method1/|method2/]")) + (should (tramp-tramp-file-p "/[method1/host1|method2/host2]")) + (should + (tramp-tramp-file-p + "/[method1/user1@host1|method2/user2@host2]")) + (should + (tramp-tramp-file-p + "/[method1/user1@host1|method2/user2@host2|method3/user3@host3]")) + + ;; No strings. + (should-not (tramp-tramp-file-p nil)) + (should-not (tramp-tramp-file-p 'symbol)) + ;; Ange-ftp syntax. + (should-not (tramp-tramp-file-p "/host:")) + (should-not (tramp-tramp-file-p "/user@host:")) + (should-not (tramp-tramp-file-p "/1.2.3.4:")) + (should-not (tramp-tramp-file-p "/host:/:")) + (should-not (tramp-tramp-file-p "/host1|host2:")) + (should-not (tramp-tramp-file-p "/user1@host1|user2@host2:")) + ;; Quote with "/:" suppresses file name handlers. + (should-not (tramp-tramp-file-p "/:[]"))) + + ;; Exit. + (tramp-change-syntax syntax)))) + (ert-deftest tramp-test02-file-name-dissect () "Check remote file name components." (let ((tramp-default-method "default-method") @@ -569,6 +678,683 @@ handled properly. BODY shall not contain a timeout." (format "%s:%s@%s|%s:%s@%s|" "method1" "user1" "host1" "method2" "user2" "host2"))))) +(ert-deftest tramp-test02-file-name-dissect-simplified () + "Check simplified file name components." + :tags '(:expensive-test) + (let ((tramp-default-method "default-method") + (tramp-default-user "default-user") + (tramp-default-host "default-host") + (syntax tramp-syntax)) + (unwind-protect + (progn + (tramp-change-syntax 'simplified) + ;; Expand `tramp-default-method' and `tramp-default-user'. + (should (string-equal + (file-remote-p "/host:") + (format "/%s@%s:" "default-user" "host"))) + (should (string-equal + (file-remote-p "/host:" 'method) "default-method")) + (should (string-equal (file-remote-p "/host:" 'user) "default-user")) + (should (string-equal (file-remote-p "/host:" 'host) "host")) + (should (string-equal (file-remote-p "/host:" 'localname) "")) + (should (string-equal (file-remote-p "/host:" 'hop) nil)) + + ;; Expand `tramp-default-method' and `tramp-default-host'. + (should (string-equal + (file-remote-p "/user@:") + (format "/%s@%s:" "user" "default-host"))) + (should (string-equal + (file-remote-p "/user@:" 'method) "default-method")) + (should (string-equal (file-remote-p "/user@:" 'user) "user")) + (should (string-equal (file-remote-p "/user@:" 'host) "default-host")) + (should (string-equal (file-remote-p "/user@:" 'localname) "")) + (should (string-equal (file-remote-p "/user@:" 'hop) nil)) + + ;; Expand `tramp-default-method'. + (should (string-equal + (file-remote-p "/user@host:") + (format "/%s@%s:" "user" "host"))) + (should (string-equal + (file-remote-p "/user@host:" 'method) "default-method")) + (should (string-equal (file-remote-p "/user@host:" 'user) "user")) + (should (string-equal (file-remote-p "/user@host:" 'host) "host")) + (should (string-equal (file-remote-p "/user@host:" 'localname) "")) + (should (string-equal (file-remote-p "/user@host:" 'hop) nil)) + + ;; No expansion. + (should (string-equal + (file-remote-p "/user@email@host:") + (format "/%s@%s:" "user@email" "host"))) + (should (string-equal + (file-remote-p + "/user@email@host:" 'method) "default-method")) + (should (string-equal + (file-remote-p "/user@email@host:" 'user) "user@email")) + (should (string-equal + (file-remote-p "/user@email@host:" 'host) "host")) + (should (string-equal + (file-remote-p "/user@email@host:" 'localname) "")) + (should (string-equal + (file-remote-p "/user@email@host:" 'hop) nil)) + + ;; Expand `tramp-default-method' and `tramp-default-user'. + (should (string-equal + (file-remote-p "/host#1234:") + (format "/%s@%s:" "default-user" "host#1234"))) + (should (string-equal + (file-remote-p "/host#1234:" 'method) "default-method")) + (should (string-equal + (file-remote-p "/host#1234:" 'user) "default-user")) + (should (string-equal + (file-remote-p "/host#1234:" 'host) "host#1234")) + (should (string-equal (file-remote-p "/host#1234:" 'localname) "")) + (should (string-equal (file-remote-p "/host#1234:" 'hop) nil)) + + ;; Expand `tramp-default-method'. + (should (string-equal + (file-remote-p "/user@host#1234:") + (format "/%s@%s:" "user" "host#1234"))) + (should (string-equal + (file-remote-p "/user@host#1234:" 'method) "default-method")) + (should (string-equal + (file-remote-p "/user@host#1234:" 'user) "user")) + (should (string-equal + (file-remote-p "/user@host#1234:" 'host) "host#1234")) + (should (string-equal + (file-remote-p "/user@host#1234:" 'localname) "")) + (should (string-equal (file-remote-p "/user@host#1234:" 'hop) nil)) + + ;; Expand `tramp-default-method' and `tramp-default-user'. + (should (string-equal + (file-remote-p "/1.2.3.4:") + (format "/%s@%s:" "default-user" "1.2.3.4"))) + (should (string-equal + (file-remote-p "/1.2.3.4:" 'method) "default-method")) + (should (string-equal + (file-remote-p "/1.2.3.4:" 'user) "default-user")) + (should (string-equal (file-remote-p "/1.2.3.4:" 'host) "1.2.3.4")) + (should (string-equal (file-remote-p "/1.2.3.4:" 'localname) "")) + (should (string-equal (file-remote-p "/1.2.3.4:" 'hop) nil)) + + ;; Expand `tramp-default-method'. + (should (string-equal + (file-remote-p "/user@1.2.3.4:") + (format "/%s@%s:" "user" "1.2.3.4"))) + (should (string-equal + (file-remote-p "/user@1.2.3.4:" 'method) "default-method")) + (should (string-equal (file-remote-p "/user@1.2.3.4:" 'user) "user")) + (should (string-equal + (file-remote-p "/user@1.2.3.4:" 'host) "1.2.3.4")) + (should (string-equal (file-remote-p "/user@1.2.3.4:" 'localname) "")) + (should (string-equal (file-remote-p "/user@1.2.3.4:" 'hop) nil)) + + ;; Expand `tramp-default-method', `tramp-default-user' and + ;; `tramp-default-host'. + (should (string-equal + (file-remote-p "/[]:") + (format + "/%s@%s:" "default-user" "default-host"))) + (should (string-equal + (file-remote-p "/[]:" 'method) "default-method")) + (should (string-equal (file-remote-p "/[]:" 'user) "default-user")) + (should (string-equal (file-remote-p "/[]:" 'host) "default-host")) + (should (string-equal (file-remote-p "/[]:" 'localname) "")) + (should (string-equal (file-remote-p "/[]:" 'hop) nil)) + + ;; Expand `tramp-default-method' and `tramp-default-user'. + (let ((tramp-default-host "::1")) + (should (string-equal + (file-remote-p "/[]:") + (format "/%s@%s:" "default-user" "[::1]"))) + (should (string-equal + (file-remote-p "/[]:" 'method) "default-method")) + (should (string-equal (file-remote-p "/[]:" 'user) "default-user")) + (should (string-equal (file-remote-p "/[]:" 'host) "::1")) + (should (string-equal (file-remote-p "/[]:" 'localname) "")) + (should (string-equal (file-remote-p "/[]:" 'hop) nil))) + + ;; Expand `tramp-default-method' and `tramp-default-user'. + (should (string-equal + (file-remote-p "/[::1]:") + (format "/%s@%s:" "default-user" "[::1]"))) + (should (string-equal + (file-remote-p "/[::1]:" 'method) "default-method")) + (should (string-equal (file-remote-p "/[::1]:" 'user) "default-user")) + (should (string-equal (file-remote-p "/[::1]:" 'host) "::1")) + (should (string-equal (file-remote-p "/[::1]:" 'localname) "")) + (should (string-equal (file-remote-p "/[::1]:" 'hop) nil)) + + ;; Expand `tramp-default-method'. + (should (string-equal + (file-remote-p "/user@[::1]:") + (format "/%s@%s:" "user" "[::1]"))) + (should (string-equal + (file-remote-p "/user@[::1]:" 'method) "default-method")) + (should (string-equal (file-remote-p "/user@[::1]:" 'user) "user")) + (should (string-equal (file-remote-p "/user@[::1]:" 'host) "::1")) + (should (string-equal (file-remote-p "/user@[::1]:" 'localname) "")) + (should (string-equal (file-remote-p "/user@[::1]:" 'hop) nil)) + + ;; Local file name part. + (should (string-equal (file-remote-p "/host:/:" 'localname) "/:")) + (should (string-equal (file-remote-p "/host::" 'localname) ":")) + (should (string-equal (file-remote-p "/host: " 'localname) " ")) + (should (string-equal (file-remote-p "/host:file" 'localname) "file")) + (should (string-equal + (file-remote-p "/host:/path/to/file" 'localname) + "/path/to/file")) + + ;; Multihop. + (should + (string-equal + (file-remote-p "/user1@host1|user2@host2:/path/to/file") + (format "/%s@%s|%s@%s:" "user1" "host1" "user2" "host2"))) + (should + (string-equal + (file-remote-p + "/user1@host1|user2@host2:/path/to/file" 'method) + "default-method")) + (should + (string-equal + (file-remote-p + "/user1@host1|user2@host2:/path/to/file" 'user) + "user2")) + (should + (string-equal + (file-remote-p + "/user1@host1|user2@host2:/path/to/file" 'host) + "host2")) + (should + (string-equal + (file-remote-p + "/user1@host1|user2@host2:/path/to/file" 'localname) + "/path/to/file")) + (should + (string-equal + (file-remote-p + "/user1@host1|user2@host2:/path/to/file" 'hop) + (format "%s@%s|" "user1" "host1"))) + + (should + (string-equal + (file-remote-p + (concat + "/user1@host1" + "|user2@host2" + "|user3@host3:/path/to/file")) + (format "/%s@%s|%s@%s|%s@%s:" + "user1" "host1" + "user2" "host2" + "user3" "host3"))) + (should + (string-equal + (file-remote-p + (concat + "/user1@host1" + "|user2@host2" + "|user3@host3:/path/to/file") + 'method) + "default-method")) + (should + (string-equal + (file-remote-p + (concat + "/user1@host1" + "|user2@host2" + "|user3@host3:/path/to/file") + 'user) + "user3")) + (should + (string-equal + (file-remote-p + (concat + "/user1@host1" + "|user2@host2" + "|user3@host3:/path/to/file") + 'host) + "host3")) + (should + (string-equal + (file-remote-p + (concat + "/user1@host1" + "|user2@host2" + "|user3@host3:/path/to/file") + 'localname) + "/path/to/file")) + (should + (string-equal + (file-remote-p + (concat + "/user1@host1" + "|user2@host2" + "|user3@host3:/path/to/file") + 'hop) + (format "%s@%s|%s@%s|" + "user1" "host1" "user2" "host2")))) + + ;; Exit. + (tramp-change-syntax syntax)))) + +(ert-deftest tramp-test02-file-name-dissect-separate () + "Check separate file name components." + :tags '(:expensive-test) + (let ((tramp-default-method "default-method") + (tramp-default-user "default-user") + (tramp-default-host "default-host") + (syntax tramp-syntax)) + (unwind-protect + (progn + (tramp-change-syntax 'separate) + ;; Expand `tramp-default-user' and `tramp-default-host'. + (should (string-equal + (file-remote-p "/[method/]") + (format + "/[%s/%s@%s]" "method" "default-user" "default-host"))) + (should (string-equal (file-remote-p "/[method/]" 'method) "method")) + (should (string-equal + (file-remote-p "/[method/]" 'user) "default-user")) + (should (string-equal + (file-remote-p "/[method/]" 'host) "default-host")) + (should (string-equal (file-remote-p "/[method/]" 'localname) "")) + (should (string-equal (file-remote-p "/[method/]" 'hop) nil)) + + ;; Expand `tramp-default-method' and `tramp-default-user'. + (should (string-equal + (file-remote-p "/[-/host]") + (format + "/[%s/%s@%s]" "default-method" "default-user" "host"))) + (should (string-equal + (file-remote-p "/[-/host]" 'method) "default-method")) + (should (string-equal + (file-remote-p "/[-/host]" 'user) "default-user")) + (should (string-equal (file-remote-p "/[-/host]" 'host) "host")) + (should (string-equal (file-remote-p "/[-/host]" 'localname) "")) + (should (string-equal (file-remote-p "/[-/host]" 'hop) nil)) + + ;; Expand `tramp-default-method' and `tramp-default-host'. + (should (string-equal + (file-remote-p "/[-/user@]") + (format + "/[%s/%s@%s]" "default-method" "user" "default-host"))) + (should (string-equal + (file-remote-p "/[-/user@]" 'method) "default-method")) + (should (string-equal (file-remote-p "/[-/user@]" 'user) "user")) + (should (string-equal + (file-remote-p "/[-/user@]" 'host) "default-host")) + (should (string-equal (file-remote-p "/[-/user@]" 'localname) "")) + (should (string-equal (file-remote-p "/[-/user@]" 'hop) nil)) + + ;; Expand `tramp-default-method'. + (should (string-equal + (file-remote-p "/[-/user@host]") + (format "/[%s/%s@%s]" "default-method" "user" "host"))) + (should (string-equal + (file-remote-p "/[-/user@host]" 'method) "default-method")) + (should (string-equal (file-remote-p "/[-/user@host]" 'user) "user")) + (should (string-equal (file-remote-p "/[-/user@host]" 'host) "host")) + (should (string-equal (file-remote-p "/[-/user@host]" 'localname) "")) + (should (string-equal (file-remote-p "/[-/user@host]" 'hop) nil)) + + ;; Expand `tramp-default-user'. + (should (string-equal + (file-remote-p "/[method/host]") + (format "/[%s/%s@%s]" "method" "default-user" "host"))) + (should (string-equal + (file-remote-p "/[method/host]" 'method) "method")) + (should (string-equal + (file-remote-p "/[method/host]" 'user) "default-user")) + (should (string-equal (file-remote-p "/[method/host]" 'host) "host")) + (should (string-equal (file-remote-p "/[method/host]" 'localname) "")) + (should (string-equal (file-remote-p "/[method/host]" 'hop) nil)) + + ;; Expand `tramp-default-host'. + (should (string-equal + (file-remote-p "/[method/user@]") + (format "/[%s/%s@%s]" "method" "user" "default-host"))) + (should (string-equal + (file-remote-p "/[method/user@]" 'method) "method")) + (should (string-equal (file-remote-p "/[method/user@]" 'user) "user")) + (should (string-equal + (file-remote-p "/[method/user@]" 'host) "default-host")) + (should (string-equal + (file-remote-p "/[method/user@]" 'localname) "")) + (should (string-equal (file-remote-p "/[method/user@]" 'hop) nil)) + + ;; No expansion. + (should (string-equal + (file-remote-p "/[method/user@host]") + (format "/[%s/%s@%s]" "method" "user" "host"))) + (should (string-equal + (file-remote-p "/[method/user@host]" 'method) "method")) + (should (string-equal + (file-remote-p "/[method/user@host]" 'user) "user")) + (should (string-equal + (file-remote-p "/[method/user@host]" 'host) "host")) + (should (string-equal + (file-remote-p "/[method/user@host]" 'localname) "")) + (should (string-equal + (file-remote-p "/[method/user@host]" 'hop) nil)) + + ;; No expansion. + (should (string-equal + (file-remote-p "/[method/user@email@host]") + (format "/[%s/%s@%s]" "method" "user@email" "host"))) + (should (string-equal + (file-remote-p + "/[method/user@email@host]" 'method) "method")) + (should (string-equal + (file-remote-p + "/[method/user@email@host]" 'user) "user@email")) + (should (string-equal + (file-remote-p "/[method/user@email@host]" 'host) "host")) + (should (string-equal + (file-remote-p "/[method/user@email@host]" 'localname) "")) + (should (string-equal + (file-remote-p "/[method/user@email@host]" 'hop) nil)) + + ;; Expand `tramp-default-method' and `tramp-default-user'. + (should (string-equal + (file-remote-p "/[-/host#1234]") + (format + "/[%s/%s@%s]" "default-method" "default-user" "host#1234"))) + (should (string-equal + (file-remote-p "/[-/host#1234]" 'method) "default-method")) + (should (string-equal + (file-remote-p "/[-/host#1234]" 'user) "default-user")) + (should (string-equal + (file-remote-p "/[-/host#1234]" 'host) "host#1234")) + (should (string-equal (file-remote-p "/[-/host#1234]" 'localname) "")) + (should (string-equal (file-remote-p "/[-/host#1234]" 'hop) nil)) + + ;; Expand `tramp-default-method'. + (should (string-equal + (file-remote-p "/[-/user@host#1234]") + (format "/[%s/%s@%s]" "default-method" "user" "host#1234"))) + (should (string-equal + (file-remote-p + "/[-/user@host#1234]" 'method) "default-method")) + (should (string-equal + (file-remote-p + "/[-/user@host#1234]" 'user) "user")) + (should (string-equal + (file-remote-p "/[-/user@host#1234]" 'host) "host#1234")) + (should (string-equal + (file-remote-p "/[-/user@host#1234]" 'localname) "")) + (should (string-equal (file-remote-p "/[-/user@host#1234]" 'hop) nil)) + + ;; Expand `tramp-default-user'. + (should (string-equal + (file-remote-p "/[method/host#1234]") + (format "/[%s/%s@%s]" "method" "default-user" "host#1234"))) + (should (string-equal + (file-remote-p "/[method/host#1234]" 'method) "method")) + (should (string-equal + (file-remote-p "/[method/host#1234]" 'user) "default-user")) + (should (string-equal + (file-remote-p "/[method/host#1234]" 'host) "host#1234")) + (should (string-equal + (file-remote-p "/[method/host#1234]" 'localname) "")) + (should (string-equal (file-remote-p "/[method/host#1234]" 'hop) nil)) + + ;; No expansion. + (should (string-equal + (file-remote-p "/[method/user@host#1234]") + (format "/[%s/%s@%s]" "method" "user" "host#1234"))) + (should (string-equal + (file-remote-p "/[method/user@host#1234]" 'method) "method")) + (should (string-equal + (file-remote-p "/[method/user@host#1234]" 'user) "user")) + (should (string-equal + (file-remote-p + "/[method/user@host#1234]" 'host) "host#1234")) + (should (string-equal + (file-remote-p "/[method/user@host#1234]" 'localname) "")) + (should (string-equal + (file-remote-p "/[method/user@host#1234]" 'hop) nil)) + + ;; Expand `tramp-default-method' and `tramp-default-user'. + (should (string-equal + (file-remote-p "/[-/1.2.3.4]") + (format + "/[%s/%s@%s]" "default-method" "default-user" "1.2.3.4"))) + (should (string-equal + (file-remote-p "/[-/1.2.3.4]" 'method) "default-method")) + (should (string-equal + (file-remote-p "/[-/1.2.3.4]" 'user) "default-user")) + (should (string-equal + (file-remote-p "/[-/1.2.3.4]" 'host) "1.2.3.4")) + (should (string-equal (file-remote-p "/[-/1.2.3.4]" 'localname) "")) + (should (string-equal (file-remote-p "/[-/1.2.3.4]" 'hop) nil)) + + ;; Expand `tramp-default-method'. + (should (string-equal + (file-remote-p "/[-/user@1.2.3.4]") + (format "/[%s/%s@%s]" "default-method" "user" "1.2.3.4"))) + (should (string-equal + (file-remote-p + "/[-/user@1.2.3.4]" 'method) "default-method")) + (should (string-equal + (file-remote-p "/[-/user@1.2.3.4]" 'user) "user")) + (should (string-equal + (file-remote-p "/[-/user@1.2.3.4]" 'host) "1.2.3.4")) + (should (string-equal + (file-remote-p "/[-/user@1.2.3.4]" 'localname) "")) + (should (string-equal (file-remote-p "/[-/user@1.2.3.4]" 'hop) nil)) + + ;; Expand `tramp-default-user'. + (should (string-equal + (file-remote-p "/[method/1.2.3.4]") + (format "/[%s/%s@%s]" "method" "default-user" "1.2.3.4"))) + (should (string-equal + (file-remote-p "/[method/1.2.3.4]" 'method) "method")) + (should (string-equal + (file-remote-p "/[method/1.2.3.4]" 'user) "default-user")) + (should (string-equal + (file-remote-p "/[method/1.2.3.4]" 'host) "1.2.3.4")) + (should (string-equal + (file-remote-p "/[method/1.2.3.4]" 'localname) "")) + (should (string-equal (file-remote-p "/[method/1.2.3.4]" 'hop) nil)) + + ;; No expansion. + (should (string-equal + (file-remote-p "/[method/user@1.2.3.4]") + (format "/[%s/%s@%s]" "method" "user" "1.2.3.4"))) + (should (string-equal + (file-remote-p "/[method/user@1.2.3.4]" 'method) "method")) + (should (string-equal + (file-remote-p "/[method/user@1.2.3.4]" 'user) "user")) + (should (string-equal + (file-remote-p "/[method/user@1.2.3.4]" 'host) "1.2.3.4")) + (should (string-equal + (file-remote-p "/[method/user@1.2.3.4]" 'localname) "")) + (should (string-equal + (file-remote-p "/[method/user@1.2.3.4]" 'hop) nil)) + + ;; Expand `tramp-default-method', `tramp-default-user' and + ;; `tramp-default-host'. + (should (string-equal + (file-remote-p "/[-/]") + (format + "/[%s/%s@%s]" + "default-method" "default-user" "default-host"))) + (should (string-equal + (file-remote-p "/[-/]" 'method) "default-method")) + (should (string-equal (file-remote-p "/[-/]" 'user) "default-user")) + (should (string-equal (file-remote-p "/[-/]" 'host) "default-host")) + (should (string-equal (file-remote-p "/[-/]" 'localname) "")) + (should (string-equal (file-remote-p "/[-/]" 'hop) nil)) + + ;; Expand `tramp-default-method' and `tramp-default-user'. + (let ((tramp-default-host "::1")) + (should (string-equal + (file-remote-p "/[-/]") + (format + "/[%s/%s@%s]" + "default-method" "default-user" "::1"))) + (should (string-equal + (file-remote-p "/[-/]" 'method) "default-method")) + (should (string-equal (file-remote-p "/[-/]" 'user) "default-user")) + (should (string-equal (file-remote-p "/[-/]" 'host) "::1")) + (should (string-equal (file-remote-p "/[-/]" 'localname) "")) + (should (string-equal (file-remote-p "/[-/]" 'hop) nil))) + + ;; Expand `tramp-default-method' and `tramp-default-user'. + (should (string-equal + (file-remote-p "/[-/::1]") + (format + "/[%s/%s@%s]" "default-method" "default-user" "::1"))) + (should (string-equal + (file-remote-p "/[-/::1]" 'method) "default-method")) + (should (string-equal + (file-remote-p "/[-/::1]" 'user) "default-user")) + (should (string-equal (file-remote-p "/[-/::1]" 'host) "::1")) + (should (string-equal (file-remote-p "/[-/::1]" 'localname) "")) + (should (string-equal (file-remote-p "/[-/::1]" 'hop) nil)) + + ;; Expand `tramp-default-method'. + (should (string-equal + (file-remote-p "/[-/user@::1]") + (format "/[%s/%s@%s]" "default-method" "user" "::1"))) + (should (string-equal + (file-remote-p "/[-/user@::1]" 'method) "default-method")) + (should (string-equal (file-remote-p "/[-/user@::1]" 'user) "user")) + (should (string-equal (file-remote-p "/[-/user@::1]" 'host) "::1")) + (should (string-equal (file-remote-p "/[-/user@::1]" 'localname) "")) + (should (string-equal (file-remote-p "/[-/user@::1]" 'hop) nil)) + + ;; Expand `tramp-default-user'. + (should (string-equal + (file-remote-p "/[method/::1]") + (format "/[%s/%s@%s]" "method" "default-user" "::1"))) + (should (string-equal + (file-remote-p "/[method/::1]" 'method) "method")) + (should (string-equal + (file-remote-p "/[method/::1]" 'user) "default-user")) + (should (string-equal (file-remote-p "/[method/::1]" 'host) "::1")) + (should (string-equal (file-remote-p "/[method/::1]" 'localname) "")) + (should (string-equal (file-remote-p "/[method/::1]" 'hop) nil)) + + ;; No expansion. + (should (string-equal + (file-remote-p "/[method/user@::1]") + (format "/[%s/%s@%s]" "method" "user" "::1"))) + (should (string-equal + (file-remote-p "/[method/user@::1]" 'method) "method")) + (should (string-equal + (file-remote-p "/[method/user@::1]" 'user) "user")) + (should (string-equal + (file-remote-p "/[method/user@::1]" 'host) "::1")) + (should (string-equal + (file-remote-p "/[method/user@::1]" 'localname) "")) + (should (string-equal (file-remote-p "/[method/user@::1]" 'hop) nil)) + + ;; Local file name part. + (should (string-equal (file-remote-p "/[-/host]/:" 'localname) "/:")) + (should (string-equal (file-remote-p "/[method/]:" 'localname) ":")) + (should (string-equal (file-remote-p "/[method/] " 'localname) " ")) + (should (string-equal + (file-remote-p "/[method/]file" 'localname) "file")) + (should (string-equal + (file-remote-p "/[method/]/path/to/file" 'localname) + "/path/to/file")) + + ;; Multihop. + (should + (string-equal + (file-remote-p + "/[method1/user1@host1|method2/user2@host2]/path/to/file") + (format "/[%s/%s@%s|%s/%s@%s]" + "method1" "user1" "host1" "method2" "user2" "host2"))) + (should + (string-equal + (file-remote-p + "/[method1/user1@host1|method2/user2@host2]/path/to/file" 'method) + "method2")) + (should + (string-equal + (file-remote-p + "/[method1/user1@host1|method2/user2@host2]/path/to/file" 'user) + "user2")) + (should + (string-equal + (file-remote-p + "/[method1/user1@host1|method2/user2@host2]/path/to/file" 'host) + "host2")) + (should + (string-equal + (file-remote-p + "/[method1/user1@host1|method2/user2@host2]/path/to/file" + 'localname) + "/path/to/file")) + (should + (string-equal + (file-remote-p + "/[method1/user1@host1|method2/user2@host2]/path/to/file" 'hop) + (format "%s/%s@%s|" + "method1" "user1" "host1"))) + + (should + (string-equal + (file-remote-p + (concat + "/[method1/user1@host1" + "|method2/user2@host2" + "|method3/user3@host3]/path/to/file")) + (format "/[%s/%s@%s|%s/%s@%s|%s/%s@%s]" + "method1" "user1" "host1" + "method2" "user2" "host2" + "method3" "user3" "host3"))) + (should + (string-equal + (file-remote-p + (concat + "/[method1/user1@host1" + "|method2/user2@host2" + "|method3/user3@host3]/path/to/file") + 'method) + "method3")) + (should + (string-equal + (file-remote-p + (concat + "/[method1/user1@host1" + "|method2/user2@host2" + "|method3/user3@host3]/path/to/file") + 'user) + "user3")) + (should + (string-equal + (file-remote-p + (concat + "/[method1/user1@host1" + "|method2/user2@host2" + "|method3/user3@host3]/path/to/file") + 'host) + "host3")) + (should + (string-equal + (file-remote-p + (concat + "/[method1/user1@host1" + "|method2/user2@host2" + "|method3/user3@host3]/path/to/file") + 'localname) + "/path/to/file")) + (should + (string-equal + (file-remote-p + (concat + "/[method1/user1@host1" + "|method2/user2@host2" + "|method3/user3@host3]/path/to/file") + 'hop) + (format "%s/%s@%s|%s/%s@%s|" + "method1" "user1" "host1" "method2" "user2" "host2")))) + + ;; Exit. + (tramp-change-syntax syntax)))) + (ert-deftest tramp-test03-file-name-defaults () "Check default values for some methods." ;; Default values in tramp-adb.el.