Skip to content

Commit 47bf501

Browse files
committed
Choose target for haskell-session-change-target
1 parent 318ccab commit 47bf501

File tree

3 files changed

+25
-17
lines changed

3 files changed

+25
-17
lines changed

doc/haskell-mode.texi

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -601,32 +601,24 @@ TODO/WRITEME
601601
@findex haskell-session-change-target
602602
@vindex haskell-interactive-mode-hook
603603

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

608-
After the session is started, you can switch the target for
607+
608+
After REPL session started, in @code{haskell-interactive-mode} buffer invoke the
609+
@code{haskell-session-change-target} and select from available targets for
609610

610611
@cindex testing
611612
- Testing
612613

613-
In @code{haskell-interactive-mode} buffer invoke the
614-
@code{haskell-session-change-target} and enter the name of the test you
615-
wish to perform, i.e. ``test''.
616-
Answer ``yes'' to restart the session.
617-
618614
@cindex benchmarking
619615
- Benchmark
620616

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

627-
In @code{haskell-interactive-mode} buffer invoke the @code{haskell-session-change-target}
628-
and enter the name of the executable you wish to work with.
629-
Answer ``yes'' to restart the session.
619+
- Library
620+
621+
Answer ``yes'' to restart the session and run your tests, benchmarks, executables.
630622

631623

632624
TODO/WRITEME

haskell-cabal.el

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,21 @@ OTHER-WINDOW use `find-file-other-window'."
444444
(defun haskell-cabal-section-data-start-column (section)
445445
(plist-get section :data-start-column))
446446

447+
(defun haskell-cabal-enum-targets ()
448+
"Enumerate .cabal targets."
449+
(let ((cabal-file (haskell-cabal-find-file)))
450+
(when (and cabal-file (file-readable-p cabal-file))
451+
(with-temp-buffer
452+
(insert-file-contents cabal-file)
453+
(haskell-cabal-mode)
454+
(let (matches)
455+
(goto-char (point-min))
456+
(haskell-cabal-next-section)
457+
(while (not (eobp))
458+
(push (haskell-cabal-section-value (haskell-cabal-section)) matches)
459+
(haskell-cabal-next-section))
460+
(reverse matches))))))
461+
447462
(defmacro haskell-cabal-with-subsection (subsection replace &rest funs)
448463
"Copy subsection data into a temporary buffer, save indentation
449464
and execute FORMS

haskell-commands.el

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,8 @@ inferior GHCi process."
773773
;;;###autoload
774774
(defun haskell-session-change-target (target)
775775
"Set the build TARGET for cabal REPL."
776-
(interactive "sNew build target:")
776+
(interactive
777+
(list (completing-read "New build target:" (haskell-cabal-enum-targets))))
777778
(let* ((session haskell-session)
778779
(old-target (haskell-session-get session 'target)))
779780
(when session

0 commit comments

Comments
 (0)