make C-c C-k aware of rebar and rebar.config

This commit is contained in:
Gleb Peregud 2012-02-29 14:00:04 +01:00
parent 27813974d9
commit 5921ed3a91

View file

@ -47,6 +47,25 @@
(add-to-list 'load-path wrangler-path) (add-to-list 'load-path wrangler-path)
(require 'wrangler))) (require 'wrangler)))
(defun erlang-rebar-compile ()
(interactive)
(let* ((dir (or (projectile-get-project-root)
(file-name-directory (buffer-file-name))))
(pref (concat "cd " dir " && "))
(cmd (cond ((file-exists-p (expand-file-name "rebar" dir)) "./rebar compile")
((executable-find "rebar") "rebar compile")
((file-exists-p (expand-file-name "Makefile" dir)) "Makefile")
(t nil))))
(if cmd
(compilation-start (concat pref cmd))
(call-interactively 'inferior-erlang-compile))
))
(add-hook 'erlang-mode-hook (lambda ()
(make-variable-buffer-local 'projectile-project-root-files)
(setq projectile-project-root-files '("rebar.config" ".git" ".hg" ".bzr" ".projectile"))
(setq erlang-compile-function 'erlang-rebar-compile)))
(provide 'prelude-erlang) (provide 'prelude-erlang)
;;; prelude-erlang.el ends here ;;; prelude-erlang.el ends here