# HG changeset patch # User Augie Fackler # Date 1259094249 21600 # Node ID 95b7dc384677ff3feb0dea5d1a0a0abf97f25189 # Parent 59ea03d7029acd0ab3b493c9402cb7222d4ec0c2 textmate.el: bring in upstream changes diff --git a/.elisp/textmate.el b/.elisp/textmate.el --- a/.elisp/textmate.el +++ b/.elisp/textmate.el @@ -138,6 +138,8 @@ (defvar *textmate-find-in-project-type-default* nil) +(defvar *textmate-compile-default* nil) + ;;; Bindings (defun textmate-ido-fix () @@ -240,6 +242,8 @@ Symbols matching the text at point are p (textmate-project-files root)))))) (defun textmate-find-in-project-type () + "Run grep over project files of a specific type and put the results +in a grep-mode buffer." (interactive) (let ((pat (read-string (concat "Suffix" (if *textmate-find-in-project-type-default* @@ -250,37 +254,55 @@ Symbols matching the text at point are p (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*) - ) +(defun textmate-start-compile-in-root (command &optional mode + name-function + highlight-regexp) + "Idential to compilation-start, except it automatically changes to the +project root directory before starting the command." + (let ((root (textmate-project-root))) (when (null root) (error "Not in a project area.")) - (let ((re (read-string (concat "Search for " + (let ((realcommand (concat "cd " root " ; " command))) + (compilation-start realcommand mode name-function highlight-regexp)))) + +(defun textmate-compile () + "Run a command in compilation-mode rooted at the project root." + (interactive) + (let* ((default *textmate-compile-default*) + (command (read-string + (concat "Command" + (if default (format " [\"%s\"]" default) "") + ": ") nil 'textmate-compile-history default))) + (setq *textmate-compile-default* command) + (textmate-start-compile-in-root command))) + +(defun textmate-find-in-project (&optional pattern) + "Run grep over project files with results in grep-mode. + +Takes an optional argument (see also textmate-find-in-project-type) +of a file extension to limit the search. Useful for finding results in only a +specific type of file." + (interactive) + (let* ((default *textmate-find-in-project-default*) + (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") + nil 'textmate-find-in-project-history default)) + (incpat (if pattern pattern "*")) + (type (textmate-project-root-type (textmate-project-root))) + (command + (cond ((not (string= type "unknown")) + (concat (cond ((string= type "git") "git ls-files") ((string= type "hg") "hg manifest")) (if *textmate-vcs-exclude* - (concat " | grep -v " (shell-quote-argument *textmate-vcs-exclude*)) + (concat " | grep -v " + (shell-quote-argument *textmate-vcs-exclude*)) "") - " | xargs grep -nR " + " | xargs egrep -nR " (if pattern (concat " --include='" pattern "' ") "") " -- " (shell-quote-argument re))) - (t (concat "cd " root "; egrep -nR --exclude='" + (t (concat "egrep -nR --exclude='" *textmate-gf-exclude* "' --include='" incpat @@ -290,8 +312,8 @@ Symbols matching the text at point are p *textmate-gf-exclude* "' | sed s:./::" ))))) - (compilation-start command 'grep-mode))) - ))) + (setq *textmate-find-in-project-default* re) + (textmate-start-compile-in-root command 'grep-mode))) (defun textmate-clear-cache () (interactive)