1edlin_expand(3)            Erlang Module Definition            edlin_expand(3)
2
3
4

NAME

6       edlin_expand - Shell expansion and formatting of expansion suggestions.
7

DESCRIPTION

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

EXPORTS

13       expand(Bef0) -> {Res, Completion, Matches}
14
15       expand(Bef0, Opts) -> {Res, Completion, Matches}
16
17              Types:
18
19                 Bef0 = string()
20                 Opts = [Option]
21                 Option = {legacy_output, boolean()}
22                 Res = yes | no
23                 Completion = string()
24                 Matches = [Element] | [Section]
25                 Element = {string(), [ElementOption]}
26                 ElementOption = {ending, string()}
27                 Section =
28                     #{title := string(),
29                       elems := Matches,
30                       options := SectionOption}
31                 SectionOption =
32                     {highlight_all} |
33                     {highlight, string()} |
34                     {highlight_param, integer()} |
35                     {hide, title} |
36                     {hide, result} |
37                     {separator, string()}
38
39              The standard expansion function is able  to  expand  strings  to
40              valid erlang terms. This includes module names:
41
42              1> erla
43              modules
44              erlang:
45
46
47              function names:
48
49              1> is_ato
50              functions
51              is_atom(
52              2> erlang:is_ato
53              functions
54              is_atom(
55
56
57              function types:
58
59              1> erlang:is_atom(
60              typespecs
61              erlang:is_atom(Term)
62              any()
63
64
65              and  automatically  add  ,  or closing parenthesis when no other
66              valid expansion is possible. The expand function also completes:
67              shell bindings, record names, record fields and map keys.
68
69              As  seen below, function headers are grouped together if they've
70              got the same expansion suggestion, in this case all had the same
71              suggestions, that is '}'. There is also limited support for fil‐
72              tering out function typespecs that that does not match the types
73              on  the  terms on the prompt. Only 4 suggestions are shown below
74              but there exists plenty more typespecs for erlang:system_info.
75
76              1> erlang:system_info({allocator, my_allocator
77              typespecs
78              erlang:system_info(wordsize | {wordsize, ...} | {wordsize, ...})
79              erlang:system_info({allocator, ...})
80              erlang:system_info({allocator_sizes, ...})
81              erlang:system_info({cpu_topology, ...})
82              }
83
84
85              The return type of expand function specifies either  a  list  of
86              Element  tuples  or  a list of Section maps. The section concept
87              was introduced to enable more formatting options for the  expan‐
88              sion  results.  For  example, the shell expansion has support to
89              highlight text and hide suggestions. There  are  also  a  {high‐
90              light,  Text}  that highlights all occurances of Text in the ti‐
91              tle, and a highlight_all for  simplicity  which  highlights  the
92              whole title, as can be seen above for functions and typespecs.
93
94              By  setting  the {hide, result} or {hide, title} options you may
95              hide suggestions. Sometimes the title isn't useful and just pro‐
96              duces  text noise, in the example above the any() result is part
97              of a section with title Types. Hiding results is  currently  not
98              in  use,  but  the idea is that a section can be selected in the
99              expand area and all the other section  entries  should  be  col‐
100              lapsed.
101
102              Its possible to set a custom separator between the title and the
103              results. This can be done with {separator,  Separator}.  By  de‐
104              fault  its  set to be \n, some results display a type_name() ::
105              followed by all types that define type_name().
106
107              The {ending, Text} ElementOption just appends Text to  the  Ele‐
108              ment.
109
110
111
112Ericsson AB                      stdlib 5.1.1                  edlin_expand(3)
Impressum