emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/compat fe20be9ef2 2/7: Add file-name-quoted-p


From: ELPA Syncer
Subject: [elpa] externals/compat fe20be9ef2 2/7: Add file-name-quoted-p
Date: Mon, 11 Apr 2022 18:57:23 -0400 (EDT)

branch: externals/compat
commit fe20be9ef269e81866c4e40a7d61cffe18080904
Author: Philip Kaludercic <philipk@posteo.net>
Commit: Philip Kaludercic <philipk@posteo.net>

    Add file-name-quoted-p
---
 MANUAL          |  1 +
 compat-26.el    |  8 ++++++++
 compat-tests.el | 10 ++++++++++
 3 files changed, 19 insertions(+)

diff --git a/MANUAL b/MANUAL
index 471e882181..307311ecd1 100644
--- a/MANUAL
+++ b/MANUAL
@@ -230,6 +230,7 @@ provided by Compat by default:
 - Function: temporary-file-directory :: See [[info:elisp#Unique File 
Names][(elisp) Unique File Names]].
 - Macro: and-let* :: Defined in ~subr-x.el~.
 - Function: file-local-name :: See [[info:elisp#Magic File Names][(elisp) 
Magic File Names]].
+- Function: file-name-quoted-p :: See [[info:elisp#File Name 
Expansion][(elisp) File Name Expansion]].
 
 These functions are prefixed with ~compat~ prefix, and are only loaded
 when ~compat-26~ is required:
diff --git a/compat-26.el b/compat-26.el
index bf8e1ceef6..e8c8ca8d7c 100644
--- a/compat-26.el
+++ b/compat-26.el
@@ -352,8 +352,16 @@ and the method of accessing the host, leaving only the 
part that
 identifies FILE locally on the remote system.
 The returned file name can be used directly as argument of
 `process-file', `start-file-process', or `shell-command'."
+  :realname compat--file-local-name
   (or (file-remote-p file 'localname) file))
 
+(compat-defun 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."
+  :realname compat--file-name-quoted-p
+  (let ((file-name-handler-alist (unless top file-name-handler-alist)))
+    (string-prefix-p "/:" (compat--file-local-name name))))
+
 ;;* UNTESTED
 (compat-defun temporary-file-directory ()
   "The directory for writing temporary files.
diff --git a/compat-tests.el b/compat-tests.el
index 5e0ece15bc..1ae907a644 100644
--- a/compat-tests.el
+++ b/compat-tests.el
@@ -1578,5 +1578,15 @@ being compared against."
   (ought ":foo" "/ssh:::foo")
   (ought ":/bar/foo" "/ssh:::/bar/foo"))
 
+(compat-deftest file-name-quoted-p
+  (ought nil "")
+  (ought t "/:")
+  (ought nil "//:")
+  (ought t "/::")
+  (ought nil "/ssh::")
+  (ought nil "/ssh::a")
+  (ought t "/ssh::/:a")
+  (ought nil "/ssh:/:a"))
+
 (provide 'compat-tests)
 ;;; compat-tests.el ends here



reply via email to

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