diff options
| author | Jim Porter | 2022-03-08 17:07:26 -0800 |
|---|---|---|
| committer | Eli Zaretskii | 2022-04-17 10:27:39 +0300 |
| commit | bbb92dde01ec3fc46b24247fb2d181a21dbcc40a (patch) | |
| tree | 46c8eaede0f5d432d447fefb768338f9e847ef4a /lisp/eshell | |
| parent | 265f4ef70233c4708cbbdeb1850541570c40fdd6 (diff) | |
| download | emacs-bbb92dde01ec3fc46b24247fb2d181a21dbcc40a.tar.gz emacs-bbb92dde01ec3fc46b24247fb2d181a21dbcc40a.zip | |
Add unit tests and documentation for Eshell pattern-based globs
* lisp/eshell/em-glob.el (eshell-extended-glob): Fix docstring.
(eshell-glob-entries): Refer to '**/' in error (technically, '**' can
end a glob, but it means the same thing as '*'). (Bug#54470)
* test/lisp/eshell/em-glob-tests.el: New file.
* doc/misc/eshell.texi (Globbing): Document pattern-based globs.
Diffstat (limited to 'lisp/eshell')
| -rw-r--r-- | lisp/eshell/em-glob.el | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/lisp/eshell/em-glob.el b/lisp/eshell/em-glob.el index 842f27a4920..52531ff8939 100644 --- a/lisp/eshell/em-glob.el +++ b/lisp/eshell/em-glob.el | |||
| @@ -233,7 +233,10 @@ resulting regular expression." | |||
| 233 | "\\'"))) | 233 | "\\'"))) |
| 234 | 234 | ||
| 235 | (defun eshell-extended-glob (glob) | 235 | (defun eshell-extended-glob (glob) |
| 236 | "Return a list of files generated from GLOB, perhaps looking for DIRS-ONLY. | 236 | "Return a list of files matched by GLOB. |
| 237 | If no files match, signal an error (if `eshell-error-if-no-glob' | ||
| 238 | is non-nil), or otherwise return GLOB itself. | ||
| 239 | |||
| 237 | This function almost fully supports zsh style filename generation | 240 | This function almost fully supports zsh style filename generation |
| 238 | syntax. Things that are not supported are: | 241 | syntax. Things that are not supported are: |
| 239 | 242 | ||
| @@ -243,12 +246,7 @@ syntax. Things that are not supported are: | |||
| 243 | foo~x(a|b) (a|b) will be interpreted as a predicate/modifier list | 246 | foo~x(a|b) (a|b) will be interpreted as a predicate/modifier list |
| 244 | 247 | ||
| 245 | Mainly they are not supported because file matching is done with Emacs | 248 | Mainly they are not supported because file matching is done with Emacs |
| 246 | regular expressions, and these cannot support the above constructs. | 249 | regular expressions, and these cannot support the above constructs." |
| 247 | |||
| 248 | If this routine fails, it returns nil. Otherwise, it returns a list | ||
| 249 | the form: | ||
| 250 | |||
| 251 | (INCLUDE-REGEXP EXCLUDE-REGEXP (PRED-FUNC-LIST) (MOD-FUNC-LIST))" | ||
| 252 | (let ((paths (eshell-split-path glob)) | 250 | (let ((paths (eshell-split-path glob)) |
| 253 | eshell-glob-matches message-shown) | 251 | eshell-glob-matches message-shown) |
| 254 | (unwind-protect | 252 | (unwind-protect |
| @@ -287,7 +285,7 @@ the form: | |||
| 287 | glob (car globs) | 285 | glob (car globs) |
| 288 | len (length glob))))) | 286 | len (length glob))))) |
| 289 | (if (and recurse-p (not glob)) | 287 | (if (and recurse-p (not glob)) |
| 290 | (error "`**' cannot end a globbing pattern")) | 288 | (error "`**/' cannot end a globbing pattern")) |
| 291 | (let ((index 1)) | 289 | (let ((index 1)) |
| 292 | (setq incl glob) | 290 | (setq incl glob) |
| 293 | (while (and (eq incl glob) | 291 | (while (and (eq incl glob) |