branch: externals/compat commit 74250577e643779a3afc2fe7be2465833c7fa134 Author: Daniel Mendler <m...@daniel-mendler.de> Commit: Daniel Mendler <m...@daniel-mendler.de>
Fix file-name-quoted-p and file-name-quote --- compat-tests.el | 36 +++++++++++++++-------------- compat.texi | 72 +++++++++++++++++++++++++++++---------------------------- 2 files changed, 56 insertions(+), 52 deletions(-) diff --git a/compat-tests.el b/compat-tests.el index 4e8a0d6f5b..17b59f8a30 100644 --- a/compat-tests.el +++ b/compat-tests.el @@ -1564,28 +1564,30 @@ (should-equal ":/bar/foo" (file-local-name "/ssh:::/bar/foo"))) (ert-deftest file-name-quoted-p () - (should-not (compat-call file-name-quoted-p "")) - (should (compat-call file-name-quoted-p "/:")) - (should-not (compat-call file-name-quoted-p "//:")) - (should (compat-call file-name-quoted-p "/::")) - (should-not (compat-call file-name-quoted-p "/ssh::")) - (should-not (compat-call file-name-quoted-p "/ssh::a")) - (should (compat-call file-name-quoted-p "/ssh::/:a")) + ;; TODO test TOP argument + (should-not (file-name-quoted-p "")) + (should (file-name-quoted-p "/:")) + (should-not (file-name-quoted-p "//:")) + (should (file-name-quoted-p "/::")) + (should-not (file-name-quoted-p "/ssh::")) + (should-not (file-name-quoted-p "/ssh::a")) + (should (file-name-quoted-p "/ssh::/:a")) ;; NOTE: These tests fails prior to Emacs 26, because /ssh:foo was a valid ;; TRAMP path back then. (when (>= emacs-major-version 26) - (should-not (compat-call file-name-quoted-p "/ssh:/:a")))) + (should-not (file-name-quoted-p "/ssh:/:a")))) (ert-deftest file-name-quote () - (should-equal "/:" (compat-call file-name-quote "")) - (should-equal "/::"(compat-call file-name-quote ":")) - (should-equal "/:/" (compat-call file-name-quote "/")) - (should-equal "/:" (compat-call file-name-quote "/:")) - (should-equal "/:a" (compat-call file-name-quote "a")) - (should-equal "/::a" (compat-call file-name-quote ":a")) - (should-equal "/:/a" (compat-call file-name-quote "/a")) - (should-equal "/:a" (compat-call file-name-quote "/:a")) - (should-equal (concat "/ssh:" (system-name) ":/:a") (compat-call file-name-quote "/ssh::a"))) + ;; TODO test TOP argument + (should-equal "/:" (file-name-quote "")) + (should-equal "/::"(file-name-quote ":")) + (should-equal "/:/" (file-name-quote "/")) + (should-equal "/:" (file-name-quote "/:")) + (should-equal "/:a" (file-name-quote "a")) + (should-equal "/::a" (file-name-quote ":a")) + (should-equal "/:/a" (file-name-quote "/a")) + (should-equal "/:a" (file-name-quote "/:a")) + (should-equal (concat "/ssh:" (system-name) ":/:a") (file-name-quote "/ssh::a"))) (ert-deftest file-name-concat () (should-equal (file-name-concat "foo" "bar") "foo/bar") diff --git a/compat.texi b/compat.texi index 1d5a4ffc7f..37e9d5202c 100644 --- a/compat.texi +++ b/compat.texi @@ -652,6 +652,41 @@ 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 +@defun file-name-quoted-p name +This macro returns non-@code{nil}, when @var{name} is quoted with the +prefix @samp{/:}. If @var{name} is a remote file name, the local part +of @var{name} is checked. + +@xref{File Name Expansion,,,elisp}. +@end defun + +@c copied from lispref/files.texi +@defun file-name-quote name +This macro adds the quotation prefix @samp{/:} to the file @var{name}. +For a local file @var{name}, it prefixes @var{name} with @samp{/:}. If +@var{name} is a remote file name, the local part of @var{name} +(@pxref{Magic File Names,,,elisp}) is quoted. If @var{name} is already +a quoted file name, @var{name} is returned unchanged. + +@example +@group +(substitute-in-file-name (compat-call file-name-quote "bar/~/foo")) @result{} + "/:bar/~/foo" +@end group + +@group +(substitute-in-file-name (compat-call file-name-quote "/ssh:host:bar/~/foo")) + @result{} "/ssh:host:/:bar/~/foo" +@end group +@end example + +The macro cannot be used to suppress file name handlers from magic file +names (@pxref{Magic File Names,,,elisp}). + +@xref{File Name Expansion,,,elisp}. +@end defun + @c copied from lispref/files.texi @defun make-nearby-temp-file prefix &optional dir-flag suffix This function is similar to @code{make-temp-file}, but it creates a @@ -922,47 +957,14 @@ The compatibility version handles the optional arguments @var{trim-left} and @var{trim-right}. @end defun -@c copied from lispref/files.texi -@defun compat-call@ file-name-quoted-p name -This macro returns non-@code{nil}, when @var{name} is quoted with the -prefix @samp{/:}. If @var{name} is a remote file name, the local part -of @var{name} is checked. - -@xref{File Name Expansion,,,elisp}. -@end defun - -@c copied from lispref/files.texi -@defun compat-call@ file-name-quote name -This macro adds the quotation prefix @samp{/:} to the file @var{name}. -For a local file @var{name}, it prefixes @var{name} with @samp{/:}. If -@var{name} is a remote file name, the local part of @var{name} -(@pxref{Magic File Names,,,elisp}) is quoted. If @var{name} is already -a quoted file name, @var{name} is returned unchanged. - -@example -@group -(substitute-in-file-name (compat-call file-name-quote "bar/~/foo")) @result{} - "/:bar/~/foo" -@end group - -@group -(substitute-in-file-name (compat-call file-name-quote "/ssh:host:bar/~/foo")) - @result{} "/ssh:host:/:bar/~/foo" -@end group -@end example - -The macro cannot be used to suppress file name handlers from magic file -names (@pxref{Magic File Names,,,elisp}). - -@xref{File Name Expansion,,,elisp}. -@end defun - @subsection Missing Definitions Compat does not provide support for the following Lisp features 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}.