Skip to content

Commit 06306dc

Browse files
committed
Var to enable/disable prompts on starting REPL
If haskell-process-load-or-reload-prompt is nil, there will be no prompts on starting REPL, and all the defaults are accepted.
1 parent 64bd44f commit 06306dc

File tree

4 files changed

+26
-12
lines changed

4 files changed

+26
-12
lines changed

haskell-customize.el

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2323
;; Customization variables
2424

25+
(defcustom haskell-process-load-or-reload-prompt nil
26+
"Nil means there will be no prompts on starting REPL. Defaults will be accepted."
27+
:type 'boolean
28+
:group 'haskell-interactive)
29+
2530
(defgroup haskell nil
2631
"Major mode for editing Haskell programs."
2732
:link '(custom-manual "(haskell-mode)")

haskell-session.el

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,14 @@ with all relevant buffers)."
150150
(haskell-session-get s 'name))
151151

152152
(defun haskell-session-target (s)
153-
"Get the session build target."
153+
"Get the session build target.
154+
If `haskell-process-load-or-reload-prompt' is nil, accept `default'."
154155
(let* ((maybe-target (haskell-session-get s 'target))
155156
(target (if maybe-target maybe-target
156157
(let ((new-target
157-
(read-string "build target (empty for default):")))
158+
(if haskell-process-load-or-reload-prompt
159+
(read-string "build target (empty for default):")
160+
"")))
158161
(haskell-session-set-target s new-target)))))
159162
(if (not (string= target "")) target nil)))
160163

haskell-utils.el

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,23 @@
3838
;; require/depend-on any other haskell-mode modules in order to
3939
;; stay at the bottom of the module dependency graph.
4040

41+
(require 'haskell-customize)
42+
4143
(defvar haskell-utils-async-post-command-flag nil
4244
"Non-nil means some commands were triggered during async function execution.")
4345
(make-variable-buffer-local 'haskell-utils-async-post-command-flag)
4446

4547
(defun haskell-utils-read-directory-name (prompt default)
4648
"Read directory name and normalize to true absolute path.
4749
Refer to `read-directory-name' for the meaning of PROMPT and
48-
DEFAULT."
50+
DEFAULT. If `haskell-process-load-or-reload-prompt' is nil, accept `default'."
4951
(let ((filename (file-truename
50-
(read-directory-name prompt
51-
default
52-
default))))
53-
(concat (replace-regexp-in-string "/$" "" filename)
54-
"/")))
52+
(if haskell-process-load-or-reload-prompt
53+
(read-directory-name prompt
54+
default
55+
default)
56+
default))))
57+
(concat (replace-regexp-in-string "/$" "" filename) "/")))
5558

5659
(defun haskell-utils-parse-import-statement-at-point ()
5760
"Return imported module name if on import statement or nil otherwise.

haskell.el

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
(require 'haskell-modules)
3030
(require 'haskell-string)
3131
(require 'haskell-completions)
32+
(require 'haskell-utils)
33+
(require 'haskell-customize)
3234

3335
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3436
;; Basic configuration hooks
@@ -169,12 +171,13 @@
169171
session))
170172

171173
(defun haskell-session-new-assume-from-cabal ()
172-
"Prompt to create a new project based on a guess from the nearest Cabal file."
174+
"Prompt to create a new project based on a guess from the nearest Cabal file.
175+
If `haskell-process-load-or-reload-prompt' is nil, accept `default'."
173176
(let ((name (haskell-session-default-name)))
174177
(unless (haskell-session-lookup name)
175-
(when (y-or-n-p (format "Start a new project named “%s”? "
176-
name))
177-
(haskell-session-make name)))))
178+
(if (or (not haskell-process-load-or-reload-prompt)
179+
(y-or-n-p (format "Start a new project named “%s”? " name)))
180+
(haskell-session-make name)))))
178181

179182
;;;###autoload
180183
(defun haskell-session ()

0 commit comments

Comments
 (0)