On Mon, Nov 30, 2020 at 02:11:58PM -0800, Aaron Lindsay wrote:
 Is there a better way to programmatically rewrite ledgers by hooking into 
> pieces of the beancount internals today? If not, will v3 have any impact on 
> this?

As a side comment on this topic, I'm more and more convinced that the
ability to programmatically edit the syntax of textual ledgers is
(should be) a key feature for plain text accounting. And that such a
feature would naturally complement the great support that Beancount
already has for plugins (which modify the semantics, rather than the
syntax, of textual ledgers).

The reason is that, thanks to version control, when doing plain text
accounting with a computer we routinely alter the *historical* records,
e.g., by improving how we book past transactions, fixing mistakes,
etc. --- which is something both great and novel in comparison to
traditional accounting practices.

Now the problem lies in programmatically editing *concrete* syntax,
which is a complicated problem in general, due to the amount of
information that parsers tend to throw away when converting to ASTs.
So, Martin, everything the new Beancount parsers manage to keep
(locations, comments, etc.) would be definitely welcome in this respect.

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.)

Cheers

[1]: https://github.com/psf/black
-- 
Stefano Zacchiroli . z...@upsilon.cc . upsilon.cc/zack . . o . . . o . o
Computer Science Professor . CTO Software Heritage . . . . . o . . . o o
Former Debian Project Leader & OSI Board Director  . . . o o o . . . o .
« the first rule of tautology club is the first rule of tautology club »

-- 
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 beancount+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beancount/20201201135838.elqx5kitsmhefygy%40upsilon.cc.

Reply via email to