File tree 3 files changed +29
-17
lines changed 3 files changed +29
-17
lines changed Original file line number Diff line number Diff line change @@ -614,32 +614,24 @@ TODO/WRITEME
614
614
@findex haskell-session-change-target
615
615
@vindex haskell-interactive-mode-hook
616
616
617
- With @code {haskell-session-change-target } you can change the section
618
- (defined in project's @file {.cabal } file) the interactive REPL session is
619
- started with.
617
+ With @code {haskell-session-change-target } you can change the target for
618
+ REPL session.
620
619
621
- After the session is started, you can switch the target for
620
+
621
+ After REPL session started, in @code {haskell-interactive-mode } buffer invoke the
622
+ @code {haskell-session-change-target } and select from available targets for
622
623
623
624
@cindex testing
624
625
- Testing
625
626
626
- In @code {haskell-interactive-mode } buffer invoke the
627
- @code {haskell-session-change-target } and enter the name of the test you
628
- wish to perform, i.e. ``test''.
629
- Answer ``yes'' to restart the session.
630
-
631
627
@cindex benchmarking
632
628
- Benchmark
633
629
634
- In @code {haskell-interactive-mode } buffer invoke the @code {haskell-session-change-target }
635
- and enter the name of the benchmark you wish to perform, i.e. ``bench''.
636
- Answer ``yes'' to restart the session.
637
-
638
630
- Executable
639
631
640
- In @code { haskell-interactive-mode } buffer invoke the @code { haskell-session-change-target }
641
- and enter the name of the executable you wish to work with.
642
- Answer ``yes'' to restart the session.
632
+ - Library
633
+
634
+ Answer ``yes'' to restart the session and run your tests, benchmarks, executables .
643
635
644
636
645
637
TODO/WRITEME
Original file line number Diff line number Diff line change @@ -444,6 +444,21 @@ OTHER-WINDOW use `find-file-other-window'."
444
444
(defun haskell-cabal-section-data-start-column (section )
445
445
(plist-get section :data-start-column ))
446
446
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
+
447
462
(defmacro haskell-cabal-with-subsection (subsection replace &rest funs )
448
463
" Copy subsection data into a temporary buffer, save indentation
449
464
and execute FORMS
Original file line number Diff line number Diff line change @@ -169,6 +169,8 @@ Use to update mtime on BUFFER's file."
169
169
170
170
(defvar url-http-response-status )
171
171
(defvar url-http-end-of-headers )
172
+ (defvar haskell-cabal-targets-history nil
173
+ " History list for session targets." )
172
174
173
175
(defun haskell-process-hayoo-ident (ident )
174
176
; ; FIXME Obsolete doc string, CALLBACK is not used.
@@ -773,7 +775,10 @@ inferior GHCi process."
773
775
;;;### autoload
774
776
(defun haskell-session-change-target (target )
775
777
" Set the build TARGET for cabal REPL."
776
- (interactive " sNew build target:" )
778
+ (interactive
779
+ (list
780
+ (completing-read " New build target: " (haskell-cabal-enum-targets)
781
+ nil nil nil 'haskell-cabal-targets-history )))
777
782
(let* ((session haskell-session)
778
783
(old-target (haskell-session-get session 'target )))
779
784
(when session
You can’t perform that action at this time.
0 commit comments