Last active
August 29, 2015 13:58
-
-
Save tobias/10182549 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require 'compile) | |
(defun locate-all-dominating-files (dir filename) | |
"Searches for FILENAME in DIR and its parents, returning a list | |
of all dirs containing the file." | |
(let ((found-dir (locate-dominating-file (expand-file-name dir) filename))) | |
(if found-dir | |
(cons found-dir (locate-all-dominating-files | |
(concat found-dir "..") | |
filename))))) | |
(defvar lein-history nil) | |
(defun lein () | |
"Searches up the path for all project.clj's, asks at what level | |
to run the command (if more than one are found), then asks for a | |
lein command." | |
(interactive) | |
(let* ((dirs (locate-all-dominating-files default-directory "project.clj")) | |
(dir (case (length dirs) | |
(0 nil) | |
(1 (first dirs)) | |
(t (ido-completing-read "Project? " dirs))))) | |
(if dir | |
(compile (concat (format "cd %s;lein " dir) | |
(read-from-minibuffer "Lein task: " "install" | |
nil nil 'lein-history))) | |
(message "No project.clj found")))) | |
(define-key clojure-mode-map (kbd "C-c l") 'lein) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment