[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/compat 933cf6b365 3/7: Add file-name-quote
From: |
ELPA Syncer |
Subject: |
[elpa] externals/compat 933cf6b365 3/7: Add file-name-quote |
Date: |
Mon, 11 Apr 2022 18:57:23 -0400 (EDT) |
branch: externals/compat
commit 933cf6b365161744e1f791cb852274cd38e62b85
Author: Philip Kaludercic <philipk@posteo.net>
Commit: Philip Kaludercic <philipk@posteo.net>
Add file-name-quote
---
MANUAL | 1 +
compat-26.el | 10 ++++++++++
compat-tests.el | 11 +++++++++++
3 files changed, 22 insertions(+)
diff --git a/MANUAL b/MANUAL
index 307311ecd1..373e220bd9 100644
--- a/MANUAL
+++ b/MANUAL
@@ -231,6 +231,7 @@ provided by Compat by default:
- 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]].
+- Function: file-name-quote :: 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 e8c8ca8d7c..d3c8b5c6c4 100644
--- a/compat-26.el
+++ b/compat-26.el
@@ -362,6 +362,16 @@ 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 "/:" (compat--file-local-name name))))
+(compat-defun file-name-quote (name &optional top)
+ "Add the quotation prefix \"/:\" to file NAME.
+If NAME is a remote file name and TOP is nil, the local part of
+NAME is quoted. If NAME is already a quoted file name, NAME is
+returned unchanged."
+ (let ((file-name-handler-alist (unless top file-name-handler-alist)))
+ (if (compat--file-name-quoted-p name top)
+ name
+ (concat (file-remote-p name) "/:" (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 1ae907a644..c4089831bd 100644
--- a/compat-tests.el
+++ b/compat-tests.el
@@ -1588,5 +1588,16 @@ being compared against."
(ought t "/ssh::/:a")
(ought nil "/ssh:/:a"))
+(compat-deftest file-name-quote
+ (ought "/:" "")
+ (ought "/::" ":")
+ (ought "/:/" "/")
+ (ought "/:" "/:")
+ (ought "/:a" "a")
+ (ought "/::a" ":a")
+ (ought "/:/a" "/a")
+ (ought "/:a" "/:a")
+ (ought (concat "/ssh:" (system-name) ":/:a") "/ssh::a"))
+
(provide 'compat-tests)
;;; compat-tests.el ends here
- [elpa] externals/compat updated (a09c6c260c -> 91f25b356e), ELPA Syncer, 2022/04/11
- [elpa] externals/compat c4bde3f108 4/7: Add generalised variable handling for compat-alist-get, ELPA Syncer, 2022/04/11
- [elpa] externals/compat e83e9a67fe 5/7: Add compat-executable-find, ELPA Syncer, 2022/04/11
- [elpa] externals/compat ced0446916 1/7: Add missing function file-local-name, ELPA Syncer, 2022/04/11
- [elpa] externals/compat 933cf6b365 3/7: Add file-name-quote,
ELPA Syncer <=
- [elpa] externals/compat ed62b776b8 6/7: Add image-property, ELPA Syncer, 2022/04/11
- [elpa] externals/compat fe20be9ef2 2/7: Add file-name-quoted-p, ELPA Syncer, 2022/04/11
- [elpa] externals/compat 91f25b356e 7/7: Add compat-dired-get-marked-files, ELPA Syncer, 2022/04/11