Skip to content

Commit

Permalink
add support for cabal repl build targets
Browse files Browse the repository at this point in the history
  • Loading branch information
Philonous committed Dec 17, 2013
1 parent 7ae7411 commit c9424aa
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
4 changes: 3 additions & 1 deletion haskell-process.el
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,9 @@ from `module-buffer'."
(append (list (haskell-session-name session)
nil
haskell-process-path-cabal)
'("repl") haskell-process-args-cabal-repl)))
'("repl") haskell-process-args-cabal-repl
(let ((target (haskell-session-target session)))
(if target (list target) nil)))))
('cabal-ghci
(haskell-process-log (format "Starting inferior cabal-ghci process using %s ..."
haskell-process-path-cabal-ghci))
Expand Down
24 changes: 24 additions & 0 deletions haskell-session.el
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,17 @@ If DONTCREATE is non-nil don't create a new session."
(haskell-session-choose)
(haskell-session-new))))

(defun haskell-session-change-target (target)
"Set the build target for cabal repl"
(interactive "sNew build target:")
(let* ((session haskell-session)
(old-target (haskell-session-get session 'target)))
(when session
(haskell-session-set-target session target)
(when (and (not (string= old-target target))
(y-or-n-p "Target changed, restart haskell process?"))
(haskell-process-start session)))))

(defun haskell-session-strip-dir (session file)
"Strip the load dir from the file path."
(let ((cur-dir (haskell-session-current-dir session)))
Expand Down Expand Up @@ -252,6 +263,19 @@ If DONTCREATE is non-nil don't create a new session."
"Get the session name."
(haskell-session-get s 'name))

(defun haskell-session-target (s)
"Get the session build target."
(let* ((maybe-target (haskell-session-get s 'target))
(target (if maybe-target maybe-target
(let ((new-target
(read-string "build target (empty for default):")))
(haskell-session-set-target s new-target)))))
(if (not (string= target "")) target nil)))

(defun haskell-session-set-target (s target)
"Set the session build target."
(haskell-session-set s 'target target))

(defun haskell-session-interactive-buffer (s)
"Get the session interactive buffer."
(let ((buffer (haskell-session-get s 'interactive-buffer)))
Expand Down

0 comments on commit c9424aa

Please sign in to comment.