[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/path-iterator 0e59874 07/10: In uniquify-files, factor
From: |
Stefan Monnier |
Subject: |
[elpa] externals/path-iterator 0e59874 07/10: In uniquify-files, factor out file-complete.el |
Date: |
Tue, 1 Dec 2020 16:43:57 -0500 (EST) |
branch: externals/path-iterator
commit 0e5987466d322fe01f934d80f097b16624e2b9aa
Author: Stephen Leake <stephen_leake@stephe-leake.org>
Commit: Stephen Leake <stephen_leake@stephe-leake.org>
In uniquify-files, factor out file-complete.el
* packages/path-iterator/path-iterator-resources/alice-1/bar-file1.text:
New file.
* packages/path-iterator/path-iterator-test.el: Add trailing "/" where
needed; anything that is known to be a directory ends in "/".
* packages/uniquify-files/file-complete-root-relative-test.el:
(test-fc-root-rel-test-completion-1): Update to use
completion-current-style.
* packages/uniquify-files/file-complete.el: New file, factored out from
uniquify-file.el, file-complete-root-relative.el.
* packages/path-iterator/path-iterator.el: Add trailing "/" where needed;
anything that is known to be a directory ends in "/".
(path-iter--to-truename): Handle users passing a single string.
* packages/uniquify-files/file-complete-root-relative.el: Use
file-complete functions. Use completion-current-style.
(fc-root-rel-completion-table-iter): Call file-complete-completion-table.
(fc-root-rel--pcm-regex-list): Rename from fc-root-rel--pcm-pattern-list.
(fc-root-rel-completion-table-list): Implement test-completion. Use
test-completion, try-completion.
* packages/uniquify-files/uniquify-files-test.el (uft-iter): Add Alice,
Bob directories.
(test-uniq-file-completion-table): Delete; tested in
file-complete-test.el.
(test-uniq-file-all-completions-noface-1): Add a test.
(test-uniq-file-try-completion-1): Update tests.
* packages/uniquify-files/uniquify-files.el: Use file-complete.
(uniq-file--pcm-pat): New, factored out of uniq-file--pcm-merged-pat.
(uniq-file--pcm-pattern): Delete; use file-complete-pcm-regex.
(uniq-file-completion-table): Use file-complete-completion-table.
---
path-iterator-resources/alice-1/bar-file1.text | 1 +
path-iterator-test.el | 83 +++++++++++++-------------
path-iterator.el | 14 +++--
3 files changed, 52 insertions(+), 46 deletions(-)
diff --git a/path-iterator-resources/alice-1/bar-file1.text
b/path-iterator-resources/alice-1/bar-file1.text
new file mode 100644
index 0000000..fa6dc6c
--- /dev/null
+++ b/path-iterator-resources/alice-1/bar-file1.text
@@ -0,0 +1 @@
+Alice/alice-1/bar-file1.text
diff --git a/path-iterator-test.el b/path-iterator-test.el
index 4986842..cf50461 100644
--- a/path-iterator-test.el
+++ b/path-iterator-test.el
@@ -23,7 +23,7 @@
(defconst path-iter-root-dir
(concat
(file-name-directory (or load-file-name (buffer-file-name)))
- "path-iterator-resources"))
+ "path-iterator-resources/"))
(defmacro path-iter-deftest (name-suffix path-non-recursive path-recursive
expected-dirs &optional ignore-function)
"Define an ert test for path-iterator.
@@ -60,49 +60,49 @@ iterator built from PATH-NON-RECURSIVE, PATH-RECURSIVE,
IGNORE-FUNCTION."
(list path-iter-root-dir)
(list
path-iter-root-dir
- (concat path-iter-root-dir "/alice-1")
- (concat path-iter-root-dir "/bob-1")
- (concat path-iter-root-dir "/bob-1/bob-2")
- (concat path-iter-root-dir "/bob-1/bob-3")
+ (concat path-iter-root-dir "alice-1/")
+ (concat path-iter-root-dir "bob-1/")
+ (concat path-iter-root-dir "bob-1/bob-2/")
+ (concat path-iter-root-dir "bob-1/bob-3/")
))
(path-iter-deftest non-recursive
(list
- (concat path-iter-root-dir "/alice-1")
- (concat path-iter-root-dir "/bob-1/bob-2")
- (concat path-iter-root-dir "/bob-1/bob-3")
- (concat path-iter-root-dir "/bob-1/bob-4") ;; does not exist
+ (concat path-iter-root-dir "alice-1/")
+ (concat path-iter-root-dir "bob-1/bob-2/")
+ (concat path-iter-root-dir "bob-1/bob-3/")
+ (concat path-iter-root-dir "bob-1/bob-4/") ;; does not exist
)
nil ;; recursive
(list
- (concat path-iter-root-dir "/alice-1")
- (concat path-iter-root-dir "/bob-1/bob-2")
- (concat path-iter-root-dir "/bob-1/bob-3")
+ (concat path-iter-root-dir "alice-1/")
+ (concat path-iter-root-dir "bob-1/bob-2/")
+ (concat path-iter-root-dir "bob-1/bob-3/")
))
(path-iter-deftest both
(list
- (concat path-iter-root-dir "/alice-1"))
+ (concat path-iter-root-dir "alice-1/"))
(list
- (concat path-iter-root-dir "/bob-1"))
+ (concat path-iter-root-dir "bob-1/"))
(list
- (concat path-iter-root-dir "/bob-1")
- (concat path-iter-root-dir "/bob-1/bob-2")
- (concat path-iter-root-dir "/bob-1/bob-3")
- (concat path-iter-root-dir "/alice-1")
+ (concat path-iter-root-dir "bob-1/")
+ (concat path-iter-root-dir "bob-1/bob-2/")
+ (concat path-iter-root-dir "bob-1/bob-3/")
+ (concat path-iter-root-dir "alice-1/")
))
(path-iter-deftest dup
(list
- (concat path-iter-root-dir "/alice-1")
- (concat path-iter-root-dir "/bob-1")) ;; non-recursive
+ (concat path-iter-root-dir "alice-1/")
+ (concat path-iter-root-dir "bob-1/")) ;; non-recursive
(list
- (concat path-iter-root-dir "/bob-1")) ;; recursive
+ (concat path-iter-root-dir "bob-1/")) ;; recursive
(list
- (concat path-iter-root-dir "/bob-1")
- (concat path-iter-root-dir "/bob-1/bob-2")
- (concat path-iter-root-dir "/bob-1/bob-3")
- (concat path-iter-root-dir "/alice-1")
+ (concat path-iter-root-dir "bob-1/")
+ (concat path-iter-root-dir "bob-1/bob-2/")
+ (concat path-iter-root-dir "bob-1/bob-3/")
+ (concat path-iter-root-dir "alice-1/")
))
(defvar path-iter-ignore-bob nil
@@ -123,9 +123,9 @@ iterator built from PATH-NON-RECURSIVE, PATH-RECURSIVE,
IGNORE-FUNCTION."
iter
(list
path-iter-root-dir
- (concat path-iter-root-dir "/alice-1")
- (concat path-iter-root-dir "/bob-1")
- (concat path-iter-root-dir "/bob-1/bob-3")
+ (concat path-iter-root-dir "alice-1/")
+ (concat path-iter-root-dir "bob-1/")
+ (concat path-iter-root-dir "bob-1/bob-3/")
))
(setq path-iter-ignore-bob "bob-3")
@@ -135,9 +135,9 @@ iterator built from PATH-NON-RECURSIVE, PATH-RECURSIVE,
IGNORE-FUNCTION."
iter
(list
path-iter-root-dir
- (concat path-iter-root-dir "/alice-1")
- (concat path-iter-root-dir "/bob-1")
- (concat path-iter-root-dir "/bob-1/bob-3")
+ (concat path-iter-root-dir "alice-1/")
+ (concat path-iter-root-dir "bob-1/")
+ (concat path-iter-root-dir "bob-1/bob-3/")
))
(path-iter-reset iter);; recomputes path
@@ -145,9 +145,9 @@ iterator built from PATH-NON-RECURSIVE, PATH-RECURSIVE,
IGNORE-FUNCTION."
iter
(list
path-iter-root-dir
- (concat path-iter-root-dir "/alice-1")
- (concat path-iter-root-dir "/bob-1")
- (concat path-iter-root-dir "/bob-1/bob-2")
+ (concat path-iter-root-dir "alice-1/")
+ (concat path-iter-root-dir "bob-1/")
+ (concat path-iter-root-dir "bob-1/bob-2/")
))
))
@@ -163,7 +163,7 @@ iterator built from PATH-NON-RECURSIVE, PATH-RECURSIVE,
IGNORE-FUNCTION."
iter
(list
path-iter-root-dir
- (concat path-iter-root-dir "/alice-1")
+ (concat path-iter-root-dir "alice-1/")
))
))
@@ -174,10 +174,10 @@ iterator built from PATH-NON-RECURSIVE, PATH-RECURSIVE,
IGNORE-FUNCTION."
(path-iter--to-truename
(list
nil
- (concat path-iter-root-dir "/alice-1")))
+ (concat path-iter-root-dir "alice-1/")))
(list
path-iter-root-dir
- (concat path-iter-root-dir "/alice-1")))
+ (concat path-iter-root-dir "alice-1/")))
)))
@@ -191,10 +191,11 @@ iterator built from PATH-NON-RECURSIVE, PATH-RECURSIVE,
IGNORE-FUNCTION."
(equal
(path-iter-all-files iter)
(list
- (concat path-iter-root-dir "/bob-1/bob-3/foo-file3.text")
- (concat path-iter-root-dir "/bob-1/bob-2/foo-file2.text")
- (concat path-iter-root-dir "/alice-1/foo-file1.text")
- (concat path-iter-root-dir "/file-0.text")
+ (concat path-iter-root-dir "bob-1/bob-3/foo-file3.text")
+ (concat path-iter-root-dir "bob-1/bob-2/foo-file2.text")
+ (concat path-iter-root-dir "alice-1/foo-file1.text")
+ (concat path-iter-root-dir "alice-1/bar-file1.text")
+ (concat path-iter-root-dir "file-0.text")
)))
))
diff --git a/path-iterator.el b/path-iterator.el
index 5598e57..c4b550a 100644
--- a/path-iterator.el
+++ b/path-iterator.el
@@ -121,6 +121,10 @@ relative to `default-directory'.
If an element of PATH is nil, `default-directory' is used."
;; The nil handling is as defined by the `load-path' doc string.
+ (unless (listp path)
+ ;; Users often specify a single root directory, and forget it's
+ ;; supposed to be a list.
+ (setq path (list path)))
(let (result)
(cl-mapc
(lambda (name)
@@ -128,7 +132,7 @@ If an element of PATH is nil, `default-directory' is used."
(expand-file-name name)
default-directory)))
(when (file-directory-p absname)
- (push (directory-file-name (file-truename absname)) result))
+ (push (file-name-as-directory (file-truename absname)) result))
))
path)
(nreverse result)))
@@ -150,9 +154,9 @@ name. Symlinks in the directory part are resolved, but the
nondirectory part is the link name if it is a symlink.
The directories returned by `path-iter-next' are absolute
-directory file truenames; they contain forward slashes, do
-not end in a slash, have casing that matches the existing
-directory file name, and resolve simlinks (see `file-truename')."
+directory file truenames; they contain forward slashes, end in a
+slash, have casing that matches the existing directory file name,
+and resolve simlinks (see `file-truename')."
(cond
((and (listp (path-iter-visited iter))
(not (null (path-iter-path-recursive iter))))
@@ -178,7 +182,7 @@ directory file name, and resolve simlinks (see
`file-truename')."
;; `ignore-function' wants the link name.
(and (path-iter-ignore-function iter)
(funcall (path-iter-ignore-function iter) absname)))
- (push (file-truename absname) subdirs))
+ (push (file-name-as-directory (file-truename absname)) subdirs))
)
(directory-files result t))
- [elpa] branch externals/path-iterator created (now a981172), Stefan Monnier, 2020/12/01
- [elpa] externals/path-iterator b52f084 01/10: Add package path-iterator, version 0, Stefan Monnier, 2020/12/01
- [elpa] externals/path-iterator df995c1 02/10: In path-iterator, fix header comment syntax, add Commentary, Stefan Monnier, 2020/12/01
- [elpa] externals/path-iterator e266320 04/10: In path-iterator, add new function and test, Stefan Monnier, 2020/12/01
- [elpa] externals/path-iterator a981172 10/10: * .gitignore: New file, Stefan Monnier, 2020/12/01
- [elpa] externals/path-iterator a8f6f40 03/10: Improve uniquify-files; add tests. Add path-iterator tests, Stefan Monnier, 2020/12/01
- [elpa] externals/path-iterator df6a5e2 09/10: Release path-iterator.el, uniquify-files.el, Stefan Monnier, 2020/12/01
- [elpa] externals/path-iterator dc2e0cb 05/10: Improve path-iterator, Stefan Monnier, 2020/12/01
- [elpa] externals/path-iterator e3a6a86 06/10: Improve path-iterator handline of duplicate directories, Stefan Monnier, 2020/12/01
- [elpa] externals/path-iterator 0e59874 07/10: In uniquify-files, factor out file-complete.el,
Stefan Monnier <=
- [elpa] externals/path-iterator 92c5173 08/10: In ada-mode, wisi; release ada-mode 6.1.1, wisi 2.1.1, Stefan Monnier, 2020/12/01