 (defun textmate-goto-file ()
   (interactive)
   (let ((root (textmate-project-root)))
-    (when (null root) 
+    (message "FOUND ROOT")
+    (when (null root)
       (error "Can't find any .git directory"))
-    (find-file 
-     (concat 
+    (find-file
+     (concat
       (expand-file-name root) "/"
-      (textmate-completing-read 
+      (textmate-completing-read
        "Find file: "
-       (textmate-cached-project-files root))))))
+       (textmate-project-files root))))))
+
+(defun textmate-find-in-project-type ()
+  (interactive)
+  (let ((pat (read-string (concat "Suffix"
+                                  (if *textmate-find-in-project-type-default*
+                                      (format " [\"%s\"]" *textmate-find-in-project-type-default*)
+                                    "")
+                                  ": "
+                                  ) nil nil *textmate-find-in-project-type-default*)))
+    (setq *textmate-find-in-project-type-default* pat)
+    (textmate-find-in-project (concat "*." pat))))
+
+(defun textmate-find-in-project (&optional pattern)
+  (interactive)
+  (let ((root (textmate-project-root))
+        (default *textmate-find-in-project-default*)
+        )
+    (message "textmate-find-in-project")
+    (when (null root)
+      (error "Not in a project area."))
+    (let ((re (read-string (concat "Search for "
+                         (if (and default (> (length default) 0))
+                             (format "[\"%s\"]" default)) ": ")
+                 nil 'textmate-find-in-project-history default)
+              )
+          (incpat (if pattern pattern "*")))
+      (append textmate-find-in-project-history (list re))
+      (setq *textmate-find-in-project-default* re)
+      (let ((type (textmate-project-root-type root)))
+        (let ((command
+            (cond ((not (string= type "unknown"))
+                   (concat "cd "
+                           root
+                           " ; "
+                           (cond ((string= type "git") "git ls-files")
+                                 ((string= type "hg") "hg manifest"))
+                           " | xargs grep -nR "
+                           (if pattern (concat " --include='" pattern "' ") "")
+                           "'" re "'"))
+                  (t (concat "cd " root "; egrep -nR --exclude='"
+                            *textmate-gf-exclude*
+                            "' --include='"
+                            incpat
+                            "' '"
+                            re
+                            "' . | grep -vE '"
+                            *textmate-gf-exclude*
+                            "' | sed s:./::"
+                            )))))
+                  (compilation-start command 'grep-mode))))))
 
 (defun textmate-clear-cache ()
   (interactive)

(defvar textmate-use-file-cache t
  "* Should `textmate-goto-file' keep a local cache of files?")

(defvar textmate-completing-library 'ido 
  "The library `textmade-goto-symbol' and `textmate-goto-file' should use for completing filenames and symbols (`ido' by default)")

(defvar *textmate-completing-function-alist* '((ido ido-completing-read) 
                                               (icicles  icicle-completing-read) 
                                               (none completing-read)) 
  "The function to call to read file names and symbols from the user")

(defvar *textmate-completing-minor-mode-alist* 
  `((ido ,(lambda (a) (progn (ido-mode a) (setq ido-enable-flex-matching t)))) 
    (icicles ,(lambda (a) (icy-mode a))) 
    (none ,(lambda (a) ())))
  "The list of functions to enable and disable completing minor modes")

(defvar *textmate-mode-map* (make-sparse-keymap))
(defvar *textmate-project-root* nil)
(defvar *textmate-project-files* '())
(defvar *textmate-gf-exclude* 
  "/\\.|vendor|fixtures|tmp|log|build|\\.xcodeproj|\\.nib|\\.framework|\\.app|\\.pbproj|\\.pbxproj|\\.xcode|\\.xcodeproj|\\.bundle")

(defvar *textmate-keybindings-list* `((textmate-next-line 
                                     [A-return]    [M-return])
                                     (textmate-clear-cache 
                                      ,(kbd "A-M-t") [(control c)(control t)])
                                     (align 
                                      ,(kbd "A-M-]") [(control c)(control a)])
                                     (indent-according-to-mode 
                                      ,(kbd "A-M-[") nil)
                                     (indent-region 
                                      ,(kbd "A-]")   [(control tab)])
                                     (comment-or-uncomment-region-or-line 
                                      ,(kbd "A-/")   [(control c)(control k)])
                                     (textmate-goto-file 
                                      ,(kbd "A-t")   [(meta t)])
                                     (textmate-goto-symbol 
                                      ,(kbd "A-T")   [(meta T)])))

;;; Bindings


                             (cond
                              ((and (listp symbol) (imenu--subalist-p symbol))
                               (addsymbols symbol))

                              ((listp symbol)
                               (setq name (car symbol))
                               (setq position (cdr symbol)))

                              ((stringp symbol)
                               (setq name symbol)
                               (setq position (get-text-property 1 'org-imenu-marker symbol))))

                             (unless (or (null position) (null name))
                               (add-to-list 'symbol-names name)
                               (add-to-list 'name-and-pos (cons name position))))))))
