Hi,
It’s inconvenient because if you type
Hello or world: he
orHello or world: wo
and presstab
the tab-completion stops working. Also, the input string gets into the functionexpand_fun()
as a reversed string.
It might be inconvenient in your usecase, but for the shell its great, because then you always have the latest word (before the cursor) in the beginning of the string: “ow olleh”.
- If you want to set it back to the default expand function again you can do it like this
io:setopts([{expand_fun, fun edlin_expand:expand/2}]),
The list of possible expansions can be formatted in different ways to make more advanced expansion suggestions more readable to the user,
This is something documented in the later paragraphs of expand/2, and basically makes it possible to format your suggestions:
{no, "", "#{title := "*** Suggestions ***", elems := ["hello", "world"]}}
hello or world: he<tab>
*** Suggestions ***
hello world
- Your second function above already solves your usecase.
- Bef0 is a bit cryptic, but it stand for Before, The text before the cursor (in reverse).
- We needed edlin_expand:expand/3 in a test suite, to set a custom shell state. It being undocumented means that it should not be used outside OTP.
Hope that helps, let me know if you have more questions!