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

Tab completion #391

Closed
wants to merge 18 commits into from
Closed

Tab completion #391

wants to merge 18 commits into from

Conversation

hoelzro
Copy link
Contributor

@hoelzro hoelzro commented Mar 19, 2015

Do NOT merge me! I'm not ready yet!

This adds the linenoise changes from the no-linenoise branch (and thus depends on the corresponding NQP and MoarVM changes), in addition to some rudimentary tab completion.

How rudimentary is it? Read on...

  • The list of completions is hardcoded to the list of classes, roles, and function in OUTER::OUTER from a Perl 6 script, because my Perl 6 introspection fu is weak. Ideally it should get its list from the REPL's context.
  • It relies on Linenoise.pm being installed, and that's not indicated in the README. Maybe we should bundle it with Rakudo, or maybe just with Star.
  • Linenoise.pm depends on linenoise being installed on your system; it doesn't bundle it.
  • linenoise doesn't work out of the box on MoarVM, since MoarVM sets standard input to non-blocking. I used a patched version of linenoise to get around this, but Linenoise.pm should probably do something about that. Either that, or maybe MoarVM shouldn't set standard input to non-blocking; I don't know if that's a good idea or not.
  • Completion is provided as a module; I don't know the best way to include the completion function in Perl6::Compiler otherwise, since the former is in Perl 6, and the latter is in NQP.
  • The way Perl6::Compiler loads Linenoise.pm and gets symbols from it is atrocious.
  • The completion function should also complete variables, attributes, and methods if possible.
  • The completion function is coupled to linenoise; it should probably just return a List of completions.

@moritz
Copy link
Member

moritz commented Mar 19, 2015

sounds like a good proof of concept, but not mergable yet (due to Linenoise.pm/linenoise deps), but still, good work!

@hoelzro
Copy link
Contributor Author

hoelzro commented Mar 20, 2015

I should add that the REPL will still work without Linenoise.pm; tab completion just doesn't.


$!completions := nqp::hash();

my $core_keys := self.eval('CORE::.keys');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't care for this, but I don't know how else to get access to CORE.

@FROGGS
Copy link
Member

FROGGS commented Apr 16, 2015

I just merged nqp/master into nqp/no-readlineint and nom into this branch, but get:

$ perl6-m --ll-exception
> 1
1
This type does not support elems
   at src/Perl6/Compiler.nqp:7  (/home/froggs/dev/nqp/install/share/nqp/lib/Perl6/Compiler.moarvm:sorted_set_insert:10)
 from src/Perl6/Compiler.nqp:217  (/home/froggs/dev/nqp/install/share/nqp/lib/Perl6/Compiler.moarvm:readline:116)
 from gen/moar/stage2/NQPHLL.nqp:1179  (/home/froggs/dev/nqp/install/share/nqp/lib/./NQPHLL.moarvm::26)
 from gen/moar/stage2/NQPHLL.nqp:1176  (/home/froggs/dev/nqp/install/share/nqp/lib/./NQPHLL.moarvm:interactive:90)
 from src/Perl6/Compiler.nqp:201  (/home/froggs/dev/nqp/install/share/nqp/lib/Perl6/Compiler.moarvm:interactive:22)
 from gen/moar/stage2/NQPHLL.nqp:1360  (/home/froggs/dev/nqp/install/share/nqp/lib/./NQPHLL.moarvm:command_eval:166)
 from src/Perl6/Compiler.nqp:59  (/home/froggs/dev/nqp/install/share/nqp/lib/Perl6/Compiler.moarvm:command_eval:93)
 from gen/moar/stage2/NQPHLL.nqp:1337  (/home/froggs/dev/nqp/install/share/nqp/lib/./NQPHLL.moarvm:command_line:116)
 from src/gen/m-main.nqp:39  (/home/froggs/dev/nqp/install/share/perl6/runtime/perl6.moarvm:MAIN:18)
 from src/gen/m-main.nqp:35  (/home/froggs/dev/nqp/install/share/perl6/runtime/perl6.moarvm:<mainline>:197)
 from <unknown>:1  (/home/froggs/dev/nqp/install/share/perl6/runtime/perl6.moarvm:<main>:8)
 from <unknown>:1  (/home/froggs/dev/nqp/install/share/perl6/runtime/perl6.moarvm:<entry>:9)

@FROGGS
Copy link
Member

FROGGS commented Apr 16, 2015

