.TH edlin_expand 3erl "stdlib 5.2.2" "Ericsson AB" "Erlang Module Definition" .SH NAME edlin_expand \- Shell expansion and formatting of expansion suggestions. .SH DESCRIPTION .LP This module provides an expand_fun for the erlang shell \fIexpand/1,2\fR\&\&. It is possible to override this expand_fun \fIio:setopts/1,2\fR\&\&. .SH EXPORTS .LP .nf .B expand(Bef0) -> {Res, Completion, Matches} .br .fi .br .nf .B expand(Bef0, Opts) -> {Res, Completion, Matches} .br .fi .br .RS .LP Types: .RS 3 Bef0 = string() .br Opts = [Option] .br Option = {legacy_output, boolean()} .br Res = yes | no .br Completion = string() .br Matches = [Element] | [Section] .br Element = {string(), [ElementOption]} .br ElementOption = {ending, string()} .br Section = .br #{title := string(), .br elems := Matches, .br options := SectionOption} .br SectionOption = .br {highlight_all} | .br {highlight, string()} | .br {highlight_param, integer()} | .br {hide, title} | .br {hide, result} | .br {separator, string()} .br .RE .RE .RS .LP The standard expansion function is able to expand strings to valid erlang terms\&. This includes module names: .LP .nf 1> erla modules erlang: .fi .LP function names: .LP .nf 1> is_ato functions is_atom( 2> erlang:is_ato functions is_atom( .fi .LP function types: .LP .nf 1> erlang:is_atom( typespecs erlang:is_atom(Term) any() .fi .LP and automatically add , or closing parenthesis when no other valid expansion is possible\&. The expand function also completes: shell bindings, record names, record fields and map keys\&. .LP As seen below, function headers are grouped together if they\&'ve got the same expansion suggestion, in this case all had the same suggestions, that is \&'}\&'\&. There is also limited support for filtering out function typespecs that that does not match the types on the terms on the prompt\&. Only 4 suggestions are shown below but there exists plenty more typespecs for \fIerlang:system_info\fR\&\&. .LP .nf 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, ...}) } .fi .LP The return type of \fIexpand\fR\& function specifies either a list of \fIElement\fR\& tuples or a list of \fISection\fR\& maps\&. The section concept was introduced to enable more formatting options for the expansion results\&. For example, the shell expansion has support to highlight text and hide suggestions\&. There are also a \fI{highlight, Text}\fR\& that highlights all occurances of \fIText\fR\& in the title, and a \fIhighlight_all\fR\& for simplicity which highlights the whole title, as can be seen above for \fIfunctions\fR\& and \fItypespecs\fR\&\&. .LP By setting the \fI{hide, result}\fR\& or \fI{hide, title}\fR\& options you may hide suggestions\&. Sometimes the title isn\&'t useful and just produces text noise, in the example above the \fIany()\fR\& result is part of a section with title \fITypes\fR\&\&. 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\&. .LP Its possible to set a custom separator between the title and the results\&. This can be done with \fI{separator, Separator}\fR\&\&. By default its set to be \fI\\n\fR\&, some results display a \fItype_name() :: \fR\& followed by all types that define \fItype_name()\fR\&\&. .LP The \fI{ending, Text}\fR\& ElementOption just appends Text to the \fIElement\fR\&\&. .RE