Skip to content

Commit

Permalink
Add README.md and some small improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
leoliu committed Feb 17, 2014
1 parent a7afcd0 commit 8994f27
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
emacs wrapper for rebar
=======================

# Prerequisite #

Emacs 24.x.

`cl-lib` is required for emacs `24.1` and `24.2`, which can be readily
installed via `M-x package-install RET cl-lib RET`.

# Usage #

See the documentation on `rebar-mode` or `global-rebar-mode`. In
erlang mode, an menu item `Rebar` is added to the `Erlang` menu.
25 changes: 12 additions & 13 deletions rebar.el
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,7 @@ If t use all backends in `vc-handled-backends'."
(let ((prompt (if (and default-value
(not (string-match-p "(default .*?): *\\'" prompt)))
(format "%s (default %s): "
(if (string-match ": *\\'" prompt)
(substring prompt 0 (match-beginning 0))
prompt)
(substring prompt 0 (string-match-p ": *\\'" prompt))
(or (car-safe default-value) default-value))
prompt)))
(read-string prompt initial-input history default-value
Expand Down Expand Up @@ -130,10 +128,7 @@ If t use all backends in `vc-handled-backends'."
(setq rebar-project-root (funcall rebar-find-project-function))))

(defmacro rebar-ensure-directory (&rest body)
`(let* ((default-directory (rebar-project-root))
(process-environment
(cons (concat "PATH=" (concat default-directory ":" (getenv "PATH")))
process-environment)))
`(let ((default-directory (file-name-as-directory (rebar-project-root))))
,@body))

(defvar rebar-compilation-finish-functions nil)
Expand Down Expand Up @@ -231,11 +226,7 @@ If t use all backends in `vc-handled-backends'."
(suites (rebar-read-string "Test suites: " nil nil suite)))
(setq rebar-test-suite
(unless (equal suites "")
(format "suites=%S"
(mapconcat 'identity
(split-string (substring-no-properties suites)
",[ \t]*" t)
","))))))
(format "suites=%S" (substring-no-properties suites))))))

;;;###autoload
(defun rebar-eunit (&optional test-suite)
Expand All @@ -261,9 +252,17 @@ If t use all backends in `vc-handled-backends'."
;;;###autoload
(define-minor-mode rebar-mode nil
:lighter (:eval (if global-rebar-mode "" " RB")))

;;;###autoload
(define-minor-mode global-rebar-mode nil
:lighter " GRB" :global t :keymap rebar-mode-map)
:lighter " GRB" :global t :keymap rebar-mode-map
(if global-rebar-mode
(add-hook 'minibuffer-setup-hook #'rebar-minibuffer-setup-function)
(remove-hook 'minibuffer-setup-hook #'rebar-minibuffer-setup-function)))

(defun rebar-minibuffer-setup-function ()
;; Disable the keymap in minibuffer.
(set (make-local-variable 'global-rebar-mode) nil))

(defvar rebar-menu-items '(("Rebar"
(("Run Command" rebar)
Expand Down

0 comments on commit 8994f27

Please sign in to comment.