comparison .elisp/textmate.el @ 29:e5f414619ea7

Latest version of textmate.el
author Augie Fackler <durin42@gmail.com>
date Thu, 01 Jan 2009 23:06:34 -0600
parents 260deb14fbc8
children 43e751bdedeb
comparison
equal deleted inserted replaced
28:260deb14fbc8 29:e5f414619ea7
25 ;; ⌘] - Shift Right (currently indents region) 25 ;; ⌘] - Shift Right (currently indents region)
26 ;; ⌘[ - Shift Left (not yet implemented) 26 ;; ⌘[ - Shift Left (not yet implemented)
27 ;; ⌥⌘] - Align Assignments 27 ;; ⌥⌘] - Align Assignments
28 ;; ⌥⌘[ - Indent Line 28 ;; ⌥⌘[ - Indent Line
29 ;; ⌘RET - Insert Newline at Line's End 29 ;; ⌘RET - Insert Newline at Line's End
30 ;; ⌥⌘T - Reset File Cache (for Go to File) 30 ;; ⌥⌘T - Reset File Cache (for Go to File, cache unused if using git/hg root)
31 31
32 ;; A "project" in textmate-mode is determined by the presence of 32 ;; A "project" in textmate-mode is determined by the presence of
33 ;; a .git directory. If no .git directory is found in your current 33 ;; a .git directory. If no .git directory is found in your current
34 ;; directory, textmate-mode will traverse upwards until one (or none) 34 ;; directory, textmate-mode will traverse upwards until one (or none)
35 ;; is found. The directory housing the .git directory is presumed 35 ;; is found. The directory housing the .git directory is presumed
181 (find-file 181 (find-file
182 (concat 182 (concat
183 (expand-file-name root) "/" 183 (expand-file-name root) "/"
184 (textmate-completing-read 184 (textmate-completing-read
185 "Find file: " 185 "Find file: "
186 (textmate-cached-project-files root)))))) 186 (textmate-project-files root))))))
187 187
188 (defun textmate-find-in-project-type () 188 (defun textmate-find-in-project-type ()
189 (interactive) 189 (interactive)
190 (let ((pat (read-string (concat "Suffix" 190 (let ((pat (read-string (concat "Suffix"
191 (if *textmate-find-in-project-type-default* 191 (if *textmate-find-in-project-type-default*
209 nil 'textmate-find-in-project-history default) 209 nil 'textmate-find-in-project-history default)
210 ) 210 )
211 (incpat (if pattern pattern "*"))) 211 (incpat (if pattern pattern "*")))
212 (append textmate-find-in-project-history (list re)) 212 (append textmate-find-in-project-history (list re))
213 (setq *textmate-find-in-project-default* re) 213 (setq *textmate-find-in-project-default* re)
214 (compilation-start (concat "cd " root "; egrep -nR --exclude='" 214 (let ((type (textmate-project-root-type root)))
215 *textmate-gf-exclude* 215 (let ((command
216 "' --include='" 216 (cond ((not (string= type "unknown"))
217 incpat 217 (concat "cd "
218 "' '" 218 root
219 re 219 " ; "
220 "' . | grep -vE '" 220 (cond ((string= type "git") "git ls-files")
221 *textmate-gf-exclude* 221 ((string= type "hg") "hg manifest"))
222 "' | sed s:./::" 222 " | xargs grep -nR '" re "'"))
223 ) 223 (t (concat "cd " root "; egrep -nR --exclude='"
224 'grep-mode 224 *textmate-gf-exclude*
225 ) 225 "' --include='"
226 ) 226 incpat
227 )) 227 "' '"
228 228 re
229 "' . | grep -vE '"
230 *textmate-gf-exclude*
231 "' | sed s:./::"
232 )))))
233 (compilation-start command 'grep-mode)))
234 )))
229 235
230 (defun textmate-clear-cache () 236 (defun textmate-clear-cache ()
231 (interactive) 237 (interactive)
232 (setq *textmate-project-root* nil) 238 (setq *textmate-project-root* nil)
233 (setq *textmate-project-files* nil) 239 (setq *textmate-project-files* nil)
265 (defun textmate-also-ignore (pattern) 271 (defun textmate-also-ignore (pattern)
266 "Also ignore PATTERN in project files." 272 "Also ignore PATTERN in project files."
267 (setq *textmate-gf-exclude* 273 (setq *textmate-gf-exclude*
268 (concat *textmate-gf-exclude* "|" pattern))) 274 (concat *textmate-gf-exclude* "|" pattern)))
269 275
276 (defun textmate-project-root-type (root)
277 (cond ((member ".git" (directory-files root)) "git")
278 ((member ".hg" (directory-files root)) "hg")
279 (t "unknown")
280 ))
281
270 (defun textmate-project-files (root) 282 (defun textmate-project-files (root)
283 (let ((type (textmate-project-root-type root)))
284 (cond ((string= type "git") (split-string
285 (shell-command-to-string
286 (concat "cd " root " && git ls-files")) "\n" t))
287 ((string= type "hg") (split-string
288 (shell-command-to-string
289 (concat "cd " root " && hg manifest")) "\n" t))
290 ((string= type "unknown") (textmate-cached-project-files-find root))
291 )))
292
293 (defun textmate-project-files-find (root)
271 (split-string 294 (split-string
272 (shell-command-to-string 295 (shell-command-to-string
273 (concat 296 (concat
274 "find " 297 "find "
275 root 298 root
277 *textmate-gf-exclude* 300 *textmate-gf-exclude*
278 "' | sed 's:" 301 "' | sed 's:"
279 *textmate-project-root* 302 *textmate-project-root*
280 "/::'")) "\n" t)) 303 "/::'")) "\n" t))
281 304
282 (defun textmate-cached-project-files (&optional root) 305 (defun textmate-cached-project-files-find (&optional root)
283 (cond 306 (cond
284 ((null textmate-use-file-cache) (textmate-project-files root)) 307 ((null textmate-use-file-cache) (textmate-project-files root))
285 ((equal (textmate-project-root) (car *textmate-project-files*)) 308 ((equal (textmate-project-root) (car *textmate-project-files*))
286 (cdr *textmate-project-files*)) 309 (cdr *textmate-project-files*))
287 (t (cdr (setq *textmate-project-files* 310 (t (cdr (setq *textmate-project-files*