21 |
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
22 |
;; Boston, MA 02111-1307, USA. |
;; Boston, MA 02111-1307, USA. |
23 |
|
|
24 |
|
;;; Code: |
25 |
|
|
26 |
(provide 'em-glob) |
(provide 'em-glob) |
27 |
|
|
28 |
(eval-when-compile (require 'esh-maint)) |
(eval-when-compile (require 'esh-maint)) |
29 |
|
(require 'esh-util) |
30 |
|
|
31 |
(defgroup eshell-glob nil |
(defgroup eshell-glob nil |
32 |
"This module provides extended globbing syntax, similar what is used |
"This module provides extended globbing syntax, similar what is used |
131 |
(defun eshell-glob-initialize () |
(defun eshell-glob-initialize () |
132 |
"Initialize the extended globbing code." |
"Initialize the extended globbing code." |
133 |
;; it's important that `eshell-glob-chars-list' come first |
;; it's important that `eshell-glob-chars-list' come first |
134 |
(set (make-local-variable 'eshell-special-chars-outside-quoting) |
(when (boundp 'eshell-special-chars-outside-quoting) |
135 |
(append eshell-glob-chars-list eshell-special-chars-outside-quoting)) |
(set (make-local-variable 'eshell-special-chars-outside-quoting) |
136 |
|
(append eshell-glob-chars-list eshell-special-chars-outside-quoting))) |
137 |
(set (make-local-variable 'eshell-glob-chars-regexp) |
(set (make-local-variable 'eshell-glob-chars-regexp) |
138 |
(format "[%s]+" (apply 'string eshell-glob-chars-list))) |
(format "[%s]+" (apply 'string eshell-glob-chars-list))) |
139 |
(add-hook 'eshell-parse-argument-hook 'eshell-parse-glob-chars t t) |
(add-hook 'eshell-parse-argument-hook 'eshell-parse-glob-chars t t) |
232 |
|
|
233 |
(defun eshell-extended-glob (glob) |
(defun eshell-extended-glob (glob) |
234 |
"Return a list of files generated from GLOB, perhaps looking for DIRS-ONLY. |
"Return a list of files generated from GLOB, perhaps looking for DIRS-ONLY. |
235 |
This function almost fully supports zsh style filename generation |
This function almost fully supports zsh style filename generation |
236 |
syntax. Things that are not supported are: |
syntax. Things that are not supported are: |
237 |
|
|
238 |
^foo for matching everything but foo |
^foo for matching everything but foo |
239 |
(foo~bar) tilde within a parenthesis group |
(foo~bar) tilde within a parenthesis group |
240 |
foo<1-10> numeric ranges |
foo<1-10> numeric ranges |
241 |
foo~x(a|b) (a|b) will be interpreted as a predicate/modifier list |
foo~x(a|b) (a|b) will be interpreted as a predicate/modifier list |
242 |
|
|
243 |
Mainly they are not supported because file matching is done with Emacs |
Mainly they are not supported because file matching is done with Emacs |
244 |
regular expressions, and these cannot support the above constructs. |
regular expressions, and these cannot support the above constructs. |
245 |
|
|
246 |
If this routine fails, it returns nil. Otherwise, it returns a list |
If this routine fails, it returns nil. Otherwise, it returns a list |
247 |
the form: |
the form: |
248 |
|
|
249 |
(INCLUDE-REGEXP EXCLUDE-REGEXP (PRED-FUNC-LIST) (MOD-FUNC-LIST))" |
(INCLUDE-REGEXP EXCLUDE-REGEXP (PRED-FUNC-LIST) (MOD-FUNC-LIST))" |
250 |
(let ((paths (eshell-split-path glob)) |
(let ((paths (eshell-split-path glob)) |
357 |
(eshell-glob-entries (car rdirs) globs recurse-p) |
(eshell-glob-entries (car rdirs) globs recurse-p) |
358 |
(setq rdirs (cdr rdirs))))) |
(setq rdirs (cdr rdirs))))) |
359 |
|
|
|
;;; Code: |
|
|
|
|
360 |
;;; em-glob.el ends here |
;;; em-glob.el ends here |