-
Notifications
You must be signed in to change notification settings - Fork 347
Support simple completions in non-interactive context. Support keyword completions #1172
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 simple completions in non-interactive context. Support keyword completions #1172
Conversation
Denote internal nature of this variable by double dash
I'm modifying REPL completion function right now and can push few commits here. |
Good stuff. Can you remove these things from |
Ok it looks like it works properly. One thing I haven't checked is that REPL completion function should take precedence to simple completion function in @gracjan didn't catch your point about interactive mode, what should I remove? (: This one haskell-mode/haskell-interactive-mode.el Lines 1035 to 1045 in 371c87d
|
haskell-completions-ghc-option-prefix | ||
haskell-completions-language-extension-prefix)) | ||
;; provide simple completions | ||
(haskell-completions--simple-completions prefix-data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I understand there will be two completions hooks installed at the same time, one by haskell-mode
other by interactive-haskell-mode
. The non-interactive one will return completions for PRAGMA, GHC_OPTION and LANGUAGE, so there is no need to return those completions here again.
Unless I'm mistaken how the mechanism works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gracjan I tested this, and if first function in hook returns nil
there will no completions. I tested this creating two dummy completion functions and added both of them to completion-at-point-functions
hook in elisp mode. All time only first function was used to return completion candidates. I don't know why it works this way though.
(defun complete-ab ()
(let ((end (point)))
(save-excursion
(backward-word)
(when (looking-at "ab")
(let ((start (point)))
(list start end '("abcde" "abcdf" "abcdef")))))))
(defun complete-other ()
(let ((end (point)))
(save-excursion
(backward-word)
(let* ((start (point))
(word (buffer-substring start end)))
(list start end '(concat word "123"))))))
(add-hook 'completion-at-point-functions #'complete-other nil t)
(add-hook 'completion-at-point-functions #'complete-ab nil t)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've repeated this experiment and it works like described in Emacs docs (and unlike you say). That means I'm able to complete "1" to "123" and "ab" to any of the options listed. Emacs seems to work correctly.
As for UPDATE: I have already implemented such support and indeed substituting UPDATE: finally, I think we can leave |
Should the hardcoded completions have extra information for support for I was thinking that you could make new giant alists so that |
@fice-t hmm, I didn't catch your idea, if we do have such list already why we need another one? Can you clarify? |
I wonder how useful the hints by haskell-doc-mode are. Old timers know basic language constructs by heart, can newbies sort out keyword usage from the very short descriptions provided by haskell-doc-mode? |
I like doc messages for top-level forms, but keyword doc strings seem for me quite confusing :D |
By the way, @gracjan in Emacs 25 I have colored message in mini-buffer from |
The lists are old as they're for Haskell-98. According to git they haven't been updated in over a decade. |
@fice-t I agree, I saw that before, I just do not understand what benefits of extra information in hard-coded lists? |
The extra information would be used in
So it's just using the same list for different purposes. |
@fice-t, pal, I'm still confused. Look, |
Make use of implemented simple completion funciton. Complete keywords.
I still think the static and the interactive completion functions should be completely separate. For the interactive case there should be only For the static case there should be only Emacs will call the hooks one by one, stopping with the one that returns non-nil value. This seems perfectly reasonable to me. Am I missing something? |
@gracjan sounds reasonable, but you forgot about keywords in static case
Can you please test this (as I mentioned before in my tests second completion function was not triggered when first one returned |
That's why I'm saying this. I'm saying (I believe) there could be a single list which both completion and hints could use in some cases, such as keywords and basic/Prelude functions. That might be beneficial as one could maintain just a single list (and periodically generate a separate completion list if one was to speed completion up).
Yeah, |
@fice-t ok, now I got it :D |
@gracjan this is my thought about your proposal.
|
@geraldus: I think you convinced me that Emacs default handling of In this case you should implement it as you have done. Ping me when the PR is ready to merge. |
Support simple completions in non-interactive context. Support keyword completions
Related #1171