branch: master commit 3b3ca829a98f91e475574cfd8b59d607c76cebec Author: Stephen Leake <stephen_le...@stephe-leake.org> Commit: Stephen Leake <stephen_le...@stephe-leake.org>
Fix bugs, add tests in uniquify-files * packages/uniquify-files/uniquify-files.el: Fix bugs. * packages/uniquify-files/uniquify-files-test.el: (test-uniquify-file-all-completions-noface-func): Rename from test-uniquify-file-all-completions-noface, take table input. (test-uniquify-file-all-completions-noface-func) (test-uniquify-file-all-completions-noface-list): New; test function and list tables. (test-uniq-file-try-completion-1): Rename from test-uniq-file-try-completion, take table input, add tests on case-fold-search nil and t. (test-uniq-file-try-completion-func, test-uniq-file-try-completion-list): New; test function and list tables. --- packages/uniquify-files/uniquify-files-test.el | 369 ++++++++++++++----------- packages/uniquify-files/uniquify-files.el | 67 ++--- 2 files changed, 235 insertions(+), 201 deletions(-) diff --git a/packages/uniquify-files/uniquify-files-test.el b/packages/uniquify-files/uniquify-files-test.el index 935814b..0375749 100644 --- a/packages/uniquify-files/uniquify-files-test.el +++ b/packages/uniquify-files/uniquify-files-test.el @@ -167,7 +167,7 @@ (should (equal (test-completion "foo-file1.text<alice-1/>" table) t)) - (should (equal (test-completion "foo-file3.text" table) + (should (equal (test-completion "foo-file3.tex" table) ;; partial file name nil)) (should (equal (test-completion "foo-file3.texts2" table) @@ -186,153 +186,160 @@ (completion-styles '(uniquify-file))) ;; FIXME: need a way to specify category (test-uniq-file-test-completion-1 table))) -(ert-deftest test-uniquify-file-all-completions-noface () - (let ((table (apply-partially 'uniq-file-completion-table uft-iter))) - - (should (equal - (sort (uniq-file-all-completions "" table nil nil) #'string-lessp) - (list - "bar-file1.text<alice-1/>" - "bar-file1.text<alice-2/>" - "bar-file2.text<alice-1/>" - "bar-file2.text<alice-2/>" - "foo-file1.text<>" - "foo-file1.text<Alice/alice-1/>" - "foo-file1.text<Alice/alice-2/>" - "foo-file1.text<Bob/bob-1/>" - "foo-file1.text<Bob/bob-2/>" - "foo-file2.text<Alice/alice-1/>" - "foo-file2.text<Bob/bob-1/>" - "foo-file3.text" - "foo-file3.texts" - "foo-file3.texts2" - "foo-file5.text" - ))) - - (should (equal - (sort (uniq-file-all-completions "*-fi" table nil nil) #'string-lessp) - (list - "bar-file1.text<alice-1/>" - "bar-file1.text<alice-2/>" - "bar-file2.text<alice-1/>" - "bar-file2.text<alice-2/>" - "foo-file1.text<>" - "foo-file1.text<Alice/alice-1/>" - "foo-file1.text<Alice/alice-2/>" - "foo-file1.text<Bob/bob-1/>" - "foo-file1.text<Bob/bob-2/>" - "foo-file2.text<Alice/alice-1/>" - "foo-file2.text<Bob/bob-1/>" - "foo-file3.text" - "foo-file3.texts" - "foo-file3.texts2" - "foo-file5.text" - ))) - - (should (equal - (sort (uniq-file-all-completions "b" table nil nil) #'string-lessp) - (list - "bar-file1.text<alice-1/>" - "bar-file1.text<alice-2/>" - "bar-file2.text<alice-1/>" - "bar-file2.text<alice-2/>" - ))) - - (should (equal - (sort (uniq-file-all-completions "foo" table nil nil) #'string-lessp) - (list - "foo-file1.text<>" - "foo-file1.text<Alice/alice-1/>" - "foo-file1.text<Alice/alice-2/>" - "foo-file1.text<Bob/bob-1/>" - "foo-file1.text<Bob/bob-2/>" - "foo-file2.text<Alice/alice-1/>" - "foo-file2.text<Bob/bob-1/>" - "foo-file3.text" - "foo-file3.texts" - "foo-file3.texts2" - "foo-file5.text" - ))) - - (should (equal - (sort (uniq-file-all-completions "f-file2" table nil nil) #'string-lessp) - (list - "foo-file2.text<Alice/alice-1/>" - "foo-file2.text<Bob/bob-1/>" - ))) - - (should (equal - (sort (uniq-file-all-completions "b-fi<" table nil nil) #'string-lessp) - (list - "bar-file1.text<alice-1/>" - "bar-file1.text<alice-2/>" - "bar-file2.text<alice-1/>" - "bar-file2.text<alice-2/>" - ))) - - (should (equal - (sort (uniq-file-all-completions "f-file<" table nil nil) #'string-lessp) - (list - "foo-file1.text<>" - "foo-file1.text<Alice/alice-1/>" - "foo-file1.text<Alice/alice-2/>" - "foo-file1.text<Bob/bob-1/>" - "foo-file1.text<Bob/bob-2/>" - "foo-file2.text<Alice/alice-1/>" - "foo-file2.text<Bob/bob-1/>" - "foo-file3.text" - "foo-file3.texts" - "foo-file3.texts2" - "foo-file5.text" - ))) - - (should (equal - (sort (uniq-file-all-completions "b-fi<a-" table nil nil) #'string-lessp) - ;; FIXME: This result reflects a bug in - ;; `completion-pcm--pattern->regex'; "a-" becomes - ;; "a.*?-", but it should be (concat "a[^" - ;; wildcards "]*-". - (list - "bar-file1.text<Alice/alice-1/>" - "bar-file1.text<Alice/alice-2/>" - "bar-file2.text<Alice/alice-1/>" - "bar-file2.text<Alice/alice-2/>" - ))) - - (should (equal - (sort (uniq-file-all-completions "b-fi<a-1" table nil nil) #'string-lessp) - (list "bar-file1.text<Alice/alice-1/>" - "bar-file2.text<Alice/alice-1/>"))) - - (should (equal (uniq-file-all-completions "f-file1.text<a-1" table nil nil) - (list "foo-file1.text<Alice/alice-1/>"))) - - (should (equal (uniq-file-all-completions "f-file5" table nil nil) - (list "foo-file5.text"))) - - (should (equal (uniq-file-all-completions "foo-file1.text<Alice/alice-1/>" table nil nil) - (list "foo-file1.text<Alice/alice-1/>"))) +(defun test-uniquify-file-all-completions-noface-1 (table) + (should (equal + (sort (uniq-file-all-completions "" table nil nil) #'string-lessp) + (list + "bar-file1.text<alice-1/>" + "bar-file1.text<alice-2/>" + "bar-file2.text<alice-1/>" + "bar-file2.text<alice-2/>" + "foo-file1.text<>" + "foo-file1.text<Alice/alice-1/>" + "foo-file1.text<Alice/alice-2/>" + "foo-file1.text<Bob/bob-1/>" + "foo-file1.text<Bob/bob-2/>" + "foo-file2.text<Alice/alice-1/>" + "foo-file2.text<Bob/bob-1/>" + "foo-file3.text" + "foo-file3.texts" + "foo-file3.texts2" + "foo-file5.text" + ))) + + (should (equal + (sort (uniq-file-all-completions "*-fi" table nil nil) #'string-lessp) + (list + "bar-file1.text<alice-1/>" + "bar-file1.text<alice-2/>" + "bar-file2.text<alice-1/>" + "bar-file2.text<alice-2/>" + "foo-file1.text<>" + "foo-file1.text<Alice/alice-1/>" + "foo-file1.text<Alice/alice-2/>" + "foo-file1.text<Bob/bob-1/>" + "foo-file1.text<Bob/bob-2/>" + "foo-file2.text<Alice/alice-1/>" + "foo-file2.text<Bob/bob-1/>" + "foo-file3.text" + "foo-file3.texts" + "foo-file3.texts2" + "foo-file5.text" + ))) + + (should (equal + (sort (uniq-file-all-completions "b" table nil nil) #'string-lessp) + (list + "bar-file1.text<alice-1/>" + "bar-file1.text<alice-2/>" + "bar-file2.text<alice-1/>" + "bar-file2.text<alice-2/>" + ))) + + (should (equal + (sort (uniq-file-all-completions "foo" table nil nil) #'string-lessp) + (list + "foo-file1.text<>" + "foo-file1.text<Alice/alice-1/>" + "foo-file1.text<Alice/alice-2/>" + "foo-file1.text<Bob/bob-1/>" + "foo-file1.text<Bob/bob-2/>" + "foo-file2.text<Alice/alice-1/>" + "foo-file2.text<Bob/bob-1/>" + "foo-file3.text" + "foo-file3.texts" + "foo-file3.texts2" + "foo-file5.text" + ))) + + (should (equal + (sort (uniq-file-all-completions "f-file2" table nil nil) #'string-lessp) + (list + "foo-file2.text<Alice/alice-1/>" + "foo-file2.text<Bob/bob-1/>" + ))) + + (should (equal + (sort (uniq-file-all-completions "b-fi<" table nil nil) #'string-lessp) + (list + "bar-file1.text<alice-1/>" + "bar-file1.text<alice-2/>" + "bar-file2.text<alice-1/>" + "bar-file2.text<alice-2/>" + ))) + + (should (equal + (sort (uniq-file-all-completions "f-file<" table nil nil) #'string-lessp) + (list + "foo-file1.text<>" + "foo-file1.text<Alice/alice-1/>" + "foo-file1.text<Alice/alice-2/>" + "foo-file1.text<Bob/bob-1/>" + "foo-file1.text<Bob/bob-2/>" + "foo-file2.text<Alice/alice-1/>" + "foo-file2.text<Bob/bob-1/>" + "foo-file3.text" + "foo-file3.texts" + "foo-file3.texts2" + "foo-file5.text" + ))) + + (should (equal + (sort (uniq-file-all-completions "b-fi<a-" table nil nil) #'string-lessp) + ;; FIXME: This result reflects a bug in + ;; `completion-pcm--pattern->regex'; "a-" becomes + ;; "a.*?-", but it should be (concat "a[^" + ;; wildcards "]*-". + (list + "bar-file1.text<Alice/alice-1/>" + "bar-file1.text<Alice/alice-2/>" + "bar-file2.text<Alice/alice-1/>" + "bar-file2.text<Alice/alice-2/>" + ))) + + (should (equal + (sort (uniq-file-all-completions "b-fi<a-1" table nil nil) #'string-lessp) + (list "bar-file1.text<Alice/alice-1/>" + "bar-file2.text<Alice/alice-1/>"))) + + (should (equal (uniq-file-all-completions "f-file1.text<a-1" table nil nil) + (list "foo-file1.text<Alice/alice-1/>"))) + + (should (equal (uniq-file-all-completions "f-file5" table nil nil) + (list "foo-file5.text"))) + + (should (equal (uniq-file-all-completions "foo-file1.text<Alice/alice-1/>" table nil nil) + (list "foo-file1.text<Alice/alice-1/>"))) + + (should (equal + (sort (uniq-file-all-completions "b-fi<a>" table nil nil) #'string-lessp) + (list + "bar-file1.text<Alice/alice-1/>" + "bar-file1.text<Alice/alice-2/>" + "bar-file2.text<Alice/alice-1/>" + "bar-file2.text<Alice/alice-2/>" + ))) + + (should (equal + (sort (uniq-file-all-completions "foo-file1.text<>" table nil nil) #'string-lessp) + ;; This is complete but not unique, because the directory part matches multiple directories. + (list + "foo-file1.text<>" + "foo-file1.text<Alice/alice-1/>" + "foo-file1.text<Alice/alice-2/>" + "foo-file1.text<Bob/bob-1/>" + "foo-file1.text<Bob/bob-2/>" + ))) + ) - (should (equal - (sort (uniq-file-all-completions "b-fi<a>" table nil nil) #'string-lessp) - (list - "bar-file1.text<Alice/alice-1/>" - "bar-file1.text<Alice/alice-2/>" - "bar-file2.text<Alice/alice-1/>" - "bar-file2.text<Alice/alice-2/>" - ))) +(ert-deftest test-uniquify-file-all-completions-noface-func () + (let ((table (apply-partially 'uniq-file-completion-table uft-iter))) + (test-uniquify-file-all-completions-noface-1 table))) - (should (equal - (sort (uniq-file-all-completions "foo-file1.text<>" table nil nil) #'string-lessp) - ;; This is complete but not unique, because the directory part matches multiple directories. - (list - "foo-file1.text<>" - "foo-file1.text<Alice/alice-1/>" - "foo-file1.text<Alice/alice-2/>" - "foo-file1.text<Bob/bob-1/>" - "foo-file1.text<Bob/bob-2/>" - ))) - )) +(ert-deftest test-uniquify-file-all-completions-noface-list () + (let ((table (path-iter-all-files uft-iter)) + (completion-styles '(uniquify-file))) ;; FIXME: need a way to specify category + (test-uniquify-file-all-completions-noface-1 table))) (defun test-uniq-file-hilit (pos-list string) "Set 'face text property to 'completions-first-difference at @@ -434,9 +441,8 @@ all positions in POS-LIST in STRING; return new string." )) -(ert-deftest test-uniq-file-try-completion () - (let ((table (apply-partially 'uniq-file-completion-table uft-iter)) - string) +(defun test-uniq-file-try-completion-1 (table) + (let (string) (setq string "fo") (should (equal (uniq-file-try-completion string table nil (length string)) @@ -448,9 +454,17 @@ all positions in POS-LIST in STRING; return new string." (setq string "fo<al") (should (equal (uniq-file-try-completion string table nil 2) - '("foo-file<Alice/" . 8))) + '("foo-file<alice-" . 8))) (should (equal (uniq-file-try-completion string table nil 5) - '("foo-file<Alice/" . 15))) + '("foo-file<alice-" . 15))) + + (let ((case-fold-search t)) + (setq string "fo<al") + (should (equal (uniq-file-try-completion string table nil 2) + '("foo-file<Alice/" . 8))) + (should (equal (uniq-file-try-completion string table nil 5) + '("foo-file<Alice/" . 15))) + ) (setq string "foo-file3") ;; not unique, not valid (should (equal (uniq-file-try-completion string table nil (length string)) @@ -458,7 +472,13 @@ all positions in POS-LIST in STRING; return new string." (setq string "f-file1.text<a-1") ;; unique but not valid (should (equal (uniq-file-try-completion string table nil (length string)) - '("foo-file1.text<Alice/alice-1/>" . 30))) + '("foo-file1.text<alice-1/>" . 24))) + + (let ((case-fold-search t)) + (setq string "f-file1.text<a-1") ;; unique but not valid + (should (equal (uniq-file-try-completion string table nil (length string)) + '("foo-file1.text<Alice/alice-1/>" . 30))) + ) (setq string "foo-file1.text") ;; valid but not unique (should (equal (uniq-file-try-completion string table nil (length string)) @@ -476,6 +496,12 @@ all positions in POS-LIST in STRING; return new string." (should (equal (uniq-file-try-completion string table nil (length string)) t)) + (let ((case-fold-search t)) + (setq string "foo-file1.text<alice-1/>") ;; valid and unique, but accidental match on Alice + (should (equal (uniq-file-try-completion string table nil (length string)) + '("foo-file1.text<Alice/alice-1/>" . 30))) + ) + (setq string "foo-file3.texts") ;; not unique, valid (should (equal (uniq-file-try-completion string table nil (length string)) '("foo-file3.texts" . 15))) @@ -488,7 +514,6 @@ all positions in POS-LIST in STRING; return new string." (should (equal (uniq-file-try-completion string table nil (length string)) nil)) - ;; User input sequence: b-file2 (setq string "b-file2") (should (equal (uniq-file-try-completion string table nil (length string)) '("bar-file2.text<alice-" . 21))) @@ -496,21 +521,32 @@ all positions in POS-LIST in STRING; return new string." ;; prev + <tab>; input is prev output (setq string "bar-file2.text<alice-") (should (equal (uniq-file-try-completion string table nil (length string)) - '("bar-file2.text<Alice/alice-" . 27))) + '("bar-file2.text<alice-" . 21))) ;; prev + <tab>; input is prev output - (setq string "bar-file2.text<Alice/alice-") + (setq string "bar-file2.text<alice-") (should (equal (uniq-file-try-completion string table nil (length string)) - '("bar-file2.text<Alice/alice-" . 27))) + '("bar-file2.text<alice-" . 21))) ;; completion-try-completion called from icomplete-completions with - ;; result of all-completions instead of table function, but with table metadata. + ;; result of all-completions instead of table function. (setq string "f-file<") (let ((comps (uniq-file-all-completions string table nil nil))) (should (equal (uniq-file-try-completion string comps nil (length string)) (cons "foo-file" 8)))) )) +(ert-deftest test-uniq-file-try-completion-func () + (let ((table (apply-partially 'uniq-file-completion-table uft-iter)) + (case-fold-search nil)) + (test-uniq-file-try-completion-1 table))) + +(ert-deftest test-uniq-file-try-completion-list () + (let ((table (path-iter-all-files uft-iter)) + (case-fold-search nil) + (completion-styles '(uniquify-file))) ;; FIXME: need a way to specify category + (test-uniq-file-try-completion-1 table))) + (ert-deftest test-uniq-file-get-data-string () (let ((table (apply-partially 'uniq-file-completion-table uft-iter))) @@ -552,7 +588,7 @@ all positions in POS-LIST in STRING; return new string." ) (ert-deftest test-uniq-file-uniquify () - (should (equal (uniq-file-uniquify + (should (equal (uniq-file--uniquify '("/Alice/alice1/file1.text" "/Alice/alice1/file2.text" "/Alice/alice2/file1.text" "/Alice/alice2/file3.text" "/Bob/bob1/file1.text") @@ -563,19 +599,19 @@ all positions in POS-LIST in STRING; return new string." "file2.text" "file3.text"))) - (should (equal (uniq-file-uniquify '("/Alice/alice1/file1.text" "/Alice/alice2/file1.text") nil) + (should (equal (uniq-file--uniquify '("/Alice/alice1/file1.text" "/Alice/alice2/file1.text") nil) (list "file1.text<alice1/>" "file1.text<alice2/>"))) - (should (equal (uniq-file-uniquify '("/alice1/file2.text") nil) + (should (equal (uniq-file--uniquify '("/alice1/file2.text") nil) (list "file2.text"))) - (should (equal (uniq-file-uniquify + (should (equal (uniq-file--uniquify '("c:/tmp/test/alice-1/bar-file1.text" "c:/tmp/test/alice-1/bar-file2.text") "a-1") (list "bar-file1.text<alice-1/>" "bar-file2.text<alice-1/>"))) - (should (equal (uniq-file-uniquify + (should (equal (uniq-file--uniquify '("c:/tmp/Alice/alice-1/bar-file1.text" "c:/tmp/Alice/alice-1/bar-file2.text" "c:/tmp/Alice/alice-2/bar-file2.text") @@ -590,7 +626,7 @@ all positions in POS-LIST in STRING; return new string." "bar-file2.text<Alice/alice-1/>" "bar-file2.text<Alice/alice-2/>"))) - (should (equal (uniq-file-uniquify + (should (equal (uniq-file--uniquify '("c:/tmp/Alice/alice-1/bar-file1.text" "c:/tmp/Alice/alice-1/bar-file2.text" "c:/tmp/Alice/alice-2/bar-file2.text") @@ -600,7 +636,7 @@ all positions in POS-LIST in STRING; return new string." "bar-file2.text<Alice/alice-2/>"))) ;; From "foo-file1.text<>" - (should (equal (uniq-file-uniquify + (should (equal (uniq-file--uniquify (list (concat uft-alice1 "/foo-file1.text") (concat uft-alice2 "/foo-file1.text") @@ -618,7 +654,7 @@ all positions in POS-LIST in STRING; return new string." ))) ;; from cedet-global-test - (should (equal (uniq-file-uniquify + (should (equal (uniq-file--uniquify (list (concat uft-alice1 "/bar-file1.c") (concat uft-alice1 "/bar-file2.c") @@ -642,8 +678,5 @@ all positions in POS-LIST in STRING; return new string." ))) ) -;; FIXME: need higher-level tests, on completion-*-completion, to -;; check completion-category, completion-styles-alist. - (provide 'uniquify-files-test) ;;; uniquify-files-test.el ends here diff --git a/packages/uniquify-files/uniquify-files.el b/packages/uniquify-files/uniquify-files.el index 1bd97f3..b3cd044 100644 --- a/packages/uniquify-files/uniquify-files.el +++ b/packages/uniquify-files/uniquify-files.el @@ -273,7 +273,7 @@ If DIR is non-nil, all elements of NAMES must match DIR." conflicts ;; list of names where all non-directory names are the same. ) - ;; Sort names so duplicates are grouped together + ;; Sort names on basename so duplicates are grouped together (setq names (sort names (lambda (a b) (string< (file-name-nondirectory a) (file-name-nondirectory b))))) @@ -354,8 +354,10 @@ STRING should be in completion table input format." (file-regex (completion-pcm--pattern->regex file-pattern))) (list dir-regex file-regex))) -(defun uniq-file--pcm-merged-pat (user-string all point &optional extra-delim) - "Return a pcm pattern that is the merged completion of strings in ALL." +(defun uniq-file--pcm-merged-pat (string all point &optional extra-delim) + "Return a pcm pattern that is the merged completion of STRING in ALL. +ALL must be a list of table input format strings? +Pattern is in reverse order." (let* ((completion-pcm--delim-wild-regex (concat "[" completion-pcm-word-delimiters extra-delim "*]")) ;; If STRING ends in an empty directory part, some valid @@ -366,12 +368,13 @@ STRING should be in completion table input format." (substring string 0 -1) string)) (pattern (completion-pcm--string->pattern trimmed-string point))) - (nreverse (completion-pcm--merge-completions all pattern)) + (completion-pcm--merge-completions all pattern) )) -(defun uniq-file-try-completion (string table pred point) +(defun uniq-file-try-completion (user-string table pred point) "Implement `completion-try-completion' for uniquify-file." - ;; Returns list of user format strings (uniquified file names), nil, or t. + ;; Returns common leading substring of completions of USER-STRING in table, + ;; consed with new point (length of common substring). (let (result uniq-all done) @@ -383,27 +386,26 @@ STRING should be in completion table input format." (and (consp table) (file-name-absolute-p (car table)))) ;; TABLE is the original list of absolute file names. - (let* ((table-string (uniq-file-to-table-input string)) - (abs-all (all-completions table-string table pred))) + (setq uniq-all (uniq-file-all-completions user-string table pred point)) - (cond - ((null abs-all) ;; No matches. - (setq result nil) - (setq done t)) + (cond + ((null uniq-all) ;; No matches. + (setq result nil) + (setq done t)) - ((= 1 (length abs-all)) ;; One match; unique. - (setq done t) + ((= 1 (length uniq-all)) ;; One match; unique. + (setq done t) - (if (uniq-file--valid-completion table-string abs-all) - (setq result t) + ;; Check for valid completion + (if (string-equal user-string (car uniq-all)) + (setq result t) - (setq result (car (uniq-file--uniquify abs-all (file-name-directory table-string)))) - (setq result (cons result (length result))))) + (setq result (car uniq-all)) + (setq result (cons result (length result))))) - (t ;; Multiple matches - (setq uniq-all (uniq-file--uniquify abs-all (file-name-directory table-string))) - (setq done nil)) - ))) + (t ;; Multiple matches + (setq done nil)) + )) ;; The following cases handle being called from ;; icomplete-completions with the result of `all-completions' @@ -423,7 +425,7 @@ STRING should be in completion table input format." result ;; Find merged completion of uniqified file names - (let* ((merged-pat (uniq-file--pcm-merged-pat string uniq-all point "<>")) + (let* ((merged-pat (uniq-file--pcm-merged-pat user-string uniq-all point "<>")) ;; `merged-pat' is in reverse order. Place new point at: (point-pat (or (memq 'point merged-pat) ;; the old point @@ -452,7 +454,7 @@ Returns new list. Adds the face `completions-first-difference' to the first character after each completion field." - (let* ((merged-pat (uniq-file--pcm-merged-pat string all point extra-delim)) + (let* ((merged-pat (nreverse (uniq-file--pcm-merged-pat string all point extra-delim))) (field-count 0) (regex (completion-pcm--pattern->regex merged-pat '(any star any-delim point))) ) @@ -461,17 +463,17 @@ character after each completion field." (setq field-count (1+ field-count)))) (mapcar - (lambda (string) - (when (string-match regex string) + (lambda (str) + (when (string-match regex str) (cl-loop for i from 1 to field-count do (when (and (match-beginning i) - (<= (1+ (match-beginning i)) (length string))) - (put-text-property (match-beginning i) (1+ (match-beginning i)) 'face 'completions-first-difference string)) + (<= (1+ (match-beginning i)) (length str))) + (put-text-property (match-beginning i) (1+ (match-beginning i)) 'face 'completions-first-difference str)) )) - string) + str) all))) (defun uniq-file--match-list (regexp-list file-name) @@ -492,8 +494,7 @@ nil otherwise." (cond ((functionp table) - (setq all (uniq-file--uniquify (funcall table table-string pred t) - (file-name-directory table-string)))) + (setq all (funcall table table-string pred t))) ((and (consp table) (file-name-absolute-p (car table))) @@ -506,8 +507,7 @@ nil otherwise." (dolist (file-name table) (when (and (string-match dir-regex (directory-file-name file-name)) - (not (directory-name-p file-name)) - (uniq-file--match-list completion-regexp-list file-name) + (uniq-file--match-list completion-regexp-list (file-name-nondirectory file-name)) (or (null pred) (funcall pred file-name))) (push file-name all))) @@ -515,6 +515,7 @@ nil otherwise." ) (when all + (setq all (uniq-file--uniquify all (file-name-directory table-string))) (uniq-files--hilit user-string all point "<>")) ))