Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Choose a REPL session target from list #828

Merged
merged 3 commits into from
Sep 2, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 8 additions & 16 deletions doc/haskell-mode.texi
Original file line number Diff line number Diff line change
Expand Up @@ -601,32 +601,24 @@ TODO/WRITEME
@findex haskell-session-change-target
@vindex haskell-interactive-mode-hook

With @code{haskell-session-change-target} you can change the section
(defined in project's @file{.cabal} file) the interactive REPL session is
started with.
With @code{haskell-session-change-target} you can change the target for
REPL session.

After the session is started, you can switch the target for

After REPL session started, in @code{haskell-interactive-mode} buffer invoke the
@code{haskell-session-change-target} and select from available targets for

@cindex testing
- Testing

In @code{haskell-interactive-mode} buffer invoke the
@code{haskell-session-change-target} and enter the name of the test you
wish to perform, i.e. ``test''.
Answer ``yes'' to restart the session.

@cindex benchmarking
- Benchmark

In @code{haskell-interactive-mode} buffer invoke the @code{haskell-session-change-target}
and enter the name of the benchmark you wish to perform, i.e. ``bench''.
Answer ``yes'' to restart the session.

- Executable

In @code{haskell-interactive-mode} buffer invoke the @code{haskell-session-change-target}
and enter the name of the executable you wish to work with.
Answer ``yes'' to restart the session.
- Library

Answer ``yes'' to restart the session and run your tests, benchmarks, executables.


TODO/WRITEME
Expand Down
15 changes: 15 additions & 0 deletions haskell-cabal.el
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,21 @@ OTHER-WINDOW use `find-file-other-window'."
(defun haskell-cabal-section-data-start-column (section)
(plist-get section :data-start-column))

(defun haskell-cabal-enum-targets ()
"Enumerate .cabal targets."
(let ((cabal-file (haskell-cabal-find-file)))
(when (and cabal-file (file-readable-p cabal-file))
(with-temp-buffer
(insert-file-contents cabal-file)
(haskell-cabal-mode)
(let (matches)
(goto-char (point-min))
(haskell-cabal-next-section)
(while (not (eobp))
(push (haskell-cabal-section-value (haskell-cabal-section)) matches)
(haskell-cabal-next-section))
(reverse matches))))))

(defmacro haskell-cabal-with-subsection (subsection replace &rest funs)
"Copy subsection data into a temporary buffer, save indentation
and execute FORMS
Expand Down
7 changes: 6 additions & 1 deletion haskell-commands.el
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ Use to update mtime on BUFFER's file."

(defvar url-http-response-status)
(defvar url-http-end-of-headers)
(defvar haskell-cabal-targets-history nil
"History list for session targets.")

(defun haskell-process-hayoo-ident (ident)
;; FIXME Obsolete doc string, CALLBACK is not used.
Expand Down Expand Up @@ -773,7 +775,10 @@ inferior GHCi process."
;;;###autoload
(defun haskell-session-change-target (target)
"Set the build TARGET for cabal REPL."
(interactive "sNew build target:")
(interactive
(list
(completing-read "New build target: " (haskell-cabal-enum-targets)
nil nil nil 'haskell-cabal-targets-history)))
(let* ((session haskell-session)
(old-target (haskell-session-get session 'target)))
(when session
Expand Down