Mercurial > emacs
comparison lisp/eshell/em-glob.el @ 55430:8a3af63fa397
2004-05-08 John Wiegley <johnw@newartisans.com>
* eshell/em-glob.el (eshell-glob-initialize): Move initialization
of `eshell-glob-chars-regexp' into `eshell-glob-regexp', so that
function can be used outside of eshell buffers.
(eshell-glob-regexp): Initialize `eshell-glob-chars-regexp' here.
author | John Wiegley <johnw@newartisans.com> |
---|---|
date | Sat, 08 May 2004 12:39:01 +0000 |
parents | 695cf19ef79e |
children | b89e30bcd2bb 4c90ffeb71c5 |
comparison
equal
deleted
inserted
replaced
55429:3f07e8295d4a | 55430:8a3af63fa397 |
---|---|
120 (cons "*" (1+ pos)))))) | 120 (cons "*" (1+ pos)))))) |
121 "*An alist for translation of extended globbing characters." | 121 "*An alist for translation of extended globbing characters." |
122 :type '(repeat (cons character (choice regexp function))) | 122 :type '(repeat (cons character (choice regexp function))) |
123 :group 'eshell-glob) | 123 :group 'eshell-glob) |
124 | 124 |
125 ;;; Internal Variables: | |
126 | |
127 (defvar eshell-glob-chars-regexp nil) | |
128 | |
129 ;;; Functions: | 125 ;;; Functions: |
130 | 126 |
131 (defun eshell-glob-initialize () | 127 (defun eshell-glob-initialize () |
132 "Initialize the extended globbing code." | 128 "Initialize the extended globbing code." |
133 ;; it's important that `eshell-glob-chars-list' come first | 129 ;; it's important that `eshell-glob-chars-list' come first |
134 (when (boundp 'eshell-special-chars-outside-quoting) | 130 (when (boundp 'eshell-special-chars-outside-quoting) |
135 (set (make-local-variable 'eshell-special-chars-outside-quoting) | 131 (set (make-local-variable 'eshell-special-chars-outside-quoting) |
136 (append eshell-glob-chars-list eshell-special-chars-outside-quoting))) | 132 (append eshell-glob-chars-list eshell-special-chars-outside-quoting))) |
137 (set (make-local-variable 'eshell-glob-chars-regexp) | |
138 (format "[%s]+" (apply 'string eshell-glob-chars-list))) | |
139 (add-hook 'eshell-parse-argument-hook 'eshell-parse-glob-chars t t) | 133 (add-hook 'eshell-parse-argument-hook 'eshell-parse-glob-chars t t) |
140 (add-hook 'eshell-pre-rewrite-command-hook | 134 (add-hook 'eshell-pre-rewrite-command-hook |
141 'eshell-no-command-globbing nil t)) | 135 'eshell-no-command-globbing nil t)) |
142 | 136 |
143 (defun eshell-no-command-globbing (terms) | 137 (defun eshell-no-command-globbing (terms) |
182 (eshell-add-glob-modifier) | 176 (eshell-add-glob-modifier) |
183 (prog1 | 177 (prog1 |
184 (buffer-substring-no-properties (1- (point)) (1+ end)) | 178 (buffer-substring-no-properties (1- (point)) (1+ end)) |
185 (goto-char (1+ end)))))))))) | 179 (goto-char (1+ end)))))))))) |
186 | 180 |
181 (defvar eshell-glob-chars-regexp nil) | |
182 | |
187 (defun eshell-glob-regexp (pattern) | 183 (defun eshell-glob-regexp (pattern) |
188 "Convert glob-pattern PATTERN to a regular expression. | 184 "Convert glob-pattern PATTERN to a regular expression. |
189 The basic syntax is: | 185 The basic syntax is: |
190 | 186 |
191 glob regexp meaning | 187 glob regexp meaning |
202 If any characters in PATTERN have the text property `eshell-escaped' | 198 If any characters in PATTERN have the text property `eshell-escaped' |
203 set to true, then these characters will match themselves in the | 199 set to true, then these characters will match themselves in the |
204 resulting regular expression." | 200 resulting regular expression." |
205 (let ((matched-in-pattern 0) ; How much of PATTERN handled | 201 (let ((matched-in-pattern 0) ; How much of PATTERN handled |
206 regexp) | 202 regexp) |
207 (while (string-match eshell-glob-chars-regexp | 203 (while (string-match |
208 pattern matched-in-pattern) | 204 (or eshell-glob-chars-regexp |
205 (set (make-local-variable 'eshell-glob-chars-regexp) | |
206 (format "[%s]+" (apply 'string eshell-glob-chars-list)))) | |
207 pattern matched-in-pattern) | |
209 (let* ((op-begin (match-beginning 0)) | 208 (let* ((op-begin (match-beginning 0)) |
210 (op-char (aref pattern op-begin))) | 209 (op-char (aref pattern op-begin))) |
211 (setq regexp | 210 (setq regexp |
212 (concat regexp | 211 (concat regexp |
213 (regexp-quote | 212 (regexp-quote |