aboutsummaryrefslogtreecommitdiffstats
path: root/lib/syntax_tools
diff options
context:
space:
mode:
authorAaron <[email protected]>2013-06-02 20:54:20 +0200
committerHenrik Nord <[email protected]>2014-01-23 10:58:28 +0100
commiteb7c881a62e306f598a930b4781ecbbb67e37424 (patch)
treebf37b76f293b7e4f0672005ddd6a6094fedbcf99 /lib/syntax_tools
parente99633a51cbd22b16606c2669c575c22cf1c511f (diff)
downloadotp-eb7c881a62e306f598a930b4781ecbbb67e37424.tar.gz
otp-eb7c881a62e306f598a930b4781ecbbb67e37424.tar.bz2
otp-eb7c881a62e306f598a930b4781ecbbb67e37424.zip
Add initial implementation of having erl_tidy
print to screen instead of writing to the file provided. The reason for this is that you may want to have an intermediary step between saving the tidied file and using the output. Use-case personally is wanting to integrate erl_tidy into emacs and tidy buffers, overwriting the current file is generally not how this works in emacs with source code tidiers.
Diffstat (limited to 'lib/syntax_tools')
-rw-r--r--lib/syntax_tools/src/erl_tidy.erl16
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/syntax_tools/src/erl_tidy.erl b/lib/syntax_tools/src/erl_tidy.erl
index 0c149634f6..8507ff646e 100644
--- a/lib/syntax_tools/src/erl_tidy.erl
+++ b/lib/syntax_tools/src/erl_tidy.erl
@@ -309,9 +309,15 @@ file_2(Name, Opts) ->
true ->
ok;
false ->
- write_module(Tree, Name, Opts1),
- ok
- end.
+ case proplists:get_bool(stdout, Opts1) of
+ true ->
+ print_module(Tree, Opts1),
+ ok;
+ false ->
+ write_module(Tree, Name, Opts1),
+ ok
+ end
+ end.
read_module(Name, Opts) ->
verbose("reading module `~ts'.", [filename(Name)], Opts),
@@ -399,6 +405,10 @@ write_module(Tree, Name, Opts) ->
throw(R)
end.
+print_module(Tree, Opts) ->
+ Printer = proplists:get_value(printer, Opts),
+ io:format(Printer(Tree, Opts)).
+
output(FD, Printer, Tree, Opts) ->
io:put_chars(FD, Printer(Tree, Opts)),
io:nl(FD).