-
Notifications
You must be signed in to change notification settings - Fork 345
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
Support presentaion mode by haskell-mode-show-type-at
#598
Conversation
@chrisdone asked me to make it optional
If I understood him correctly he talked about possibility to have an option not to use presentation mode when displaying type, even if Documentation of
So, this variable is a kind of global option, i.e. use presentation mode for everything. The only idea I have to optionally disable presentation mode for arbitrary functions is to define some variables and make presentation mode checks slightly smarter (hence complex). So I need some feedback and guidance how to deal with this. |
BTW, I used same style as in |
Hmm, can we do a proper cleanup while we are at touching presentation mode? As far as I see This is async-pretending-to-be-sync. As example of other way of doing similar thing lets look at I think |
Surely, in fact to implement this functionally I've used |
I don't understand well things like |
@gracjan, it turns that xs :: [a] -> IO ()
xs = mapM_ print As you already mentioned it is blocking operation. I assume it will be good to make |
Here my new implementation. I've implemented two new functions:
Now, if Small notice: (make-haskell-command
:state (list process line mode)
…)
|
One caveat: surprisingly, I forgot to show type information when |
Good stuff! Especially the I could merge this as is, but we can improve this even further, shall we? How about this: Lets add a flag saying How to detect if nothing has changed in the buffer? That is a bit tricky, basically it is 1) set a flag saying that nothing has changed so far 2) add So the full algorithm:
Note: that everything will be async and will never render Emacs unusable. Any user command will have the function of Note also that similar functionality can be used for other synchronous commands. What do you think? |
One more question: there is also such functions as Update: that functions use another REPL command — |
@gracjan original function is |
I tried to put
and them does not appear in Also, I've added messages before adding hook, which makes obvious that |
Hmm, you should not be setting
Then I added this:
And then I got:
So everything look super good to me. Am I mistaken? If (Note: one more thing to sort out is when |
@geraldus: |
@gracjan, as for y :: IO ()
y = let x = mapM_ print in x [1, 2, 3] |
@gracjan huh! cool trick with
And what about several command launced simultaneously: we can make our flag to be a map (like in haskell, I believe this is |
@gracjan, ok, I was managed to introduce flag as |
@gracjan I've uploaded pre-final version of code. Almost everything works fine, but there is issue with regions: original (sync) version of function will wrap region with parentheses and append to expression inferred type, e.g. Also, I need to test how things work when process returns error message. |
@gracjan please review code and especially doc strings. I'm going to have 4 commits in the end:
|
+ hs-utils/capture-expr-bounds + hs-utils/compose-type-at-command + hs-utils/reduce-string + hs-utils/insert-type-signature + hs-utils/echo-or-present
Issue: eval |
Defined buffer local flag `hs-utils/async-post-command-flag` Defined flag related functions: + hs-utils/async-update-post-command-flag + hs-utils/async-watch-changes + hs-utils/async-stop-watching-changes
Make function asyncronous, remove unnecessary synchronous `haskell-mode-type-at` function. Insert type signature only if nothing changed and there was valid response. Present result in case of presentation mode, otherwise put it in echo area. Do not present result if asked to insert result.
Support presentaion mode by `haskell-mode-show-type-at`
Make
haskell-mode-show-type-at
function aware of presentation mode.Refactored code a bit: bind multiple occurances of
(haskell-fontify-as-mode ty 'haskell-mode)
to variablefty
.