This seems to fix it, though @hoelzro can you take a look at merging both .interactive methods?

@@ -215,7 +214,7 @@ class Perl6::Compiler is HLL::Compiler {
                 if $m {
                     my $word := $m<word>;
                     unless $word ~~ /^ "&" <.upper>+ $/ {
-                        sorted_set_insert($!completions, $word);
+                        sorted_set_insert($!completions, $word) if $!completions;
                     }
                 }
             }

@hoelzro
Copy link
Contributor Author

hoelzro commented Apr 16, 2015

@FROGGS Thanks for looking at this; I'll fix this up right away!

@hoelzro
Copy link
Contributor Author

hoelzro commented Apr 16, 2015

@FROGGS I merged the interactive methods and fixed up the code to be based on nom.

@FROGGS
Copy link
Member

FROGGS commented Apr 22, 2015

$ perl6
> say 42
42
===SORRY!===
This type does not support elems
$ perl6 --ll-exception
> say 42
42
This type does not support elems
   at src/Perl6/Compiler.nqp:7  (blib/Perl6/Compiler.moarvm:sorted_set_insert:10)
 from src/Perl6/Compiler.nqp:214  (blib/Perl6/Compiler.moarvm:readline:116)
 from gen/moar/stage2/NQPHLL.nqp:1202  (/home/froggs/dev/nqp/install/share/nqp/lib/NQPHLL.moarvm::26)
 from gen/moar/stage2/NQPHLL.nqp:1199  (/home/froggs/dev/nqp/install/share/nqp/lib/NQPHLL.moarvm:interactive:90)
 from src/Perl6/Compiler.nqp:151  (blib/Perl6/Compiler.moarvm:interactive:26)
 from gen/moar/stage2/NQPHLL.nqp:1383  (/home/froggs/dev/nqp/install/share/nqp/lib/NQPHLL.moarvm:command_eval:166)
 from src/Perl6/Compiler.nqp:59  (blib/Perl6/Compiler.moarvm:command_eval:93)
 from gen/moar/stage2/NQPHLL.nqp:1360  (/home/froggs/dev/nqp/install/share/nqp/lib/NQPHLL.moarvm:command_line:116)
 from src/gen/m-main.nqp:39  (/home/froggs/dev/nqp/install/share/perl6/runtime/perl6.moarvm:MAIN:18)
 from src/gen/m-main.nqp:35  (/home/froggs/dev/nqp/install/share/perl6/runtime/perl6.moarvm:<mainline>:197)
 from <unknown>:1  (/home/froggs/dev/nqp/install/share/perl6/runtime/perl6.moarvm:<main>:8)
 from <unknown>:1  (/home/froggs/dev/nqp/install/share/perl6/runtime/perl6.moarvm:<entry>:9)
froggs@TL02L-R8RXTCW-linux:~/dev/rakudo$ git show
commit 8dfe790d3f0dfc424d3685f5c6b1a3e734ba6b9a
Author: Rob Hoelz <rob@hoelz.ro>
Date:   Thu Apr 16 18:33:41 2015 -0500

    Return null string (instead of undefined) if linenoise is done

It doesn't make sense unless we have a tab completion facility
@hoelzro hoelzro closed this Apr 24, 2015
@hoelzro hoelzro deleted the tab-completion branch April 24, 2015 12:18
AlexDaniel added a commit that referenced this pull request Jan 20, 2018
NQP bump brought: Raku/nqp@2017.12-63-gd93f6ed...2017.12-79-g4d3db7f00
4d3db7f00 [MoarVM Bump] Brings 25 commits
594dc7abf Fix number of skipped tests
98aedda0b Add a few tests that grammars match graphemes
3f1d425b3 [js] Make cclass in regexes match full graphemes
ae09ff182 [js] Make enumcharlist match full graphemes
89aadbb00 [js] Make uniprop matching match full graphemes
a45bfea40 Fix dumping block with null_s cuids
734b9e5e0 Add test descriptions
2f362439a Merge pull request #394 from tbrowder/pod-tests
f64e981aa add new pod tests
a76455f2c Merge pull request #391 from dwarring/cursor_init-tweak
3a9a497db remove unreachable code in cursor_init
92730bfef Add a few div_In tests
46cf36712 Fix typo in test description
c266fcdaa [js] Fix nqp::div_In
0ed57f6f8 [js] Handle the DYN_COMP_WRAPPER hack on the js backend too
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.

None yet

3 participants