pretty printing depth in the erlang shell

Matthias Lang <>
Wed May 18 23:59:21 CEST 2005


Thomas Johnsson XA \(LN/EAB\) writes:

 > Is there a way to increase the pretty printing depth in the erlang shell?
 > It is rather tedious to have to write eg
 > io:format("~p",[ ..whatever...]).
 > to see it all....

The depth is controlled by a macro in 'shell.erl', LINEMAX. One way to
change it is to edit the macro and recompile. You may need to use 
code:unstick_mod/1.

Another way is to patch shell.erl with the appended patch. Then you
can change the depth on the fly:

    1> lists:seq(1,30).
    [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29|...]
    2> application:set_env(stdlib, shell_depth, 5).
    ok
    3> lists:seq(1,30).                            
    [1,2,3,4|...]

Matt


--- /usr/local/src/otp_src_R10B-4/lib/stdlib/src/shell.erl      2005-03-22 15:09:40.000000000 +0100
+++ shell.erl   2005-05-18 23:52:15.548943280 +0200
@@ -21,7 +21,7 @@
 -export([whereis_evaluator/0, whereis_evaluator/1]).
 -export([start_restricted/1, stop_restricted/0]).
 
--define(LINEMAX, 30).
+-define(LINEMAX, get_env(shell_depth, 30)).
 -define(DEF_HISTORY, 20).
 -define(DEF_RESULTS, 20).





More information about the erlang-questions mailing list