Skip to content

Commit 81f32e5

Browse files
committed
Var to enable/disable prompts on starting REPL
1 parent 64bd44f commit 81f32e5

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

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-p' 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-p
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: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,14 @@
4545
(defun haskell-utils-read-directory-name (prompt default)
4646
"Read directory name and normalize to true absolute path.
4747
Refer to `read-directory-name' for the meaning of PROMPT and
48-
DEFAULT."
48+
DEFAULT. If `haskell-process-load-or-reload-p' is nil, accept `default'."
4949
(let ((filename (file-truename
50-
(read-directory-name prompt
51-
default
52-
default))))
53-
(concat (replace-regexp-in-string "/$" "" filename)
54-
"/")))
50+
(if haskell-process-load-or-reload-p
51+
(read-directory-name prompt
52+
default
53+
default)
54+
default))))
55+
(concat (replace-regexp-in-string "/$" "" filename) "/")))
5556

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

haskell.el

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,17 @@
168168
(haskell-process-start session)
169169
session))
170170

171+
(defvar haskell-process-load-or-reload-p t
172+
"Non-nil means there will be no prompts on starting REPL. Defaults will be accepted.")
173+
171174
(defun haskell-session-new-assume-from-cabal ()
172-
"Prompt to create a new project based on a guess from the nearest Cabal file."
175+
"Prompt to create a new project based on a guess from the nearest Cabal file.
176+
If `haskell-process-load-or-reload-p' is nil, accept `default'."
173177
(let ((name (haskell-session-default-name)))
174178
(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)))))
179+
(if (or (not haskell-process-load-or-reload-p)
180+
(y-or-n-p (format "Start a new project named “%s”? " name)))
181+
(haskell-session-make name)))))
178182

179183
;;;###autoload
180184
(defun haskell-session ()

0 commit comments

Comments
 (0)