changeset 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 3f07e8295d4a
children b278cb498cc8
files lisp/eshell/em-glob.el
diffstat 1 files changed, 7 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/eshell/em-glob.el	Sat May 08 01:08:37 2004 +0000
+++ b/lisp/eshell/em-glob.el	Sat May 08 12:39:01 2004 +0000
@@ -122,10 +122,6 @@
   :type '(repeat (cons character (choice regexp function)))
   :group 'eshell-glob)
 
-;;; Internal Variables:
-
-(defvar eshell-glob-chars-regexp nil)
-
 ;;; Functions:
 
 (defun eshell-glob-initialize ()
@@ -134,8 +130,6 @@
   (when (boundp 'eshell-special-chars-outside-quoting)
     (set (make-local-variable 'eshell-special-chars-outside-quoting)
 	 (append eshell-glob-chars-list eshell-special-chars-outside-quoting)))
-  (set (make-local-variable 'eshell-glob-chars-regexp)
-       (format "[%s]+" (apply 'string eshell-glob-chars-list)))
   (add-hook 'eshell-parse-argument-hook 'eshell-parse-glob-chars t t)
   (add-hook 'eshell-pre-rewrite-command-hook
 	    'eshell-no-command-globbing nil t))
@@ -184,6 +178,8 @@
 		  (buffer-substring-no-properties (1- (point)) (1+ end))
 		(goto-char (1+ end))))))))))
 
+(defvar eshell-glob-chars-regexp nil)
+
 (defun eshell-glob-regexp (pattern)
   "Convert glob-pattern PATTERN to a regular expression.
 The basic syntax is:
@@ -204,8 +200,11 @@
 resulting regular expression."
   (let ((matched-in-pattern 0)          ; How much of PATTERN handled
 	regexp)
-    (while (string-match eshell-glob-chars-regexp
-			 pattern matched-in-pattern)
+    (while (string-match
+	    (or eshell-glob-chars-regexp
+		(set (make-local-variable 'eshell-glob-chars-regexp)
+		     (format "[%s]+" (apply 'string eshell-glob-chars-list))))
+	    pattern matched-in-pattern)
       (let* ((op-begin (match-beginning 0))
 	     (op-char (aref pattern op-begin)))
 	(setq regexp