-
Notifications
You must be signed in to change notification settings - Fork 75
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 querying subprocess for completion. #119
Conversation
Another note is that this almost works for completion in the lua subprocess buffer, except evaluating the string to determine the completions causes the prompt to be re-printed, which throws off the function which inserts the completions. If there were a way to suppress the re-printing of the prompt, it would solve that problem. |
Hi and thank you for a PR for a long waited feature. |
lua-mode.el
Outdated
@@ -769,6 +769,9 @@ Groups 6-9 can be used in any of argument regexps." | |||
(setq mode-popup-menu | |||
(cons (concat mode-name " Mode Commands") lua-emacs-menu))) | |||
|
|||
(make-variable-buffer-local 'completion-at-point-functions) |
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.
For making other people's variables local just in this mode it's better to use make-local-variable
.
I have been meaning to integrate Jupyter for REPL purposes for ages, but never had time for it. Your solution has the undeniable benefit of not having any extra dependencies and may work for now. One thing though is that I'm not very comfortable accepting it without any tests. Could you add some? |
lua-mode.el
Outdated
|
||
Queries current lua subprocess for possible completions." | ||
(let* ((start-of-expr (save-excursion | ||
(search-backward-regexp "[^\.a-zA-Z0-9_]") (point))) |
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.
Does it handle :
as binding attribute reference (or whatever is it actually called in Lua)? Can it?
Same questions for whitespace between components? E.g.
my_super_long_variable_name.
super_long_attribute_name
I've made all the changes you suggested, though the last one was pretty tricky! I took a look at adding tests, and I am not really even sure how to run the tests that are included so far. I avoid elpa/melpa for security reasons since Emacs cannot safely make TLS connections (https://glyph.twistedmatrix.com/2015/11/editor-malware.html); I tried to get the tests to run by downloading buttercup manually but didn't have any success with that. Do you have any recommendations for how that would work? |
Great, thank you!
Woah, thank you for the heads up, never came up to me that Emacs is that careless.
There's |
There's package-install-file function that could be run on a local tar
archive, will that work for you?
Oh, sorry that wasn't clear--I am able to install buttercup just fine;
it's just that I can't figure out how to run the tests since the
Makefile assumes Cask is installed, and I don't want to install Cask
since it looks very insecure.
Is there a way I can run the tests independently? The only interactive
function from buttercup I see is buttercup-run-at-point, but I want to
run all the tests.
|
Something like this should work:
|
Oh, of course. I was looking for interactive functions; should have
known it would run from the shell instead.
I added some tests, both for the standard completion and the one that
scans for local requires.
|
I'll do my best to find time to give it a spin on the weekend and merge, thank you for your effort. |
Completion on an expression at the beginning of a buffer now works.
This allows it to work in the *lua-repl* buffer.
Helps it work with certain less-intelligent repls.
Hi! Apologies for my replies that take eternity, I rebased it, tried it around a bit, done a couple of changes in https://github.com/immerrr/lua-mode/tree/pr-119, feel free to reset your head on top of it or use it as a reference. Aside from that, it looks great, thank you! Have you signed an FSF copyright assignment by chance? |
Whoops, I seem to have broken something with my changes... |
I am seeing breakage, but it's not related to your change. It's when you try to do completion at the end of a function and you get I have signed copyright paperwork; is lua-mode going to be integrated into Emacs? That's great news. I realized that this code could be improved a fair bit by including top-level locals in the completion targets; would you like me to add that on your branch along with the bug fix? |
I was trying to replace
That was the intention a while ago. There's still a big blocker in the shape of the indentation engine, that comes from the ages when no one cared about copyright assignments, but I'm trying to at least avoid creating more. Although the way Emacs development goes right now, in all likelihood the only win would be putting
That would be nice to have. And you don't have to rush it to get to this PR. |
…input. Good grief, `last' returns a list, not a list element?
Added a bugfix as well as the top-level locals onto your |
CI still seems to fail, do you see how to fix it? |
Seems like this was so close to completion (hah). Any chance to integrate this PR and roll out a new release? Thanks for lua-mode. |
@jdtsmith I am all for it, but unfortunately don't have time to debug this. |
I found a few issues with @technomancy's PR and generated a new corrected PR #147. |
Looks like this one is no longer needed; thanks for taking it over! |
Fixes #87.
I ended up disabling the feature that pulls completion targets from locals by default since it can cause unexpected side-effects, but it's documented in the readme how to turn it on.