[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 055e2a1: insert-directory-wildcard-in-dir-p: Tweak
From: |
Tino Calancha |
Subject: |
[Emacs-diffs] master 055e2a1: insert-directory-wildcard-in-dir-p: Tweak regexp |
Date: |
Sat, 5 Aug 2017 01:21:16 -0400 (EDT) |
branch: master
commit 055e2a1906a2f02c7b77537cbb4df858b00b39d9
Author: Tino Calancha <address@hidden>
Commit: Tino Calancha <address@hidden>
insert-directory-wildcard-in-dir-p: Tweak regexp
This function must return non-nil for a wildcard like '/*/*.txt'.
* lisp/files.el (insert-directory-wildcard-in-dir-p): Adjust regexp.
* test/lisp/files-tests.el
(files-tests--insert-directory-wildcard-in-dir-p):
Add test.
---
lisp/files.el | 2 +-
test/lisp/files-tests.el | 18 ++++++++++++++++++
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/lisp/files.el b/lisp/files.el
index 89f6f9f..c9114be 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -6566,7 +6566,7 @@ Valid wildcards are '*', '?', '[abc]' and '[a-z]'."
ls-lisp-support-shell-wildcards)
(string-match (concat "[" wildcards "]") (file-name-directory
dir))
(not (file-exists-p dir))) ; Prefer an existing file to
wildcards.
- (let ((regexp (format "\\`\\([^%s]+/\\)\\([^%s]*[%s].*\\)"
+ (let ((regexp (format "\\`\\([^%s]*/\\)\\([^%s]*[%s].*\\)"
wildcards wildcards wildcards)))
(string-match regexp dir)
(cons (match-string 1 dir) (match-string 2 dir))))))
diff --git a/test/lisp/files-tests.el b/test/lisp/files-tests.el
index 4583b1a..59c1dbc 100644
--- a/test/lisp/files-tests.el
+++ b/test/lisp/files-tests.el
@@ -313,5 +313,23 @@ be invoked with the right arguments."
`((verify-visited-file-modtime ,buffer-visiting-file)
(verify-visited-file-modtime nil))))))))
+(ert-deftest files-tests--insert-directory-wildcard-in-dir-p ()
+ (let ((alist (list (cons "/home/user/*/.txt" (cons "/home/user/" "*/.txt"))
+ (cons "/home/user/.txt" nil)
+ (cons "/home/*/.txt" (cons "/home/" "*/.txt"))
+ (cons "/home/*/" (cons "/home/" "*/"))
+ (cons "/*/.txt" (cons "/" "*/.txt"))
+ ;;
+ (cons "c:/tmp/*/*.txt" (cons "c:/tmp/" "*/*.txt"))
+ (cons "c:/tmp/*.txt" nil)
+ (cons "c:/tmp/*/" (cons "c:/tmp/" "*/"))
+ (cons "c:/*/*.txt" (cons "c:/" "*/*.txt")))))
+ (dolist (path-res alist)
+ (should
+ (equal
+ (cdr path-res)
+ (insert-directory-wildcard-in-dir-p (car path-res)))))))
+
+
(provide 'files-tests)
;;; files-tests.el ends here
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 055e2a1: insert-directory-wildcard-in-dir-p: Tweak regexp,
Tino Calancha <=