[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/uniquify-files 3509563 09/22: Improve uniquify-files in
From: |
Stefan Monnier |
Subject: |
[elpa] externals/uniquify-files 3509563 09/22: Improve uniquify-files in corner case |
Date: |
Tue, 1 Dec 2020 17:36:20 -0500 (EST) |
branch: externals/uniquify-files
commit 3509563134202b75ed85c4439ff5b701011bf1f6
Author: Stephen Leake <stephen_leake@stephe-leake.org>
Commit: Stephen Leake <stephen_leake@stephe-leake.org>
Improve uniquify-files in corner case
* packages/uniquify-files/uniquify-files.el (uniq-file--dir-match):
Include trailing directories.
(locate-uniquified-file-iter, -2): Set completion-category-overrides.
* packages/uniquify-files/uniquify-files-test.el:
(test-uniq-file-all-completions-noface-1): Add test of corner case.
---
uniquify-files-test.el | 4 ++++
uniquify-files.el | 24 ++++++++++++++++--------
2 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/uniquify-files-test.el b/uniquify-files-test.el
index 8950cbd..4dc1923 100644
--- a/uniquify-files-test.el
+++ b/uniquify-files-test.el
@@ -356,6 +356,10 @@
"foo-file4.text<Alice/alice-3/>"
"foo-file4.text<Bob/alice-3/>")))
+ (should (equal (sort (uniq-file-all-completions "foo-file4.text<Bob" table
nil nil) #'string-lessp)
+ (list
+ "foo-file4.text<Bob/alice-3/>")))
+
(should (equal (uniq-file-all-completions "f-file5" table nil nil)
(list "foo-file5.text")))
diff --git a/uniquify-files.el b/uniquify-files.el
index b36ec11..59575c2 100644
--- a/uniquify-files.el
+++ b/uniquify-files.el
@@ -191,17 +191,20 @@ Match 1 is the filename, match 2 is the relative
directory.")
(regex (completion-pcm--pattern->regex pattern)))
;; `regex' is anchored at the beginning; delete the anchor to
- ;; match a directory in the middle of ABS. Also extend
- ;; the match to the bounding '/'.
+ ;; match a directory in the middle of ABS.
(setq regex (substring regex 2))
+
+ ;; Include the preceding and following '/' .
(unless (= ?/ (aref regex 0))
(setq regex (concat "/" regex)))
(unless (= ?/ (aref regex (1- (length regex))))
(setq regex (concat regex "[^/]*/" )))
(when (string-match regex abs);; Should never fail, but gives obscure
error if it does
- ;; Drop the leading '/'
- (substring (match-string 0 abs) 1))
+
+ ;; Drop the leading '/', include all trailing directories;
+ ;; consider Bob/alice-3/foo, Alice/alice-3/foo.
+ (substring abs (1+ (match-beginning 0))))
))
(t
@@ -792,10 +795,15 @@ file name is included in the result if PRED returns
non-nil. DEFAULT is the default for completion.
In the user input string, `*' is treated as a wildcard."
- (completing-read (format (concat (or prompt "file") " (%s): ") default)
- (apply-partially #'uniq-file-completion-table iter)
- predicate t nil nil default)
- )
+ (let* ((table (apply-partially #'uniq-file-completion-table iter))
+ (table-styles (cdr (assq 'styles (completion-metadata "" table nil))))
+ (completion-category-overrides
+ (list (list 'project-file (cons 'styles table-styles)))))
+
+ (completing-read (format (concat (or prompt "file") " (%s): ") default)
+ table
+ predicate t nil nil default)
+ ))
(defun locate-uniquified-file-iter-2 (iter &optional predicate default prompt)
"Same as `locate-uniquified-file-iter', but the internal
- [elpa] branch externals/uniquify-files created (now 7b15736), Stefan Monnier, 2020/12/01
- [elpa] externals/uniquify-files 2da9386 01/22: Add package uniquify-files, Stefan Monnier, 2020/12/01
- [elpa] externals/uniquify-files dde6e90 02/22: Fix unparsable file header, Stefan Monnier, 2020/12/01
- [elpa] externals/uniquify-files 6ee5d3d 03/22: Improve uniquify-files; add tests. Add path-iterator tests, Stefan Monnier, 2020/12/01
- [elpa] externals/uniquify-files 0f9a6bf 05/22: Fix bugs, add tests in uniquify-files, Stefan Monnier, 2020/12/01
- [elpa] externals/uniquify-files a693813 04/22: In uniquify-files, handle list tables, refactor code, update tests, Stefan Monnier, 2020/12/01
- [elpa] externals/uniquify-files 7affc92 08/22: Improve uniquify-files, Stefan Monnier, 2020/12/01
- [elpa] externals/uniquify-files 3509563 09/22: Improve uniquify-files in corner case,
Stefan Monnier <=
- [elpa] externals/uniquify-files f2d8f76 12/22: In uniquify-files/file-complete-root-relative.el, delete extra paren, Stefan Monnier, 2020/12/01
- [elpa] externals/uniquify-files 95acec3 19/22: In ada-mode and wisi, release ada-mode 6.2.1, wisi 2.2.1; fix packaging bugs, Stefan Monnier, 2020/12/01
- [elpa] externals/uniquify-files 45a4eb3 21/22: In uniquify-files.el uniq-file-completion-table, fix compatibility with 25.3, Stefan Monnier, 2020/12/01
- [elpa] externals/uniquify-files ba4f850 07/22: In uniquify-files, add another file completion style, Stefan Monnier, 2020/12/01
- [elpa] externals/uniquify-files bce1da7 10/22: Fix bugs in uniquify-files, Stefan Monnier, 2020/12/01
- [elpa] externals/uniquify-files 4ebe003 14/22: In uniquify-files, improve completion table to work with other styles, Stefan Monnier, 2020/12/01
- [elpa] externals/uniquify-files 2257858 18/22: Release path-iterator.el, uniquify-files.el, Stefan Monnier, 2020/12/01
- [elpa] externals/uniquify-files 8d2322c 06/22: Improve uniquify-files-test.el, improve uniquify-files to handle new tests, Stefan Monnier, 2020/12/01
- [elpa] externals/uniquify-files 4edece3 17/22: In packages/uniquify-files/uniquify-files.el: fix typo, Stefan Monnier, 2020/12/01
- [elpa] externals/uniquify-files f264c36 15/22: In uniquify-files, factor out file-complete.el, Stefan Monnier, 2020/12/01