Elvish: Add API for inserting autosuggestion

Created on 31 Oct 2017  Â·  8Comments  Â·  Source: elves/elvish

This would look like the autosuggestion in fish. It would print some text after the current buffer of readline with diminished colouring, and readline wouldn't return this text.
For example:

~/code > _nvim /a/long/pa|__th/to/a/file.txt_

The cursor is at the | sign. The text after the cursor would be printed to the line with decreased intensity, but if the user hits return, only the following text would be returned: nvim a/long/pa.
This would make possible implementing Elvishscript programmable autosuggestion in multiple ways: history only, or completion, or most often used command lines or files/directories, etc.
Also, it would make easy to implement completion help:

~/code > _ffmpeg_| _(global_opts) (input_file_opts) (-i input_file) (output_file_opts) (output_file)_

and thousands of other things.
This would make possible to solve #395, #396, #322 in Elvishscript.

Most helpful comment

Does fish have to do it in order for elvish to do it ?

On 19 Jan 2018 13:29, "Olivier Perret" notifications@github.com wrote:

autocompletion in more than one place sounds quite complex, can fish do it?

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/elves/elvish/issues/507#issuecomment-358940353, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AF7UBxDSpgBrXanmViBW3_C2GIBUHgrlks5tMHyEgaJpZM4QMwMz
.

All 8 comments

I changed the title. This sounds like a good way to implement autosuggestion.

  • It should support markup (underline, diminished, bold, italic).
  • It should be able to complete at more than one place:
    initial text:
    ~/code > kak ne/src/n/pa.cr
    autocompletion in more than one place:
    ~/code > kak ne_ph_/src/n_eph_/pa_rser_.cr
  • The cursor mustn't be placed on this text, because it isn't real input.

autocompletion in more than one place sounds quite complex, can fish do it?

Does fish have to do it in order for elvish to do it ?

On 19 Jan 2018 13:29, "Olivier Perret" notifications@github.com wrote:

autocompletion in more than one place sounds quite complex, can fish do it?

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/elves/elvish/issues/507#issuecomment-358940353, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AF7UBxDSpgBrXanmViBW3_C2GIBUHgrlks5tMHyEgaJpZM4QMwMz
.

@occivink
Elvish is not a fish copy, so the autocompletion shouldn't be a fish copy.
I think these things are that make Elvish more powerful than other shells.

I never was implying this, I just wanted to know if fish did it and what kind of interface they might have

Of course we want Elvish to be more powerful than other shells, everyone is on the same page :)

However, fish's autosuggestion works well because it only appends at the end of the input, which makes it non-intrusive: you can accept it when it is useful, but when it is not, it does not get in your way. But if we start inserting autosuggestions in arbitrary places, it can get distracting. @notramo, do you already have thoughts of how to make this work?

It would be used mostly for fuzzy completions: fuzzy path matching, or fuzzy history matching.
Similar to fzf: it highlights matched text (this would be the real input in Elvish) and don't highlights the non-matched text (this would be the autosuggestion).

Was this page helpful?
0 / 5 - 0 ratings