From 6ad86eee284af991c0fe0e7369b730fd64c3778f Mon Sep 17 00:00:00 2001 From: irfn Date: Tue, 11 Aug 2009 22:31:16 +0530 Subject: [PATCH] Refactor to a nicer way to extend the project roots --- .gitignore | 1 + textmate.el | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c531d98 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.elc diff --git a/textmate.el b/textmate.el index 706cbe6..44fdaae 100644 --- a/textmate.el +++ b/textmate.el @@ -249,13 +249,21 @@ (setq *textmate-project-root* nil)))) *textmate-project-root*) +(defun root-match(root names) + (member (car names) (directory-files root))) + +(defun root-matches(root names) + (if (root-match root names) + (root-match root names) + (if (eq (length (cdr names)) 0) + 'nil + (root-matches root (cdr names)) + ))) + (defun textmate-find-project-root (&optional root) (when (null root) (setq root default-directory)) (cond - ((or - (member ".git" (directory-files root)) - (member "Rakefile" (directory-files root)) - (member "Makefile" (directory-files root))) + ((root-matches root '(".git" "Rakefile" "Makefile" "README" "build.xml")) (expand-file-name root)) ((equal (expand-file-name root) "/") nil) (t (textmate-find-project-root (concat (file-name-as-directory root) ".."))))) @@ -290,4 +298,4 @@ A place is considered `tab-width' character columns." (funcall (cadr mode) -1))))) (provide 'textmate) -;;; textmate.el ends here +;;; textmate.el ends here \ No newline at end of file