19962022 Ericsson AB. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. edlin_expand
edlin_expand Shell expansion and formatting of expansion suggestions.

This module provides an expand_fun for the erlang shell expand/1,2. It is possible to override this expand_fun io:setopts/1,2.

Standard expanion function for the erl shell.

The standard expansion function is able to expand strings to valid erlang terms. This 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 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.

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 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 expand function specifies either a list of Element tuples or a list of Section 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 {highlight, Text} that highlights all occurances of Text in the title, and a highlight_all for simplicity which highlights the whole title, as can be seen above for functions and typespecs.

By setting the {hide, result} or {hide, title} options you may hide suggestions. Sometimes the title isn't useful and just produces text noise, 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.

Its possible to set a custom separator between the title and the results. This can be done with {separator, Separator}. By default its set to be \n, some results display a type_name() :: followed by all types that define type_name().

The {ending, Text} ElementOption just appends Text to the Element.