On Tue, Dec 1, 2020 at 8:58 AM Stefano Zacchiroli <[email protected]> wrote:

> Another ingredient that would help is a very-opinionated,
> fully-automated formatter for Beancount syntax, similar to what Black[1]
> is to Python. With something like that an hypothetical "sed" equivalent
> for Beancount syntax would be able to worry less about getting right
> details such as spacing, indentation, etc. --- it will just have to pipe
> its output to bean-format(-ng) and be done with it. (But of course this
> is assuming that nothing is lost in the concrete syntax -> AST
> translation, and most notably comments.)
>

Yes... bean-format was intended to be a bit like that.
(I went 70% of the way, then dropped the ball on some corner cases.)
It needs a bit more work, but it could be made much better, even without
custom parsing (just processing the text in bean-format).

Maybe in v3 I'll expose an interface to parse and produce the
intermediate transaction, and implement a proper printer for it that can
reverse the process. That would help with that.
In v2 the printer can grok *some* intermediate transactions and all
finalized ones. It's designed to print finalized transactions.
99% of the time we print only finalized ones, but it's happened in the past
for debugging and for writing tests that I print the intermediate
transactions.
I think in v3 I should make a distinct printer (and code path) that can
fully reverse the intermediate partially filled transaction.
I think that's doable.
That, in itself, would naturally be the best formatter.

-- 
You received this message because you are subscribed to the Google Groups 
"Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beancount/CAK21%2BhNr6pAPwCXLqB2vK2mrTQvVeE9BqapOiRKoy%2Boe2XS_4w%40mail.gmail.com.

Reply via email to