Mercurial > dotfiles
comparison .elisp/textmate.el @ 28:260deb14fbc8
Add textmate-find-in-project.
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Tue, 30 Dec 2008 16:11:32 -0600 |
parents | c7ff220bba9f |
children | e5f414619ea7 |
comparison
equal
deleted
inserted
replaced
27:614a83a1c5dd | 28:260deb14fbc8 |
---|---|
103 (member ".hg" coll) | 103 (member ".hg" coll) |
104 )) | 104 )) |
105 "*Lambda that, given a collection of directory entries, returns | 105 "*Lambda that, given a collection of directory entries, returns |
106 non-nil if it represents the project root.") | 106 non-nil if it represents the project root.") |
107 | 107 |
108 (defvar *textmate-find-in-project-default* nil) | |
109 (defvar *textmate-find-in-project-type-default* nil) | |
110 | |
108 ;;; Bindings | 111 ;;; Bindings |
109 | 112 |
110 (defun textmate-ido-fix () | 113 (defun textmate-ido-fix () |
111 "Add up/down keybindings for ido." | 114 "Add up/down keybindings for ido." |
112 (define-key ido-completion-map [up] 'ido-prev-match) | 115 (define-key ido-completion-map [up] 'ido-prev-match) |
179 (concat | 182 (concat |
180 (expand-file-name root) "/" | 183 (expand-file-name root) "/" |
181 (textmate-completing-read | 184 (textmate-completing-read |
182 "Find file: " | 185 "Find file: " |
183 (textmate-cached-project-files root)))))) | 186 (textmate-cached-project-files root)))))) |
187 | |
188 (defun textmate-find-in-project-type () | |
189 (interactive) | |
190 (let ((pat (read-string (concat "Suffix" | |
191 (if *textmate-find-in-project-type-default* | |
192 (format " [\"%s\"]" *textmate-find-in-project-type-default*) | |
193 "") | |
194 ": " | |
195 ) nil nil *textmate-find-in-project-type-default*))) | |
196 (setq *textmate-find-in-project-type-default* pat) | |
197 (textmate-find-in-project (concat "*." pat)))) | |
198 | |
199 (defun textmate-find-in-project (&optional pattern) | |
200 (interactive) | |
201 (let ((root (textmate-project-root)) | |
202 (default *textmate-find-in-project-default*) | |
203 ) | |
204 (when (null root) | |
205 (error "Not in a project area.")) | |
206 (let ((re (read-string (concat "Search for " | |
207 (if (and default (> (length default) 0)) | |
208 (format "[\"%s\"]" default)) ": ") | |
209 nil 'textmate-find-in-project-history default) | |
210 ) | |
211 (incpat (if pattern pattern "*"))) | |
212 (append textmate-find-in-project-history (list re)) | |
213 (setq *textmate-find-in-project-default* re) | |
214 (compilation-start (concat "cd " root "; egrep -nR --exclude='" | |
215 *textmate-gf-exclude* | |
216 "' --include='" | |
217 incpat | |
218 "' '" | |
219 re | |
220 "' . | grep -vE '" | |
221 *textmate-gf-exclude* | |
222 "' | sed s:./::" | |
223 ) | |
224 'grep-mode | |
225 ) | |
226 ) | |
227 )) | |
228 | |
184 | 229 |
185 (defun textmate-clear-cache () | 230 (defun textmate-clear-cache () |
186 (interactive) | 231 (interactive) |
187 (setq *textmate-project-root* nil) | 232 (setq *textmate-project-root* nil) |
188 (setq *textmate-project-files* nil) | 233 (setq *textmate-project-files* nil) |