changeset 28:260deb14fbc8

Add textmate-find-in-project.
author Augie Fackler <durin42@gmail.com>
date Tue, 30 Dec 2008 16:11:32 -0600
parents 614a83a1c5dd
children e5f414619ea7
files .elisp/textmate.el .emacs
diffstat 2 files changed, 46 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/.elisp/textmate.el
+++ b/.elisp/textmate.el
@@ -105,6 +105,9 @@
   "*Lambda that, given a collection of directory entries, returns
   non-nil if it represents the project root.")
 
+(defvar *textmate-find-in-project-default* nil)
+(defvar *textmate-find-in-project-type-default* nil)
+
 ;;; Bindings
 
 (defun textmate-ido-fix ()
@@ -182,6 +185,48 @@
        "Find file: "
        (textmate-cached-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*)
+        )
+    (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)
+      (compilation-start (concat "cd " root "; egrep -nR --exclude='"
+                                               *textmate-gf-exclude*
+                                               "' --include='"
+                                               incpat
+                                               "' '"
+                                               re
+                                               "' . | grep -vE '"
+                                               *textmate-gf-exclude*
+                                               "' | sed s:./::"
+                                               )
+                         'grep-mode
+                                       )
+    )
+  ))
+
+
 (defun textmate-clear-cache ()
   (interactive)
   (setq *textmate-project-root* nil)
--- a/.emacs
+++ b/.emacs
@@ -116,3 +116,4 @@ point."
 (global-set-key "\C-h" 'backward-delete-char-untabify)
 ; M-t is what I want for the textmate file finding
 (global-set-key [(meta t)] 'textmate-goto-file)
+(global-set-key [(meta shift f)] 'textmate-find-in-project-type)