emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master cd3a7f3: Fix tramp-compat-file-name-quoted-p


From: Michael Albinus
Subject: [Emacs-diffs] master cd3a7f3: Fix tramp-compat-file-name-quoted-p
Date: Thu, 2 May 2019 03:51:53 -0400 (EDT)

branch: master
commit cd3a7f35de8b0f39524912529d6fceda26571276
Author: Michael Albinus <address@hidden>
Commit: Michael Albinus <address@hidden>

    Fix tramp-compat-file-name-quoted-p
    
    * lisp/net/tramp-compat.el (tramp-compat-file-local-name)
    (tramp-compat-file-name-quoted-p): Declare them.
    (top): Do not use `eval-and-compile'.
    (tramp-compat-file-name-quoted-p): Check also func-arity of
    `file-name-quoted-p'.
---
 lisp/net/tramp-compat.el | 69 ++++++++++++++++++++++++++----------------------
 1 file changed, 37 insertions(+), 32 deletions(-)

diff --git a/lisp/net/tramp-compat.el b/lisp/net/tramp-compat.el
index ae743b2..a05c841 100644
--- a/lisp/net/tramp-compat.el
+++ b/lisp/net/tramp-compat.el
@@ -45,6 +45,9 @@
 (require 'timer)
 (require 'ucs-normalize)
 
+(declare-function tramp-compat-file-local-name 'tramp-compat)
+(declare-function tramp-compat-file-name-quoted-p 'tramp-compat)
+
 ;; For not existing functions, obsolete functions, or functions with a
 ;; changed argument list, there are compiler warnings.  We want to
 ;; avoid them in cases we know what we do.
@@ -187,43 +190,45 @@ This is a string of ten letters or dashes as in ls -l."
 
 ;; `file-local-name', `file-name-quoted-p', `file-name-quote' and
 ;; `file-name-unquote' are introduced in Emacs 26.
-(eval-and-compile
-  (if (fboundp 'file-local-name)
-      (defalias 'tramp-compat-file-local-name #'file-local-name)
-    (defsubst tramp-compat-file-local-name (name)
-      "Return the local name component of NAME.
+(if (fboundp 'file-local-name)
+    (defalias 'tramp-compat-file-local-name #'file-local-name)
+  (defsubst tramp-compat-file-local-name (name)
+    "Return the local name component of NAME.
 It returns a file name which can be used directly as argument of
 `process-file', `start-file-process', or `shell-command'."
-      (or (file-remote-p name 'localname) name)))
-
-  (if (fboundp 'file-name-quoted-p)
-      (defalias 'tramp-compat-file-name-quoted-p #'file-name-quoted-p)
-    (defsubst tramp-compat-file-name-quoted-p (name &optional top)
-      "Whether NAME is quoted with prefix \"/:\".
+    (or (file-remote-p name 'localname) name)))
+
+;; `file-name-quoted-p' got a second argument in Emacs 27.1.
+(if (and
+     (fboundp 'file-name-quoted-p)
+     (equal (tramp-compat-funcall 'func-arity #'file-name-quoted-p) '(1 . 2)))
+    (defalias 'tramp-compat-file-name-quoted-p #'file-name-quoted-p)
+  (defsubst tramp-compat-file-name-quoted-p (name &optional top)
+    "Whether NAME is quoted with prefix \"/:\".
 If NAME is a remote file name and TOP is nil, check the local part of NAME."
-      (let ((file-name-handler-alist (unless top file-name-handler-alist)))
-       (string-prefix-p "/:" (tramp-compat-file-local-name name)))))
+    (let ((file-name-handler-alist (unless top file-name-handler-alist)))
+      (string-prefix-p "/:" (tramp-compat-file-local-name name)))))
 
-  (if (fboundp 'file-name-quote)
-      (defalias 'tramp-compat-file-name-quote #'file-name-quote)
-    (defsubst tramp-compat-file-name-quote (name)
-      "Add the quotation prefix \"/:\" to file NAME.
+(if (fboundp 'file-name-quote)
+    (defalias 'tramp-compat-file-name-quote #'file-name-quote)
+  (defsubst tramp-compat-file-name-quote (name)
+    "Add the quotation prefix \"/:\" to file NAME.
 If NAME is a remote file name, the local part of NAME is quoted."
-      (if (tramp-compat-file-name-quoted-p name)
-         name
-       (concat
-        (file-remote-p name) "/:" (tramp-compat-file-local-name name)))))
-
-  (if (fboundp 'file-name-unquote)
-      (defalias 'tramp-compat-file-name-unquote #'file-name-unquote)
-    (defsubst tramp-compat-file-name-unquote (name)
-      "Remove quotation prefix \"/:\" from file NAME.
+    (if (tramp-compat-file-name-quoted-p name)
+       name
+      (concat
+       (file-remote-p name) "/:" (tramp-compat-file-local-name name)))))
+
+(if (fboundp 'file-name-unquote)
+    (defalias 'tramp-compat-file-name-unquote #'file-name-unquote)
+  (defsubst tramp-compat-file-name-unquote (name)
+    "Remove quotation prefix \"/:\" from file NAME.
 If NAME is a remote file name, the local part of NAME is unquoted."
-      (let ((localname (tramp-compat-file-local-name name)))
-       (when (tramp-compat-file-name-quoted-p localname)
-         (setq
-          localname (if (= (length localname) 2) "/" (substring localname 2))))
-       (concat (file-remote-p name) localname)))))
+    (let ((localname (tramp-compat-file-local-name name)))
+      (when (tramp-compat-file-name-quoted-p localname)
+       (setq
+        localname (if (= (length localname) 2) "/" (substring localname 2))))
+      (concat (file-remote-p name) localname))))
 
 ;; `tramp-syntax' has changed its meaning in Emacs 26.  We still
 ;; support old settings.
@@ -241,7 +246,7 @@ If NAME is a remote file name, the local part of NAME is 
unquoted."
     '(cdr (mapcar #'car (get 'tramp-file-name 'cl-struct-slots)))))
 
 ;; The signature of `tramp-make-tramp-file-name' has been changed.
-;; Therefore, we cannot us `url-tramp-convert-url-to-tramp' prior
+;; Therefore, we cannot use `url-tramp-convert-url-to-tramp' prior
 ;; Emacs 26.1.  We use `temporary-file-directory' as indicator.
 (defconst tramp-compat-use-url-tramp-p (fboundp 'temporary-file-directory)
   "Whether to use url-tramp.el.")



reply via email to

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