edlin_expand(3)
π edlin_expand β the Erlang Module Definition bestie π
okay so real quick, the manual name here is edlin_expand(3) and it lives in the stdlib section, just so u know what u walked into π
β¨ NAME β¨
edlin_expand β shell expansion and formatting of expansion suggestions. that's it, that's the whole vibe πΈ
π¦ DESCRIPTION π¦
so basically this module hands u an expand_fun for the erlang shell's expand/1,2. and get this β u can totally override that expand_fun with io:setopts/1,2. no cap. π
π FUNCTIONS π
π expand(Bef0, Opts) -> {Res, Completion, Matches}
and here's the whole signature with every single type, verbatim, don't skip it bestie:
expand(Bef0, Opts) -> {Res, Completion, Matches}
when
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()}.
so the standard expansion function is able to expand strings into valid erlang terms. yes, literally. and that includes 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 will automatically add , or a closing parenthesis when there's no other valid expansion possible. iconic behavior tbh π«Ά
and the expand function also completes:
- shell bindings
- record names
- record fields
- map keys
not me listing all four like a good student, but fr fr they're all in there. π
okay so the thing about function headers β as u can see below, they get grouped together if they've got the same expansion suggestion. in this case all of them had the same suggestion, that is '}'. and there's also limited support for filtering out function typespecs that don't match the types on the terms 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 section concept got introduced to enable more formatting options for the expansion results. for example, the shell expansion has support for highlighting text and hiding suggestions. there's also a {highlight, Text} that highlights all occurrences of Text in the title, plus a highlight_all for when u just want simplicity and it highlights the whole title β exactly like u can see above for functions and typespecs. β¨
by setting the {hide, result} or {hide, title} options u can hide suggestions. sometimes the title isn't even useful and just produces text noise β in the example above, the any/0 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. lowkey a great idea, highkey not shipped yet. π
it's also possible to set a custom separator between the title and the results. u do that with {separator, Separator}. by default it's set to \n, and some results display a type_name() :: followed by all types that define type_name(). π
heads up bestie: those<italic>-energy caveats above are real β the filtering support is limited, hiding results is not currently in use, and the default separator is\n. don't go assuming extra features, ok? π
aaaand that's the whole page, periodt. this lil masterpiece comes to u from Ericsson AB, rocking stdlib 8.0.4, edlin_expand(3). go forth and expand, queen πππ¦
π¦ where this page comes from
- ubuntu stonking: erlang-doc 1:29.0.6+dfsg-1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms