emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 814fd3057f 1/2: ; Minor Tramp cleanups


From: Michael Albinus
Subject: master 814fd3057f 1/2: ; Minor Tramp cleanups
Date: Tue, 20 Sep 2022 12:36:37 -0400 (EDT)

branch: master
commit 814fd3057fb8f3122db86f30fde014f5e19502f5
Author: Michael Albinus <michael.albinus@gmx.de>
Commit: Michael Albinus <michael.albinus@gmx.de>

    ; Minor Tramp cleanups
    
    * lisp/net/tramp.el (tramp-build-remote-file-name-spec-regexp):
    Handle the `simplified' syntax better.
    (tramp-handle-file-name-case-insensitive-p): Do not unquote candidate.
---
 lisp/net/tramp.el | 44 +++++++++++++++++++++++++++++---------------
 1 file changed, 29 insertions(+), 15 deletions(-)

diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index f18e4c41c3..55c7cd5f37 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -1087,18 +1087,34 @@ Derived from `tramp-postfix-host-format'.")
 (defun tramp-build-remote-file-name-spec-regexp ()
   "Construct a regexp matching a Tramp file name for a Tramp syntax.
 It is expected, that `tramp-syntax' has the proper value."
-  (tramp-compat-rx
-   ;; Method.
-   (group (regexp tramp-method-regexp)) (regexp tramp-postfix-method-regexp)
-   ;; Optional user.  This includes domain.
-   (? (group (regexp tramp-user-regexp)) (regexp tramp-postfix-user-regexp))
-   ;; Optional host.
-   (? (group (| (regexp tramp-host-regexp)
-                (: (regexp tramp-prefix-ipv6-regexp)
-                  (? (regexp tramp-ipv6-regexp))
-                  (regexp tramp-postfix-ipv6-regexp)))
-   ;; Optional port.
-   (? (regexp tramp-prefix-port-regexp) (regexp tramp-port-regexp))))))
+  ;; Starting with Emacs 27, we can use `rx-let'.
+  (let* ((user-regexp
+         (tramp-compat-rx
+          (group-n 6 (regexp tramp-user-regexp))
+          (regexp tramp-postfix-user-regexp)))
+        (host-regexp
+         (tramp-compat-rx
+          (group-n 7 (| (regexp tramp-host-regexp)
+                        (: (regexp tramp-prefix-ipv6-regexp)
+                           (? (regexp tramp-ipv6-regexp))
+                           (regexp tramp-postfix-ipv6-regexp)))
+                   ;; Optional port.
+                   (? (regexp tramp-prefix-port-regexp)
+                      (regexp tramp-port-regexp)))))
+        (user-host-regexp
+         (if (eq tramp-syntax 'simplified)
+             ;; There must be either user or host.
+             (tramp-compat-rx
+              (| (: (regexp user-regexp) (? (regexp host-regexp)))
+                 (: (? (regexp user-regexp)) (regexp host-regexp))))
+           (tramp-compat-rx
+            (? (regexp user-regexp)) (? (regexp host-regexp))))))
+    (tramp-compat-rx
+     ;; Method.
+     (group-n 5 (regexp tramp-method-regexp))
+     (regexp tramp-postfix-method-regexp)
+     ;; User and host.
+     (regexp user-host-regexp))))
 
 (defvar tramp-remote-file-name-spec-regexp
   nil ; Initialized when defining `tramp-syntax'!
@@ -3904,9 +3920,7 @@ Let-bind it when necessary.")
              (with-tramp-progress-reporter v 5 "Checking case-insensitive"
                ;; The idea is to compare a file with lower case
                ;; letters with the same file with upper case letters.
-               (let ((candidate
-                      (tramp-compat-file-name-unquote
-                       (directory-file-name filename)))
+               (let ((candidate (directory-file-name filename))
                      case-fold-search
                      tmpfile)
                  ;; Check, whether we find an existing file with



reply via email to

[Prev in Thread] Current Thread [Next in Thread]