-
Notifications
You must be signed in to change notification settings - Fork 347
Customizable settings for skipping questions #409
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
Conversation
Creating a new session in a simple project asks many questions for which the default answers may be absolute fine. This change adds four customizable variables, and setting them (in file-local and dir-local variables) would allow questions to be skipped during session creation.
I've been thinking to revisit the prompting stuff and it make it not on by default. |
Do you mean that there would simply be an error when using commands which require a session? If so, I personally think that would be better. |
Well, rather that the prompting when making a new project wouldn't happen and instead it would just make the general assumptions and you'd customize them later if necessary. |
Aha. Well, that's moving in the opposite direction from what I was suggesting. :-) I'm a bit wary of sessions getting started automatically, particularly if it happens almost silently using defaults. When that sort of thing goes wrong, it's harder to track down in that sort of scheme than with the alternative of making everything explicit while allowing experts to streamline it. But that's not to say it couldn't work beautifully. |
I was thinking to retain something like the above |
If haskell-mode will make assumptions, it should show those assumptions to the user by, say, printing them to the session buffer. There also should be some way to override those assumptions with local variables, too. |
As I read comments here I see that there is general consensus of not pulling these 4 vars in and rethinking interaction with user again, am I right? (Do not hesitate to reopen this issue if I misunderstood the intention). |
I've made an ugly workaround for this, but the proper way, IMHO, would be to adapt Workaround: ;; Start Haskell Interactive mode without prompts
(defun haskell-session-new-assume-from-cabal-no-prompt ()
(let ((name (haskell-session-default-name)))
(unless (haskell-session-lookup name)
(haskell-session-make name))))
(defun haskell-utils-read-directory-name-no-prompt (prompt default)
(let ((filename (file-truename default)))
(concat (replace-regexp-in-string "/$" "" filename) "/")))
(defun haskell-session-target-no-prompt (s)
(let* ((maybe-target (haskell-session-get s 'target))
(target (if maybe-target maybe-target (haskell-session-set-target s ""))))
(if (not (string= target "")) target nil)))
;; Auto-accept default values on interactive mode
(fset 'haskell-session-new-assume-from-cabal 'haskell-session-new-assume-from-cabal-no-prompt)
(fset 'haskell-utils-read-directory-name 'haskell-utils-read-directory-name-no-prompt)
(fset 'haskell-session-target 'haskell-session-target-no-prompt) |
If with prefix argument (C-u) it should ask. Without prefix it should not
ask.
|
Should behave something like this: (defun haskell-process-load-or-reload-ad (&optional arg)
"If ARG is set (C-u), starts session with prompts.
If ARG is not set, accepts defaults without prompting user."
(interactive "P")
(if arg
(haskell-process-load-or-reload)
(progn
(advice-add 'haskell-session-new-assume-from-cabal
:override #'haskell-session-new-assume-from-cabal-no-prompt)
(advice-add 'haskell-utils-read-directory-name
:override #'haskell-utils-read-directory-name-no-prompt)
(advice-add 'haskell-session-target
:override #'haskell-session-target-no-prompt)
(haskell-process-load-or-reload)
(advice-remove 'haskell-session-new-assume-from-cabal
#'haskell-session-new-assume-from-cabal-no-prompt)
(advice-remove 'haskell-utils-read-directory-name
#'haskell-utils-read-directory-name-no-prompt)
(advice-remove 'haskell-session-target
#'haskell-session-target-no-prompt)))) This is, of course, just for testing purpose. This depends heavily on the three advised functions above. Those functions are quite scattered and passing an ARG around would not be the best solution. I'm very fresh in emacs, so I do not know if a temporary global would be acceptable. (defvar do-not-ask nil)
(defun haskell-process-load-or-reload-ad ()
(interactive)
(ignore-errors
(progn
(setq do-not-ask t)
(haskell-process-load-or-reload)))
(setq do-not-ask nil)) and rewrite those three functions to check for |
Sorry, no time to comment fully here, but I wanted to point out that the new-style advice functions aren't available in all the Emacs versions we currently support. |
I made a solution with a variable The three above mentioned functions are slightly changed just to check the value of If you think it's useful, I can make PR. |
Yes please.
|
Edit: Link to PR. |
Creating a new session in a simple project asks many questions for which
the default answers may be absolute fine. This change adds four
customizable variables, and setting them (in file-local and dir-local
variables) would allow questions to be skipped during session creation.
See #407
For example (to use file-local variables; dir-local variables would work too; here
t
means "default"):