edlin_expand(3)
okay bestie, welcome to edlin_expand β the Erlang module definition page that makes your shell β¨go offβ¨. Buckle up, we're doing expansion theory and it's honestly iconic.
πΈ NAME πΈ
edlin_expand β shell expansion and formatting of expansion suggestions.
β¨ DESCRIPTION β¨
So this module hands you an expand_fun for the erlang shell's expand/1,2. And get this β you can absolutely override that expand_fun with io:setopts/1,2. Main character energy: you decide how your shell expands. π
π EXPORTS π
expand(Bef0) -> {Res, Completion, Matches}
expand(Bef0, Opts) -> {Res, Completion, Matches}
Types:
Bef0 = string()
Opts = [Option]
Option = {legacy_output, boolean()}
Res = yes | no
Completion = string()
Matches = [Element] | [Section]
Element = {string(), [ElementOption]}
ElementOption = {ending, string()}
Section =
#{title := string(),
elems := Matches,
options := SectionOption}
SectionOption =
{highlight_all} |
{highlight, string()} |
{highlight_param, integer()} |
{hide, title} |
{hide, result} |
{separator, string()}
The standard expansion function is literally able to expand strings into valid erlang terms. We're talking module names:
1> erla
modules
erlang:
function names:
1> is_ato
functions
is_atom(
2> erlang:is_ato
functions
is_atom(
function types:
1> erlang:is_atom(
typespecs
erlang:is_atom(Term)
any()
...and it'll automatically add , or a closing parenthesis when there's no other valid expansion possible. Not me being impressed by auto-close π«Ά. The expand function also completes: shell bindings, record names, record fields and map keys.
Okay so check this out β function headers get grouped together when they've got the same expansion suggestion. In the example below, all of them had the same suggestion, that is '}'. There's also limited support for filtering out function typespecs that don't match the types on the terms sitting on the prompt. Only 4 suggestions show up below, but bestie, there are plenty more typespecs for erlang:system_info. π
1> erlang:system_info({allocator, my_allocator
typespecs
erlang:system_info(wordsize | {wordsize, ...} | {wordsize, ...})
erlang:system_info({allocator, ...})
erlang:system_info({allocator_sizes, ...})
erlang:system_info({cpu_topology, ...})
}
The return type of the expand function specifies either a list of Element tuples or a list of Section maps. The whole section concept was introduced to unlock more formatting options for your expansion results. For example, shell expansion has support for highlighting text and hiding suggestions. There's also a {highlight, Text} that highlights all occurances of Text in the title, plus a highlight_all for when you want it simple β that one highlights the whole title, exactly like you can see above for functions and typespecs. β¨
By setting the {hide, result} or {hide, title} options you may hide suggestions. Sometimes the title just isn't useful and produces text noise, no cap β in the example above, the any() result is part of a section with title Types. Hiding results is currently not in use, but the idea is that a section can be selected in the expand area and all the other section entries should be collapsed.
ngl that's a whole vibe waiting to happen.
It's possible to set a custom separator between the title and the results. Do that with {separator, Separator}. By default it's set to be \n, and some results display a type_name() :: followed by all types that define type_name().
The {ending, Text} ElementOption just appends Text to the Element. Simple as that. π
and that's the whole page, bestie β brought to you by the legends at Ericsson AB, running stdlib 5.2.3.6, and this little gem is edlin_expand(3). go forth and expand, you absolute icon ππ
π¦ where this page comes from
- fedora 43: erlang-stdlib 26.2.5.21-8.fc43 Β· Apache-2.0
- fedora 44: erlang-stdlib 26.2.5.18-1.fc44 Β· Apache-2.0
- fedora 44: erlang-stdlib 26.2.5.21-8.fc44 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms