# HG changeset patch # User Augie Fackler # Date 1230675092 21600 # Node ID 260deb14fbc8a9d356d3be1e48d6ce758d545a93 # Parent 614a83a1c5dd7034114b57a38c68d1bfabd2967a Add textmate-find-in-project. diff --git a/.elisp/textmate.el b/.elisp/textmate.el --- 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) diff --git a/.emacs b/.emacs --- 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)