Now that es script can be run while reading shell input, we should actually do that in $&readline.
The obvious candidates are programmable tab completion and arbitrary key bindings.
I played around with a simple version of tab completion in https://github.com/jpco/es-shell/blob/palloc/ (see completion.es and the completions directory). It's just a demo really, and doesn't have some nice features like good handling for GNU-style --foo=bar long opts, but at least one nice quality of it is that it really only has one hook function, %complete (or two, if you include %completion-to-file). This makes it so that completion functions can call each other, and can call the "root" %complete hook function, recursively, which is all pretty useful in a language like es where commands are often arguments to other commands.
For programmable tab completion in particular, it would be very good to make the es-written parts of tab completion suitable for use with different line editing libraries. I know that a lot of people are, reasonably, not fond of readline, but it's entire heap of work to create a tab-completion "library", so designing tab-completion to work with readline alternatives would be a virtue.
One of the big pitfalls of the tab-completion demo above is that it's not really syntax-aware. For example, suppose you have a function in which takes a directory and a command and cds to that directory just for the duration of executing the command. The following should all have the same completion behavior:
; in ~ ls .[TAB]
; in ~ (ls .[TAB]
; in ~ {ls .[TAB]
; in ~ { ls .[TAB]
Resolving that shortcoming "completely" would probably be hard, requiring a new, incremental parser and some kind of good user-facing design for iterating through a half-written command. I'm not convinced that a syntactically-aware solution should be a requirement to design and implement before getting, say, the ability to tab-complete words in first-position.
If anybody has more ideas for programmable interactive integration, I'm all ears. I'm going to play around with this for a while before proposing anything in particular.
Now that es script can be run while reading shell input, we should actually do that in
$&readline.The obvious candidates are programmable tab completion and arbitrary key bindings.
I played around with a simple version of tab completion in https://github.com/jpco/es-shell/blob/palloc/ (see completion.es and the completions directory). It's just a demo really, and doesn't have some nice features like good handling for GNU-style
--foo=barlong opts, but at least one nice quality of it is that it really only has one hook function,%complete(or two, if you include%completion-to-file). This makes it so that completion functions can call each other, and can call the "root"%completehook function, recursively, which is all pretty useful in a language like es where commands are often arguments to other commands.For programmable tab completion in particular, it would be very good to make the es-written parts of tab completion suitable for use with different line editing libraries. I know that a lot of people are, reasonably, not fond of readline, but it's entire heap of work to create a tab-completion "library", so designing tab-completion to work with readline alternatives would be a virtue.
One of the big pitfalls of the tab-completion demo above is that it's not really syntax-aware. For example, suppose you have a function
inwhich takes a directory and a command andcds to that directory just for the duration of executing the command. The following should all have the same completion behavior:Resolving that shortcoming "completely" would probably be hard, requiring a new, incremental parser and some kind of good user-facing design for iterating through a half-written command. I'm not convinced that a syntactically-aware solution should be a requirement to design and implement before getting, say, the ability to tab-complete words in first-position.
If anybody has more ideas for programmable interactive integration, I'm all ears. I'm going to play around with this for a while before proposing anything in particular.