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

Haskell Interactive Shell is stuck when started #3271

Closed
PierreR opened this issue Oct 5, 2015 · 24 comments
Closed

Haskell Interactive Shell is stuck when started #3271

PierreR opened this issue Oct 5, 2015 · 24 comments

Comments

@PierreR
Copy link
Contributor

PierreR commented Oct 5, 2015

When you fire up an interactive shell in Haskell (haskell-interactive-bring with SPC m s s), you end up being in a kind of "stuck mode". From this state (wrongly the normal state), if you try to press i to enter the insert state, you will quickly realize you cannot press RET to evaluate the line. Nothing is actually working, no completion, ... you can just enter characters.

A workaround described in issue #445, is to press c-c c-k and then A but this is just a workaround and you will quickly be back in this "stuck-mode" if you leave the insert state and come back again. That's why in issue #445 it is advised to use c-o SPC in order to stay in insert mode.

There is another trick described by @meditans in #445 that also works and is less awkward compared to c-c c-k:

just move with the arrows towards the end of the grey area, then write a new expression

Still, the whole process makes the use of the interactive repl in Haskell a rather painful experience. This is a shame because this internal repl is tremendously useful indeed.

Would it be possible to go directly in an non-stuck insert mode whenever we use haskell-interactive-bring ? Even better would it be possible to prevent the stuck mode completely (I don't really see how it is useful).

Additional info: using spacemacs 0.104.2, default shell is zsh.

@d12frosted
Copy link
Collaborator

Hm. When I open any hs file of cabal project, enter normal state and then SPC m s s the REPL is opened in insert mode, so I don't see this problem. I am on develop.

@PierreR
Copy link
Contributor Author

PierreR commented Oct 6, 2015

@d12frosted Thanks for the input. I will try again on develop.

Could you let me know if ,sS (haskell-interactive-swich) works for you when the focus is on the repl. It works only within a buffer for me. I was about to enter a new issue about that but I want to know if it is just a problem on my side somehow.

@d12frosted
Copy link
Collaborator

@PierreR I don't understand what you expect from haskell-interactive-switch. It is used to switch from any other buffer to REPL. When you are focusing REPL, it remains there. Or would you like it to switch and enter edit mode?

@PierreR
Copy link
Contributor Author

PierreR commented Oct 6, 2015

@d12frosted Well it is the only (,s) binding available on the repl. So I would expect it to bring me back to the buffer (as a switch) I came from. I can always use SPC-w j or something. So that's fine. Maybe it just needs to be removed.from the menu then.

@d12frosted
Copy link
Collaborator

Ah I see. Sorry, I misunderstood you. Well yeah, it looks like broken thing. Cause it's intended to return from REPL to previous buffer. I'll look into it. Thanks for noticing :)

@d12frosted
Copy link
Collaborator

@PierreR, ,sS is fixed upstream.

@PierreR
Copy link
Contributor Author

PierreR commented Oct 6, 2015

Thanks ! I will try it asap.

d12frosted pushed a commit to d12frosted/spacemacs that referenced this issue Oct 7, 2015
- update section about setting up PATH by updating value of
  =exec-path= (previously it was saying to update it in =user-init=
  function, but looks like you need to do it in =user-config=) -
  following syl20bnr#1718
