Emacs config utilizing prelude as a base
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
2.4 KiB

14 years ago
14 years ago
  1. ;;; prelude-erlang.el --- Emacs Prelude: Erlang programming support.
  2. ;;
  3. ;; Copyright (c) 2011 Gleb Peregud
  4. ;;
  5. ;; Author: Gleb Peregud <gleber.p@gmail.com>
  6. ;; Version: 1.0.0
  7. ;; Keywords: convenience erlang
  8. ;; This file is not part of GNU Emacs.
  9. ;;; Commentary:
  10. ;; Erlang is a concurrent functional language.
  11. ;;; License:
  12. ;; This program is free software; you can redistribute it and/or
  13. ;; modify it under the terms of the GNU General Public License
  14. ;; as published by the Free Software Foundation; either version 3
  15. ;; of the License, or (at your option) any later version.
  16. ;;
  17. ;; This program is distributed in the hope that it will be useful,
  18. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. ;; GNU General Public License for more details.
  21. ;;
  22. ;; You should have received a copy of the GNU General Public License
  23. ;; along with GNU Emacs; see the file COPYING. If not, write to the
  24. ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  25. ;; Boston, MA 02110-1301, USA.
  26. ;;; Code:
  27. (defcustom wrangler-path nil
  28. "*The location of wrangler elisp directory"
  29. :group 'prelude-erlang
  30. :type 'string
  31. :safe 'stringp)
  32. (when (require 'erlang-start nil t)
  33. (eval-after-load 'erlang-mode
  34. '(progn
  35. (flymake-mode)))
  36. (when (not (null wrangler-path))
  37. (add-to-list 'load-path wrangler-path)
  38. (require 'wrangler)))
  39. (defun erlang-rebar-compile ()
  40. (interactive)
  41. (let* ((dir (or (projectile-get-project-root)
  42. (file-name-directory (buffer-file-name))))
  43. (pref (concat "cd " dir " && "))
  44. (cmd (cond ((file-exists-p (expand-file-name "rebar" dir)) "./rebar compile")
  45. ((executable-find "rebar") "rebar compile")
  46. ((file-exists-p (expand-file-name "Makefile" dir)) "Makefile")
  47. (t nil))))
  48. (if cmd
  49. (compilation-start (concat pref cmd))
  50. (call-interactively 'inferior-erlang-compile))
  51. ))
  52. (add-hook 'erlang-mode-hook (lambda ()
  53. (make-variable-buffer-local 'projectile-project-root-files)
  54. (setq projectile-project-root-files '("rebar.config" ".git" ".hg" ".bzr" ".projectile"))
  55. (setq erlang-compile-function 'erlang-rebar-compile)))
  56. (provide 'prelude-erlang)
  57. ;;; prelude-erlang.el ends here