Skip to content

Commit 7ea8fae

Browse files
committed
Fully support inspect_opts in IEx.Options
1 parent 82655b6 commit 7ea8fae

File tree

3 files changed

+23
-9
lines changed

3 files changed

+23
-9
lines changed

lib/elixir/lib/kernel.ex

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1890,19 +1890,19 @@ defmodule Kernel do
18901890
18911891
## Options
18921892
1893-
The following options are supported:
1894-
1895-
* :raw - tuples are not formatted as the inspect protocol, they are
1896-
always shown as tuples, defaults to false;
1897-
1898-
* :limit - the limit of items that are shown in tuples, bitstrings and
1899-
lists. Does not apply to strings;
1893+
See the docs for IEx.Options for more details.
19001894
19011895
## Examples
19021896
19031897
iex> inspect(:foo)
19041898
":foo"
19051899
1900+
inspect(ArgumentError[])
1901+
#=> "ArgumentError[message: \"argument error\"]"
1902+
1903+
inspect(ArgumentError[], raw: true)
1904+
#=> "{ArgumentError,:__exception__,\"argument error\"}"
1905+
19061906
Note that the inspect protocol does not necessarily return a valid
19071907
representation of an Elixir term. In such cases, the inspected result must
19081908
start with `#`. For example, inspecting a function will return:

lib/iex/lib/iex/options.ex

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,20 @@ defmodule IEx.Options do
2424
"""
2525
],
2626
inspect: [
27-
doc: ""
27+
doc: """
28+
Control the behavior of the shell's inspecting algorithm. Inspect is
29+
used for printing results of evaluating expressions. It is also used by IO.inspect.
30+
31+
The value is a keyword list that should have any of the following keys
32+
specified. If any of the keys is omitted, that option is not changed.
33+
34+
* raw -- when true, record tuples are not formatted by the inspect protocol,
35+
but are printed as just tuples; default: false
36+
37+
* limit -- limits the number of items that are printed for tuples, bitstrings,
38+
and lists; does not apply to strings
39+
40+
"""
2841
],
2942
]
3043

@@ -69,6 +82,7 @@ defmodule IEx.Options do
6982

7083
def set(:inspect, opts) when is_list(opts) do
7184
old_opts = IEx.inspect_opts
85+
# FIXME: validate keys before setting
7286
IEx.inspect_opts(opts)
7387
old_opts
7488
end

lib/iex/mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ defmodule IEx.Mixfile do
88
def application do
99
[env: [
1010
after_spawn: [],
11-
inspect_opts: [limit: 50],
11+
inspect_opts: [limit: 50, raw: false],
1212
colors: [
1313
enabled: true,
1414
eval_result: "yellow",

0 commit comments

Comments
 (0)