- add FAQ section
  - add note about setting up =stack-ghci= as =haskell-process= (as
  noted in syl20bnr#2142)
  - add note about fixing problems with =ghc-mod= and =stack=
  - add note about fixing stuck REPL (following syl20bnr#3271)
TheBB pushed a commit that referenced this issue Oct 7, 2015
- update section about setting up PATH by updating value of
  =exec-path= (previously it was saying to update it in =user-init=
  function, but looks like you need to do it in =user-config=) -
  following #1718
- add FAQ section
  - add note about setting up =stack-ghci= as =haskell-process= (as
  noted in #2142)
  - add note about fixing problems with =ghc-mod= and =stack=
  - add note about fixing stuck REPL (following #3271)
@TheBB
Copy link
Collaborator

TheBB commented Oct 7, 2015

There is a FAQ entry now in the Haskell README for this problem, but it would be nice to actually get it fixed.

@d12frosted
Copy link
Collaborator

Yeah, I do understand, but I can't think about any good way for fixing this. I can't understand why when you exit normal mode it doesn't move to the right. I think it should be fixed by someone who is familiar with non-edit modes (I don't use them, honestly).

@d12frosted
Copy link
Collaborator

You see, the problem is actually not with haskell REPL, but with normal mode -> edit mode itself. When I try to enter normal mode when cursor is at the end of line it moves 1 character left. Then I move back to edit mode - and it doesn't move at the original place.

The same in VIM. Just tested.

Updated

So I am not sure what to do with it. But I'll try to think of something.

@TheBB
Copy link
Collaborator

TheBB commented Oct 7, 2015

Well yeah, that's common behaviour of course. It doesn't cause other comint-like modes to hang, though, so something is different about this one.

@TheBB
Copy link
Collaborator

TheBB commented Oct 7, 2015

Anyway, for vimmers who want to get into using REPLs in Emacs, you might as well get into the habit of almost always entering insert state in a REPL with a or A, and not to use i.

@TheBB
Copy link
Collaborator

TheBB commented Oct 7, 2015

Sorry for spam. :-)

This is also an option:

(add-hook 'haskell-interactive-mode-hook
          (lambda ()
            (setq-local evil-move-cursor-back nil)))

@PierreR
Copy link
Contributor Author

PierreR commented Oct 7, 2015

Anyway, for vimmers who want to get into using REPLs in Emacs, you might as well get into the habit of almost always entering insert state in a REPL with a or A, and not to use i.

@TheBB I would not mind but can we at least open the repl in the "right" default mode (edit with A) after the haskell-interactive-switch ?

That's what is happening when you open a shell in emacs IIRC (you are in insert mode by default)

@d12frosted
Copy link
Collaborator

@TheBB

(add-hook 'haskell-interactive-mode-hook
          (lambda ()
            (setq-local evil-move-cursor-back nil)))

Wow. This is really an option! I was thinking about checking if cursor is on the line that begins with λ and moving cursor to the λ _ if it's inside of λ. But probably this is a good workaround. What do you think?

About a - it's really working. When you press a it moves to insert mode and (!) places cursor at the right place (if you are at λ_).

I would not mind but can we at least open the repl in the "right" default mode (edit with A) after the haskell-interactive-switch ?

It's opening with insert mode for me. But that's probably because I use emacs editing style. I'll check that tomorrow.

@PierreR
Copy link
Contributor Author

PierreR commented Oct 7, 2015

Thank so much for checking all this. While we are on the subject what should I do to have a beautiful λ>. It looks like this for me:

lambda

@d12frosted
Copy link
Collaborator

Well, that looks bad. What font are you using?

@PierreR
Copy link
Contributor Author

PierreR commented Oct 7, 2015

Well you know what. You asking me this question makes me check about the font I thought I was using ... And for some reason, it was not installed.

So thanks 😊

@d12frosted
Copy link
Collaborator

Then I did a right thing to ask you about font before asking you to open separate issue for this 😄

@d12frosted
Copy link
Collaborator

I've added more tips on how to ease the burden for evil users with haskell REPL in #3325. @PierreR you might be interested in them 😄

@d12frosted
Copy link
Collaborator

@TheBB What do you think about this issue? I know that you wanted it to be fixed, instead of just being documented, but... It looks like it's just a matter of using workaround or just being cautious about where you type.

@PierreR
Copy link
Contributor Author

PierreR commented Oct 12, 2015

Why not changing layers/+lang/haskell/packages.el to

  • force the insert mode by default (this is what a SPC ' is doing)
  • (setq-local evil-move-cursor-back nil)

as suggested in the help ?

@d12frosted
Copy link
Collaborator

I created PR #3292 that makes what you suggest. But after short discussion I thought that it's better to leave this option to users, since doing both things is an over kill. But different users might prefer different workarounds for this problem. Some might want to set evil-move-cursor-back to nil, while others might want to always start REPL in insert-mode. Also, since there is no much interest in this issue - I think it could be enough to just place possible workarounds in the README file.

@PierreR
Copy link
Contributor Author

PierreR commented Oct 18, 2015

I will close it then. Thanks for the support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants