Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New variable to allow user to enable/disable prompts on starting REPL #769

Merged
merged 1 commit into from
Jul 23, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions haskell-customize.el
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Customization variables

(defcustom haskell-process-load-or-reload-prompt nil
"Nil means there will be no prompts on starting REPL. Defaults will be accepted."
:type 'boolean
:group 'haskell-interactive)

(defgroup haskell nil
"Major mode for editing Haskell programs."
:link '(custom-manual "(haskell-mode)")
Expand Down
7 changes: 5 additions & 2 deletions haskell-session.el
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,14 @@ with all relevant buffers)."
(haskell-session-get s 'name))

(defun haskell-session-target (s)
"Get the session build target."
"Get the session build target.
If `haskell-process-load-or-reload-prompt' is nil, accept `default'."
(let* ((maybe-target (haskell-session-get s 'target))
(target (if maybe-target maybe-target
(let ((new-target
(read-string "build target (empty for default):")))
(if haskell-process-load-or-reload-prompt
(read-string "build target (empty for default):")
"")))
(haskell-session-set-target s new-target)))))
(if (not (string= target "")) target nil)))

Expand Down
15 changes: 9 additions & 6 deletions haskell-utils.el
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,23 @@
;; require/depend-on any other haskell-mode modules in order to
;; stay at the bottom of the module dependency graph.

(require 'haskell-customize)

(defvar haskell-utils-async-post-command-flag nil
"Non-nil means some commands were triggered during async function execution.")
(make-variable-buffer-local 'haskell-utils-async-post-command-flag)

(defun haskell-utils-read-directory-name (prompt default)
"Read directory name and normalize to true absolute path.
Refer to `read-directory-name' for the meaning of PROMPT and
DEFAULT."
DEFAULT. If `haskell-process-load-or-reload-prompt' is nil, accept `default'."
(let ((filename (file-truename
(read-directory-name prompt
default
default))))
(concat (replace-regexp-in-string "/$" "" filename)
"/")))
(if haskell-process-load-or-reload-prompt
(read-directory-name prompt
default
default)
default))))
(concat (replace-regexp-in-string "/$" "" filename) "/")))

(defun haskell-utils-parse-import-statement-at-point ()
"Return imported module name if on import statement or nil otherwise.
Expand Down
11 changes: 7 additions & 4 deletions haskell.el
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
(require 'haskell-modules)
(require 'haskell-string)
(require 'haskell-completions)
(require 'haskell-utils)
(require 'haskell-customize)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Basic configuration hooks
Expand Down Expand Up @@ -169,12 +171,13 @@
session))

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

;;;###autoload
(defun haskell-session ()
Expand Down