File tree Expand file tree Collapse file tree 3 files changed +29
-17
lines changed Expand file tree Collapse file tree 3 files changed +29
-17
lines changed Original file line number Diff line number Diff line change @@ -601,32 +601,24 @@ TODO/WRITEME
601
601
@findex haskell-session-change-target
602
602
@vindex haskell-interactive-mode-hook
603
603
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.
607
606
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
609
610
610
611
@cindex testing
611
612
- Testing
612
613
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
-
618
614
@cindex benchmarking
619
615
- Benchmark
620
616
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
-
625
617
- Executable
626
618
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 .
630
622
631
623
632
624
TODO/WRITEME
Original file line number Diff line number Diff line change @@ -444,6 +444,25 @@ 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 targets from .cabal file."
449
+ (defvar haskell-cabal-source-bearing-sections )
450
+ (let ((cabal-file (haskell-cabal-find-file)))
451
+ (when (and cabal-file (file-readable-p cabal-file))
452
+ (with-temp-buffer
453
+ (insert-file-contents cabal-file)
454
+ (let* ((targets (mapcar (lambda (arg ) (haskell-cabal--all-instances arg))
455
+ haskell-cabal-source-bearing-sections)))
456
+ (apply #'append targets))))))
457
+
458
+ (defun haskell-cabal--all-instances (target )
459
+ " Return list of all instances of TARGET section."
460
+ (goto-char (point-min ))
461
+ (let (matches)
462
+ (while (re-search-forward (concat target " +\\ ([[:word:]-]+\\ )" ) nil t )
463
+ (push (match-string 1 ) matches))
464
+ (sort matches 'string< )))
465
+
447
466
(defmacro haskell-cabal-with-subsection (subsection replace &rest funs )
448
467
" Copy subsection data into a temporary buffer, save indentation
449
468
and execute FORMS
Original file line number Diff line number Diff line change @@ -773,7 +773,8 @@ inferior GHCi process."
773
773
;;;### autoload
774
774
(defun haskell-session-change-target (target )
775
775
" 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))))
777
778
(let* ((session haskell-session)
778
779
(old-target (haskell-session-get session 'target )))
779
780
(when session
You can’t perform that action at this time.
0 commit comments