Skip to content

Commit

Permalink
Refactor to a nicer way to extend the project roots
Browse files Browse the repository at this point in the history
  • Loading branch information
irfn committed Aug 11, 2009
1 parent 2b34699 commit 6ad86ee
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.elc
18 changes: 13 additions & 5 deletions textmate.el
Original file line number Diff line number Diff line change
Expand Up @@ -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) "..")))))
Expand Down Expand Up @@ -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

0 comments on commit 6ad86ee

Please sign in to comment.