Skip to content

Completion mechanics haskell-completions-grab-prefix implementation #688

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

Merged
merged 7 commits into from
Jun 18, 2015
Merged

Completion mechanics haskell-completions-grab-prefix implementation #688

merged 7 commits into from
Jun 18, 2015

Conversation

geraldus
Copy link
Contributor

@geraldus geraldus commented Jun 2, 2015

This is long story. I want to make some improvements on completion stuff.
I will add changes step by step because a bit short in time and made this PR to have some feedback and help.

@geraldus
Copy link
Contributor Author

geraldus commented Jun 2, 2015

Function haskell-grab-pragma-or-ghc-option-prefix handles all stuff described here, and also returns prefixes for pragma names itself, e.g.
{-# OP|OP
{-# LANG|LANG
I've merged this functionality, because both cases occurs inside {-# #-} comment.

Any thought about how to make it a bit readable?

@geraldus
Copy link
Contributor Author

geraldus commented Jun 4, 2015

@gracjan updated

@geraldus
Copy link
Contributor Author

geraldus commented Jun 4, 2015

the rest should be easier, but I want to fix presentation buffer first

otherwise returns nil."
;; TODO Discuss this. In some cases it is better to provide completions if
;; point is not at whitespace, for example when point is at closing
;; parenthesis: (ma|) - point is after `a` character.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In some cases it is better to provide completions if point is not at whitespace, for example when point is at closing parenthesis: (ma|) - point is after a character. Any thoughts?

@geraldus
Copy link
Contributor Author

geraldus commented Jun 6, 2015

Well, I believe I've covered all prefix cases originally defined here1. Now I can write a general function for grabbing prefix at point which first invokes pragma-prefix function and if its result is nil it returns the result of identifier-prefix function.

And after that I can update completions at point function: split it to synchronous and asynchronous ones.
Synchronous function will operate like existing CAP-function, and asynchronous can provide all completions using REPL, i.e. provide completions for GHC options and language extensions running :complete repl ":set <prefix>".

Have any thoughts?

@gracjan
Copy link
Contributor

gracjan commented Jun 6, 2015 via email

@geraldus
Copy link
Contributor Author

geraldus commented Jun 8, 2015

A little progress here

@gracjan
Copy link
Contributor

gracjan commented Jun 8, 2015

Are there some commits here that you could spin-off as a separate pull request? This is getting rather big...

@geraldus
Copy link
Contributor Author

geraldus commented Jun 8, 2015

@gracjan I think I'm done with prefixes, can you review everything that done so far and it is could be merged after squashing some commits. The next part is to update completion functions (still some research needed).

I have no strong opinion on some key points though:

  1. Currently, all grabbing functions return nil if mark is activated.
  2. Should completion list be provided when typing in the middle of word?

@@ -0,0 +1,189 @@
;;; haskell-completions.el --- Haskell Completion package

;; FIXME copyright (c) 2015 Haskell mode community. All rights reserved.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it okay to reserve copy rights to community rather than a person?

@geraldus
Copy link
Contributor Author

geraldus commented Jun 9, 2015

@gracjan I think GPL licence itself (COPYING file) could be spinned-off. Also if GPL is the preferrable licensing method it would be nice to have some notice about licensing on Contributing page.

@gracjan
Copy link
Contributor

gracjan commented Jun 10, 2015

Overall this looks good to me. Tests provide assurance that this also works.

License stuff got merged in another commit, so it can go away. Please squash what is there to squash.

(Note: when you commit you can use git commit --squash COMMITID that will generate specially formatted commit message for commits that are supposed to be squashed.)

@geraldus
Copy link
Contributor Author

@gracjan I will tidy up things this evening, however, I'm still have no strong opinion about completions in the middle of strings. Initially I've decided not to grab prefixes in the middle of string (hence no completions in this case) being influenced by some comments in company-mode sources1. But, when I write Elisp code company-mode works even in the mid of the word and it feels quite comfortable and useful, so this was wrong decision from the very beginning and provide no completions in the middle of string is likely a misfeature.

Now I'm leaning to other direction, but I don't know and can't recall how completions provision works in other packages (like auto-complete) and/or in other editors/IDEs _(I can check how Sublime works in the evening).

@gracjan
Copy link
Contributor

gracjan commented Jun 11, 2015 via email

@geraldus
Copy link
Contributor Author

OK, I've tested Sublime Text and it does not completes in the middle of string, so does company-mode with elisp code. But them both provide completions when point is at punctuation, e.g. co|), com|,, comp|., and etc, and we really need it too for haskell-mode (currently it's not supported).

I also want to have completions inside comments and string literals, this is one of the reasons of my efforts on completion improvements. Currently, it is possible to grab prefix inside comments and strings, but I think I need to implement special completion type for these cases, e.g. 'haskell-completions-literal-prefix. I plan to make some hacking around dabbrev-expand function to get completions in this case, and as a free bonus we'll have a completions for local identifiers (in let blocks) and newly added things with unsaved buffer.
If I'm not mistaken REPL does not provide completions for local identifiers, also it is required to reload file to have completions for things added since last load. Similarly, it is required to save buffer when completions come from TAGS file.

As for quasi-quotes, my current haskell workflow have lot of them, so if it's possible to make QQs support a bit better I'd love to have it. But I have nothing to say about this stuff yet.

@geraldus geraldus mentioned this pull request Jun 11, 2015
@geraldus
Copy link
Contributor Author

pinging @gracjan, please review carefully final update

@gracjan
Copy link
Contributor

gracjan commented Jun 17, 2015

Code is nice, can be merged as is. Do you anything more you want to do about this?

How can I see this working besides of unit tests?

@geraldus
Copy link
Contributor Author

@gracjan nope, this is supposed to be merged as is, the next PR will touch completion functionality itself. I'm testing this stuff manually running M-: (haskell-completions-grab-prefix), etc. at various places of arbitrary haskell file.

@gracjan gracjan changed the title Completion mechanics improvements [WIP] Completion mechanics haskell-completions-grab-prefix implementation Jun 18, 2015
gracjan added a commit that referenced this pull request Jun 18, 2015
Completion mechanics haskell-completions-grab-prefix implementation
@gracjan gracjan merged commit c1f9e6b into haskell:master Jun 18, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants