Mercurial > emacs
annotate lisp/eshell/em-glob.el @ 112404:2b0d6f7bbb80
Merge: src/config.in: shrink slightly
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Fri, 21 Jan 2011 16:13:42 -0800 |
parents | 417b1e4d63cd |
children |
rev | line source |
---|---|
38414
67b464da13ec
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
33020
diff
changeset
|
1 ;;; em-glob.el --- extended file name globbing |
29876 | 2 |
95152
ad5d26b1d5d1
Use eshell-defgroup rather than defgroup.
Glenn Morris <rgm@gnu.org>
parents:
94661
diff
changeset
|
3 ;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, |
112218
376148b31b5e
Add 2011 to FSF/AIST copyright years.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
4 ;; 2008, 2009, 2010, 2011 Free Software Foundation, Inc. |
29876 | 5 |
32526 | 6 ;; Author: John Wiegley <johnw@gnu.org> |
7 | |
29876 | 8 ;; This file is part of GNU Emacs. |
9 | |
94661
b5b0801a7637
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
10 ;; GNU Emacs is free software: you can redistribute it and/or modify |
29876 | 11 ;; it under the terms of the GNU General Public License as published by |
94661
b5b0801a7637
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
12 ;; the Free Software Foundation, either version 3 of the License, or |
b5b0801a7637
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
13 ;; (at your option) any later version. |
29876 | 14 |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
94661
b5b0801a7637
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
29876 | 22 |
23 ;;; Commentary: | |
24 | |
25 ;; The globbing code used by Eshell closely follows the syntax used by | |
26 ;; zsh. Basically, here is a summary of examples: | |
27 ;; | |
28 ;; echo a* ; anything starting with 'a' | |
29 ;; echo a#b ; zero or more 'a's, then 'b' | |
30 ;; echo a##b ; one or more 'a's, then 'b' | |
31 ;; echo a? ; a followed by any character | |
32 ;; echo a*~ab ; 'a', then anything, but not 'ab' | |
33 ;; echo c*~*~ ; all files beginning with 'c', except backups (*~) | |
34 ;; | |
35 ;; Recursive globbing is also supported: | |
36 ;; | |
37 ;; echo **/*.c ; all '.c' files at or under current directory | |
38 ;; echo ***/*.c ; same as above, but traverse symbolic links | |
39 ;; | |
40 ;; Using argument predication, the recursive globbing syntax is | |
41 ;; sufficient to replace the use of 'find <expr> | xargs <cmd>' in | |
42 ;; most cases. For example, to change the readership of all files | |
43 ;; belonging to 'johnw' in the '/tmp' directory or lower, use: | |
44 ;; | |
45 ;; chmod go-r /tmp/**/*(u'johnw') | |
46 ;; | |
47 ;; The glob above matches all of the files beneath '/tmp' that are | |
48 ;; owned by the user 'johnw'. See [Value modifiers and predicates], | |
49 ;; for more information about argument predication. | |
50 | |
87067
19c1fcdf634c
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
85955
diff
changeset
|
51 ;;; Code: |
19c1fcdf634c
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
85955
diff
changeset
|
52 |
19c1fcdf634c
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
85955
diff
changeset
|
53 (eval-when-compile (require 'eshell)) |
19c1fcdf634c
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
85955
diff
changeset
|
54 (require 'esh-util) |
19c1fcdf634c
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
85955
diff
changeset
|
55 |
95152
ad5d26b1d5d1
Use eshell-defgroup rather than defgroup.
Glenn Morris <rgm@gnu.org>
parents:
94661
diff
changeset
|
56 ;;;###autoload |
ad5d26b1d5d1
Use eshell-defgroup rather than defgroup.
Glenn Morris <rgm@gnu.org>
parents:
94661
diff
changeset
|
57 (eshell-defgroup eshell-glob nil |
87067
19c1fcdf634c
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
85955
diff
changeset
|
58 "This module provides extended globbing syntax, similar what is used |
19c1fcdf634c
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
85955
diff
changeset
|
59 by zsh for filename generation." |
19c1fcdf634c
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
85955
diff
changeset
|
60 :tag "Extended filename globbing" |
19c1fcdf634c
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
85955
diff
changeset
|
61 :group 'eshell-module) |
19c1fcdf634c
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
85955
diff
changeset
|
62 |
29876 | 63 ;;; User Variables: |
64 | |
65 (defcustom eshell-glob-load-hook '(eshell-glob-initialize) | |
110580
f57f72bb4757
Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
66 "A list of functions to run when `eshell-glob' is loaded." |
29876 | 67 :type 'hook |
68 :group 'eshell-glob) | |
69 | |
70 (defcustom eshell-glob-include-dot-files nil | |
110580
f57f72bb4757
Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
71 "If non-nil, glob patterns will match files beginning with a dot." |
29876 | 72 :type 'boolean |
73 :group 'eshell-glob) | |
74 | |
75 (defcustom eshell-glob-include-dot-dot t | |
110580
f57f72bb4757
Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
76 "If non-nil, glob patterns that match dots will match . and .." |
29876 | 77 :type 'boolean |
78 :group 'eshell-glob) | |
79 | |
46852
6eb625bead4f
Removed eshell-under-cygwin-p, and all uses of it.
John Wiegley <johnw@newartisans.com>
parents:
46820
diff
changeset
|
80 (defcustom eshell-glob-case-insensitive (eshell-under-windows-p) |
110580
f57f72bb4757
Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
81 "If non-nil, glob pattern matching will ignore case." |
29876 | 82 :type 'boolean |
83 :group 'eshell-glob) | |
84 | |
33020 | 85 (defcustom eshell-glob-show-progress nil |
110580
f57f72bb4757
Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
86 "If non-nil, display progress messages during a recursive glob. |
33020 | 87 This option slows down recursive glob processing by quite a bit." |
29876 | 88 :type 'boolean |
89 :group 'eshell-glob) | |
90 | |
91 (defcustom eshell-error-if-no-glob nil | |
110580
f57f72bb4757
Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
92 "If non-nil, it is an error for a glob pattern not to match. |
29876 | 93 This mimcs the behavior of zsh if non-nil, but bash if nil." |
94 :type 'boolean | |
95 :group 'eshell-glob) | |
96 | |
72346
adbd3421e276
(eshell-glob-chars-list) (eshell-glob-translate-alist): Add support
John Wiegley <johnw@newartisans.com>
parents:
68648
diff
changeset
|
97 (defcustom eshell-glob-chars-list '(?\] ?\[ ?* ?? ?~ ?\( ?\) ?| ?# ?^) |
110580
f57f72bb4757
Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
98 "List of additional characters used in extended globbing." |
29876 | 99 :type '(repeat character) |
100 :group 'eshell-glob) | |
101 | |
102 (defcustom eshell-glob-translate-alist | |
103 '((?\] . "]") | |
104 (?\[ . "[") | |
72346
adbd3421e276
(eshell-glob-chars-list) (eshell-glob-translate-alist): Add support
John Wiegley <johnw@newartisans.com>
parents:
68648
diff
changeset
|
105 (?^ . "^") |
29876 | 106 (?? . ".") |
107 (?* . ".*") | |
108 (?~ . "~") | |
109 (?\( . "\\(") | |
110 (?\) . "\\)") | |
111 (?\| . "\\|") | |
112 (?# . (lambda (str pos) | |
113 (if (and (< (1+ pos) (length str)) | |
114 (memq (aref str (1+ pos)) '(?* ?# ?+ ??))) | |
115 (cons (if (eq (aref str (1+ pos)) ??) | |
116 "?" | |
117 (if (eq (aref str (1+ pos)) ?*) | |
118 "*" "+")) (+ pos 2)) | |
119 (cons "*" (1+ pos)))))) | |
110580
f57f72bb4757
Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
120 "An alist for translation of extended globbing characters." |
29876 | 121 :type '(repeat (cons character (choice regexp function))) |
122 :group 'eshell-glob) | |
123 | |
124 ;;; Functions: | |
125 | |
126 (defun eshell-glob-initialize () | |
127 "Initialize the extended globbing code." | |
128 ;; it's important that `eshell-glob-chars-list' come first | |
48210
eeded772a8a2
Require esh-util.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46852
diff
changeset
|
129 (when (boundp 'eshell-special-chars-outside-quoting) |
eeded772a8a2
Require esh-util.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46852
diff
changeset
|
130 (set (make-local-variable 'eshell-special-chars-outside-quoting) |
eeded772a8a2
Require esh-util.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46852
diff
changeset
|
131 (append eshell-glob-chars-list eshell-special-chars-outside-quoting))) |
29876 | 132 (add-hook 'eshell-parse-argument-hook 'eshell-parse-glob-chars t t) |
133 (add-hook 'eshell-pre-rewrite-command-hook | |
134 'eshell-no-command-globbing nil t)) | |
135 | |
136 (defun eshell-no-command-globbing (terms) | |
137 "Don't glob the command argument. Reflect this by modifying TERMS." | |
138 (ignore | |
139 (when (and (listp (car terms)) | |
140 (eq (caar terms) 'eshell-extended-glob)) | |
141 (setcar terms (cadr (car terms)))))) | |
142 | |
143 (defun eshell-add-glob-modifier () | |
144 "Add `eshell-extended-glob' to the argument modifier list." | |
145 (when (memq 'expand-file-name eshell-current-modifiers) | |
146 (setq eshell-current-modifiers | |
147 (delq 'expand-file-name eshell-current-modifiers)) | |
148 ;; if this is a glob pattern than needs to be expanded, then it | |
149 ;; will need to expand each member of the resulting glob list | |
150 (add-to-list 'eshell-current-modifiers | |
151 '(lambda (list) | |
152 (if (listp list) | |
153 (mapcar 'expand-file-name list) | |
154 (expand-file-name list))))) | |
155 (add-to-list 'eshell-current-modifiers 'eshell-extended-glob)) | |
156 | |
157 (defun eshell-parse-glob-chars () | |
158 "Parse a globbing delimiter. | |
159 The character is not advanced for ordinary globbing characters, so | |
160 that other function may have a chance to override the globbing | |
161 interpretation." | |
162 (when (memq (char-after) eshell-glob-chars-list) | |
163 (if (not (memq (char-after) '(?\( ?\[))) | |
164 (ignore (eshell-add-glob-modifier)) | |
165 (let ((here (point))) | |
166 (forward-char) | |
167 (let* ((delim (char-before)) | |
168 (end (eshell-find-delimiter | |
169 delim (if (eq delim ?\[) ?\] ?\))))) | |
170 (if (not end) | |
171 (throw 'eshell-incomplete delim) | |
172 (if (and (eshell-using-module 'eshell-pred) | |
173 (eshell-arg-delimiter (1+ end))) | |
174 (ignore (goto-char here)) | |
175 (eshell-add-glob-modifier) | |
176 (prog1 | |
177 (buffer-substring-no-properties (1- (point)) (1+ end)) | |
178 (goto-char (1+ end)))))))))) | |
179 | |
55430
8a3af63fa397
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
52401
diff
changeset
|
180 (defvar eshell-glob-chars-regexp nil) |
8a3af63fa397
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
52401
diff
changeset
|
181 |
29876 | 182 (defun eshell-glob-regexp (pattern) |
183 "Convert glob-pattern PATTERN to a regular expression. | |
184 The basic syntax is: | |
185 | |
186 glob regexp meaning | |
187 ---- ------ ------- | |
188 ? . matches any single character | |
189 * .* matches any group of characters (or none) | |
190 # * matches zero or more occurrences of preceding | |
191 ## + matches one or more occurrences of preceding | |
192 (x) \(x\) makes 'x' a regular expression group | |
193 | \| boolean OR within an expression group | |
194 [a-b] [a-b] matches a character or range | |
195 [^a] [^a] excludes a character or range | |
196 | |
197 If any characters in PATTERN have the text property `eshell-escaped' | |
198 set to true, then these characters will match themselves in the | |
199 resulting regular expression." | |
200 (let ((matched-in-pattern 0) ; How much of PATTERN handled | |
201 regexp) | |
55430
8a3af63fa397
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
52401
diff
changeset
|
202 (while (string-match |
8a3af63fa397
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
52401
diff
changeset
|
203 (or eshell-glob-chars-regexp |
8a3af63fa397
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
52401
diff
changeset
|
204 (set (make-local-variable 'eshell-glob-chars-regexp) |
8a3af63fa397
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
52401
diff
changeset
|
205 (format "[%s]+" (apply 'string eshell-glob-chars-list)))) |
8a3af63fa397
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
52401
diff
changeset
|
206 pattern matched-in-pattern) |
29876 | 207 (let* ((op-begin (match-beginning 0)) |
208 (op-char (aref pattern op-begin))) | |
209 (setq regexp | |
210 (concat regexp | |
211 (regexp-quote | |
212 (substring pattern matched-in-pattern op-begin)))) | |
213 (if (get-text-property op-begin 'escaped pattern) | |
214 (setq regexp (concat regexp | |
215 (regexp-quote (char-to-string op-char))) | |
216 matched-in-pattern (1+ op-begin)) | |
217 (let ((xlat (assq op-char eshell-glob-translate-alist))) | |
218 (if (not xlat) | |
219 (error "Unrecognized globbing character '%c'" op-char) | |
220 (if (stringp (cdr xlat)) | |
221 (setq regexp (concat regexp (cdr xlat)) | |
222 matched-in-pattern (1+ op-begin)) | |
223 (let ((result (funcall (cdr xlat) pattern op-begin))) | |
224 (setq regexp (concat regexp (car result)) | |
225 matched-in-pattern (cdr result))))))))) | |
226 (concat "\\`" | |
227 regexp | |
228 (regexp-quote (substring pattern matched-in-pattern)) | |
229 "\\'"))) | |
230 | |
231 (defun eshell-extended-glob (glob) | |
232 "Return a list of files generated from GLOB, perhaps looking for DIRS-ONLY. | |
48210
eeded772a8a2
Require esh-util.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46852
diff
changeset
|
233 This function almost fully supports zsh style filename generation |
eeded772a8a2
Require esh-util.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46852
diff
changeset
|
234 syntax. Things that are not supported are: |
29876 | 235 |
236 ^foo for matching everything but foo | |
237 (foo~bar) tilde within a parenthesis group | |
238 foo<1-10> numeric ranges | |
239 foo~x(a|b) (a|b) will be interpreted as a predicate/modifier list | |
240 | |
48210
eeded772a8a2
Require esh-util.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46852
diff
changeset
|
241 Mainly they are not supported because file matching is done with Emacs |
eeded772a8a2
Require esh-util.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46852
diff
changeset
|
242 regular expressions, and these cannot support the above constructs. |
29876 | 243 |
48210
eeded772a8a2
Require esh-util.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46852
diff
changeset
|
244 If this routine fails, it returns nil. Otherwise, it returns a list |
eeded772a8a2
Require esh-util.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46852
diff
changeset
|
245 the form: |
29876 | 246 |
247 (INCLUDE-REGEXP EXCLUDE-REGEXP (PRED-FUNC-LIST) (MOD-FUNC-LIST))" | |
248 (let ((paths (eshell-split-path glob)) | |
111455
f21190964294
Silence compilation of some shell files.
Glenn Morris <rgm@gnu.org>
parents:
110580
diff
changeset
|
249 eshell-glob-matches message-shown ange-cache) |
29876 | 250 (unwind-protect |
251 (if (and (cdr paths) | |
252 (file-name-absolute-p (car paths))) | |
253 (eshell-glob-entries (file-name-as-directory (car paths)) | |
254 (cdr paths)) | |
66601
2f18208cd84b
*** empty log message ***
John Wiegley <johnw@newartisans.com>
parents:
66588
diff
changeset
|
255 (eshell-glob-entries (file-name-as-directory ".") paths)) |
29876 | 256 (if message-shown |
257 (message nil))) | |
111455
f21190964294
Silence compilation of some shell files.
Glenn Morris <rgm@gnu.org>
parents:
110580
diff
changeset
|
258 (or (and eshell-glob-matches (sort eshell-glob-matches #'string<)) |
29876 | 259 (if eshell-error-if-no-glob |
260 (error "No matches found: %s" glob) | |
261 glob)))) | |
262 | |
111455
f21190964294
Silence compilation of some shell files.
Glenn Morris <rgm@gnu.org>
parents:
110580
diff
changeset
|
263 (defvar eshell-glob-matches) |
95619
45dbb3c749a6
Remove unnecessary eval-when-compiles and eval-and-compiles.
Glenn Morris <rgm@gnu.org>
parents:
95152
diff
changeset
|
264 (defvar message-shown) |
29876 | 265 |
111455
f21190964294
Silence compilation of some shell files.
Glenn Morris <rgm@gnu.org>
parents:
110580
diff
changeset
|
266 ;; FIXME does this really need to abuse eshell-glob-matches, message-shown? |
29876 | 267 (defun eshell-glob-entries (path globs &optional recurse-p) |
268 "Glob the entries in PATHS, possibly recursing if RECURSE-P is non-nil." | |
269 (let* ((entries (ignore-errors | |
270 (file-name-all-completions "" path))) | |
271 (case-fold-search eshell-glob-case-insensitive) | |
272 (glob (car globs)) | |
273 (len (length glob)) | |
274 dirs rdirs | |
275 incl excl | |
276 name isdir pathname) | |
277 (while (cond | |
278 ((and (= len 3) (equal glob "**/")) | |
279 (setq recurse-p 2 | |
280 globs (cdr globs) | |
281 glob (car globs) | |
282 len (length glob))) | |
283 ((and (= len 4) (equal glob "***/")) | |
284 (setq recurse-p 3 | |
285 globs (cdr globs) | |
286 glob (car globs) | |
287 len (length glob))))) | |
288 (if (and recurse-p (not glob)) | |
289 (error "'**' cannot end a globbing pattern")) | |
290 (let ((index 1)) | |
291 (setq incl glob) | |
292 (while (and (eq incl glob) | |
293 (setq index (string-match "~" glob index))) | |
294 (if (or (get-text-property index 'escaped glob) | |
295 (or (= (1+ index) len))) | |
296 (setq index (1+ index)) | |
297 (setq incl (substring glob 0 index) | |
298 excl (substring glob (1+ index)))))) | |
299 ;; can't use `directory-file-name' because it strips away text | |
300 ;; properties in the string | |
301 (let ((len (1- (length incl)))) | |
62915
b89e30bcd2bb
Changed all uses of `directory-sep-char' to ?/, and all uses of
John Wiegley <johnw@newartisans.com>
parents:
55430
diff
changeset
|
302 (if (eq (aref incl len) ?/) |
29876 | 303 (setq incl (substring incl 0 len))) |
304 (when excl | |
305 (setq len (1- (length excl))) | |
62915
b89e30bcd2bb
Changed all uses of `directory-sep-char' to ?/, and all uses of
John Wiegley <johnw@newartisans.com>
parents:
55430
diff
changeset
|
306 (if (eq (aref excl len) ?/) |
29876 | 307 (setq excl (substring excl 0 len))))) |
308 (setq incl (eshell-glob-regexp incl) | |
309 excl (and excl (eshell-glob-regexp excl))) | |
310 (if (or eshell-glob-include-dot-files | |
311 (eq (aref glob 0) ?.)) | |
312 (unless (or eshell-glob-include-dot-dot | |
313 (cdr globs)) | |
314 (setq excl (if excl | |
315 (concat "\\(\\`\\.\\.?\\'\\|" excl "\\)") | |
316 "\\`\\.\\.?\\'"))) | |
317 (setq excl (if excl | |
318 (concat "\\(\\`\\.\\|" excl "\\)") | |
319 "\\`\\."))) | |
320 (when (and recurse-p eshell-glob-show-progress) | |
321 (message "Building file list...%d so far: %s" | |
111455
f21190964294
Silence compilation of some shell files.
Glenn Morris <rgm@gnu.org>
parents:
110580
diff
changeset
|
322 (length eshell-glob-matches) path) |
29876 | 323 (setq message-shown t)) |
324 (if (equal path "./") (setq path "")) | |
325 (while entries | |
326 (setq name (car entries) | |
327 len (length name) | |
62915
b89e30bcd2bb
Changed all uses of `directory-sep-char' to ?/, and all uses of
John Wiegley <johnw@newartisans.com>
parents:
55430
diff
changeset
|
328 isdir (eq (aref name (1- len)) ?/)) |
29876 | 329 (if (let ((fname (directory-file-name name))) |
330 (and (not (and excl (string-match excl fname))) | |
331 (string-match incl fname))) | |
332 (if (cdr globs) | |
333 (if isdir | |
334 (setq dirs (cons (concat path name) dirs))) | |
111455
f21190964294
Silence compilation of some shell files.
Glenn Morris <rgm@gnu.org>
parents:
110580
diff
changeset
|
335 (setq eshell-glob-matches |
f21190964294
Silence compilation of some shell files.
Glenn Morris <rgm@gnu.org>
parents:
110580
diff
changeset
|
336 (cons (concat path name) eshell-glob-matches)))) |
29876 | 337 (if (and recurse-p isdir |
338 (or (> len 3) | |
339 (not (or (and (= len 2) (equal name "./")) | |
340 (and (= len 3) (equal name "../"))))) | |
341 (setq pathname (concat path name)) | |
342 (not (and (= recurse-p 2) | |
343 (file-symlink-p | |
344 (directory-file-name pathname))))) | |
345 (setq rdirs (cons pathname rdirs))) | |
346 (setq entries (cdr entries))) | |
347 (setq dirs (nreverse dirs) | |
348 rdirs (nreverse rdirs)) | |
349 (while dirs | |
350 (eshell-glob-entries (car dirs) (cdr globs)) | |
351 (setq dirs (cdr dirs))) | |
352 (while rdirs | |
353 (eshell-glob-entries (car rdirs) globs recurse-p) | |
354 (setq rdirs (cdr rdirs))))) | |
355 | |
87067
19c1fcdf634c
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
85955
diff
changeset
|
356 (provide 'em-glob) |
19c1fcdf634c
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
85955
diff
changeset
|
357 |
95152
ad5d26b1d5d1
Use eshell-defgroup rather than defgroup.
Glenn Morris <rgm@gnu.org>
parents:
94661
diff
changeset
|
358 ;; Local Variables: |
ad5d26b1d5d1
Use eshell-defgroup rather than defgroup.
Glenn Morris <rgm@gnu.org>
parents:
94661
diff
changeset
|
359 ;; generated-autoload-file: "esh-groups.el" |
ad5d26b1d5d1
Use eshell-defgroup rather than defgroup.
Glenn Morris <rgm@gnu.org>
parents:
94661
diff
changeset
|
360 ;; End: |
ad5d26b1d5d1
Use eshell-defgroup rather than defgroup.
Glenn Morris <rgm@gnu.org>
parents:
94661
diff
changeset
|
361 |
29876 | 362 ;;; em-glob.el ends here |