[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/compat e4e564bdf1: compat-27: Add file-name-unquote
From: |
ELPA Syncer |
Subject: |
[elpa] externals/compat e4e564bdf1: compat-27: Add file-name-unquote |
Date: |
Mon, 23 Jan 2023 09:57:26 -0500 (EST) |
branch: externals/compat
commit e4e564bdf1e8664665e626e4c65146f7207c5a56
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
compat-27: Add file-name-unquote
---
NEWS.org | 1 +
compat-27.el | 16 +++++++++++++---
compat-tests.el | 7 +++++++
compat.texi | 9 +++++++--
4 files changed, 28 insertions(+), 5 deletions(-)
diff --git a/NEWS.org b/NEWS.org
index b4a66b301c..84a9331abc 100644
--- a/NEWS.org
+++ b/NEWS.org
@@ -2,6 +2,7 @@
* Development
+- compat-27: Add ~file-name-unquote~.
- compat-29: Replace ~string-lines~ with version from Emacs 29, support
optional
KEEP-NEWLINES argument.
diff --git a/compat-27.el b/compat-27.el
index 102abf1f1c..793c98e095 100644
--- a/compat-27.el
+++ b/compat-27.el
@@ -427,10 +427,20 @@ the minibuffer was activated, and execute the forms."
(compat-defun file-name-quote (name &optional top) ;;
<compat-tests:file-name-quote>
"Handle optional argument TOP."
:extended "26.1"
- (let ((file-name-handler-alist (unless top file-name-handler-alist)))
- (if (string-prefix-p "/:" (file-local-name name))
+ (let* ((file-name-handler-alist (unless top file-name-handler-alist))
+ (localname (file-local-name name)))
+ (if (string-prefix-p "/:" localname)
name
- (concat (file-remote-p name) "/:" (file-local-name name)))))
+ (concat (file-remote-p name) "/:" localname))))
+
+(compat-defun file-name-unquote (name &optional top) ;;
<compat-tests:file-name-unquote>
+ "Handle optional argument TOP."
+ :extended "26.1"
+ (let* ((file-name-handler-alist (unless top file-name-handler-alist))
+ (localname (file-local-name name)))
+ (when (string-prefix-p "/:" localname)
+ (setq localname (if (= (length localname) 2) "/" (substring localname
2))))
+ (concat (file-remote-p name) localname)))
(compat-defun file-size-human-readable (file-size &optional flavor space unit)
;; <compat-tests:file-size-human-readable>
"Handle the optional arguments SPACE and UNIT."
diff --git a/compat-tests.el b/compat-tests.el
index c26c29496f..9724314f5f 100644
--- a/compat-tests.el
+++ b/compat-tests.el
@@ -1592,6 +1592,13 @@
(when (>= emacs-major-version 26)
(should-not (file-name-quoted-p "/ssh:/:a"))))
+(ert-deftest file-name-unquote ()
+ (should-equal "/" (compat-call file-name-unquote "/:" t)) ;; top argument
+ (should-equal ":"(compat-call file-name-unquote "/::" t)) ;; top argument
+ (should-equal "/" (file-name-unquote "/:/"))
+ (should-equal "/" (file-name-unquote "/:"))
+ (should-equal ":" (file-name-unquote "/::")))
+
(ert-deftest file-name-quote ()
(should-equal "/:" (compat-call file-name-quote "" t)) ;; top argument
(should-equal "/::"(compat-call file-name-quote ":" t)) ;; top argument
diff --git a/compat.texi b/compat.texi
index b4880ae6ef..d4535bc126 100644
--- a/compat.texi
+++ b/compat.texi
@@ -657,6 +657,13 @@ It should be somewhat more efficient on larger buffers than
@c according to what we find useful.
@end defun
+@c copied from lispref/files.texi
+@defmac file-name-unquote name
+This macro removes the quotation prefix @samp{/:} from the file
+@var{name}, if any. If @var{name} is a remote file name, the local
+part of @var{name} is unquoted.
+@end defmac
+
@c copied from lispref/files.texi
@defun file-name-quoted-p name
This macro returns non-@code{nil}, when @var{name} is quoted with the
@@ -968,8 +975,6 @@ implemented in 26.1:
@itemize
@item
-The function @code{file-name-unquote}.
-@item
The function @code{func-arity}.
@item
The function @code{secure-hash-algorithms}.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/compat e4e564bdf1: compat-27: Add file-name-unquote,
ELPA Syncer <=