Browse files

use `locate-dominating-file' function to detect project root directory

  • Loading branch information...
1 parent 6ac9a84 commit 18d29b387ed48e2c181b7ad3b043f2fdf88e0ca1 @tonini committed Oct 14, 2013
Showing with 6 additions and 13 deletions.
  1. +6 −13 elixir-mix.el
@@ -116,9 +116,9 @@
(defvar elixir-mix-buffer-name "*MIX*"
"Name of the mix output buffer.")
-(defvar elixir-mix--elixir-project-root-indicators
- '("mix.exs" "mix.lock" ".git")
- "List of files and directories which indicate a elixir project root.")
+(defvar elixir-mix--elixir-project-root-indicator
+ "mix.exs"
+ "The file which indicate an elixir project root.")
(defvar elixir-mix--deps-commands
'("deps" "deps.clean" "deps.compile" "deps.get" "deps.unlock" "deps.unlock")
@@ -132,18 +132,11 @@
'("path" "url")
"List of local.install option types.")
-(defun elixir-mix--elixir-project-root-directory-p (a-directory)
- "Return t if A-DIRECTORY is the elixir project root."
- (equal a-directory (file-name-directory (directory-file-name a-directory))))
(defun elixir-mix--elixir-project-root (&optional directory)
"Finds the root directory of the project by walking the
-directory tree until it finds a elixir project root indicator."
- (let* ((directory (file-name-as-directory (or directory (expand-file-name default-directory))))
- (present-files (directory-files directory)))
- (cond ((elixir-mix--elixir-project-root-directory-p directory) nil)
- ((> (length (intersection present-files elixir-mix--elixir-project-root-indicators :test 'string=)) 0) directory)
- (t (elixir-mix--elixir-project-root (file-name-directory (directory-file-name directory)))))))
+ directory tree until it finds a elixir project root indicator."
+ (let* ((directory (file-name-as-directory (or directory (expand-file-name default-directory)))))
+ (locate-dominating-file directory elixir-mix--elixir-project-root-indicator)))
(defun elixir-mix--get-buffer (name)
"Get and kills a buffer if exists and returns a new one."

0 comments on commit 18d29b3

Please sign in to comment.