From eb7c881a62e306f598a930b4781ecbbb67e37424 Mon Sep 17 00:00:00 2001 From: Aaron Date: Sun, 2 Jun 2013 20:54:20 +0200 Subject: 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. --- lib/syntax_tools/src/erl_tidy.erl | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'lib/syntax_tools') 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). -- cgit v1.2.3 From a857d28603ad674c40a977249c1b6ae8d29c1f6c Mon Sep 17 00:00:00 2001 From: Aaron Date: Sun, 2 Jun 2013 21:46:25 +0200 Subject: Added documenation for the new option describing what it does. --- lib/syntax_tools/src/erl_tidy.erl | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib/syntax_tools') diff --git a/lib/syntax_tools/src/erl_tidy.erl b/lib/syntax_tools/src/erl_tidy.erl index 8507ff646e..7444d8dc67 100644 --- a/lib/syntax_tools/src/erl_tidy.erl +++ b/lib/syntax_tools/src/erl_tidy.erl @@ -269,6 +269,13 @@ file(Name) -> %% is typically most useful if the `verbose' flag is enabled, to %% generate reports about the program files without affecting %% them. The default value is `false'. +%% +%%
{stdout, boolean()}
+%% +%%
If the value is `true', instead of the file being written +%% to disk it will be printed to stdout. The default value is +%% `false'.
+%% %% %% %% See the function `module/2' for further options. -- cgit v1.2.3