beancount-mode as a major mode

79 views
Skip to first unread message

Daniele Nicolodi

unread,
Jan 22, 2019, 8:02:41 PM1/22/19
to bean...@googlegroups.com
Hello,

I have been hacking on beancount-mode to add some IMHO missing
functionality. Today I decided to explore the option to turn beancount
mode into a major mode and use outline-minor-mode to preserve the
section folding functionality used by some. I adapted some code from
outshine-mode to allow headlines visibility cycling ala org-mode.

While the code needs some cleanup, I'm quite happy with the result: the
code is simpler and more robust. You can it here:

https://bitbucket.org/daniele/beancount/src/default/editors/emacs/beancount.el

Before I start working on polishing the code and breaking up my
changesets to be pushed upstream, I would like to know if current users
of beancount-mode find this approach interesting.

Please test it and let me know what you think and what is missing or
broken to support your current workflow.

Thank you!

Cheers,
Dan

Stefano Zacchiroli

unread,
Jan 23, 2019, 5:42:58 AM1/23/19
to bean...@googlegroups.com
On Tue, Jan 22, 2019 at 06:02:36PM -0700, Daniele Nicolodi wrote:
> Today I decided to explore the option to turn beancount mode into a
> major mode and use outline-minor-mode to preserve the section folding
> functionality used by some. I adapted some code from outshine-mode to
> allow headlines visibility cycling ala org-mode.
>
> While the code needs some cleanup, I'm quite happy with the result:
> the code is simpler and more robust. You can it here:
>
> https://bitbucket.org/daniele/beancount/src/default/editors/emacs/beancount.el

Nice, thanks for this.

> Before I start working on polishing the code and breaking up my
> changesets to be pushed upstream, I would like to know if current
> users of beancount-mode find this approach interesting.

I personally don't have a use for it, but I've tested transaction
folding in this beancount-mode version and it did work fine.

I've noticed another glitch though, which I think is new.

"(setq beancount-posting-alignment-column 4)" in my global Emacs
configuration seems to no longer impact indentation level. The variable
is set properly to 4 while I'm in beancount-mode, but TAB pulls back
postings to the 2nd column. Looking at the code the variable seems to be
used correctly, so I'm not sure what's causing this. Can you reproduce
it?

Cheers
--
Stefano Zacchiroli . za...@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 »

Daniele Nicolodi

unread,
Jan 23, 2019, 11:08:08 AM1/23/19
to bean...@googlegroups.com
On 23/01/2019 03:42, Stefano Zacchiroli wrote:
> On Tue, Jan 22, 2019 at 06:02:36PM -0700, Daniele Nicolodi wrote:
>> Today I decided to explore the option to turn beancount mode into a
>> major mode and use outline-minor-mode to preserve the section folding
>> functionality used by some. I adapted some code from outshine-mode to
>> allow headlines visibility cycling ala org-mode.
>>
>> While the code needs some cleanup, I'm quite happy with the result:
>> the code is simpler and more robust. You can it here:
>>
>> https://bitbucket.org/daniele/beancount/src/default/editors/emacs/beancount.el
>
> Nice, thanks for this.
>
>> Before I start working on polishing the code and breaking up my
>> changesets to be pushed upstream, I would like to know if current
>> users of beancount-mode find this approach interesting.
>
> I personally don't have a use for it, but I've tested transaction
> folding in this beancount-mode version and it did work fine.
>
> I've noticed another glitch though, which I think is new.
>
> "(setq beancount-posting-alignment-column 4)" in my global Emacs
> configuration seems to no longer impact indentation level. The variable
> is set properly to 4 while I'm in beancount-mode, but TAB pulls back
> postings to the 2nd column. Looking at the code the variable seems to be
> used correctly, so I'm not sure what's causing this. Can you reproduce
> it?

I renamed the two variables that control alignment. Now they are
beancount-transaction-indent and beancount-number-alignment-column. I
think those names are better than my old choice. I mentioned that in a
previous email, but you may have missed it.

I also forgot to mention that this version drops the cache for account
names used for completion. I tested it on a ledger of mines with more
than two years of personal transactions and completion is instantaneous.
However, I would appreciate if users with very large ledgers would test
it and let me know how responsive it feels.

Cheers,
Dan

Stefano Zacchiroli

unread,
Jan 23, 2019, 11:22:17 AM1/23/19
to bean...@googlegroups.com
On Wed, Jan 23, 2019 at 09:08:40AM -0700, Daniele Nicolodi wrote:
> I renamed the two variables that control alignment. Now they are
> beancount-transaction-indent and beancount-number-alignment-column. I
> think those names are better than my old choice. I mentioned that in a
> previous email, but you may have missed it.

Oh, yeah, that's it, sorry for the noise.

> I also forgot to mention that this version drops the cache for account
> names used for completion. I tested it on a ledger of mines with more
> than two years of personal transactions and completion is instantaneous.
> However, I would appreciate if users with very large ledgers would test
> it and let me know how responsive it feels.

I've tried it on my ledger --- 5 years, 8 K transactions, 2 MB ledger in
beancount format --- and it still feels very responsive; I wouldn't say
it feels *instantaneous*, but it's still waaaay acceptable.

Daniele Nicolodi

unread,
Jan 23, 2019, 12:58:07 PM1/23/19
to bean...@googlegroups.com
On 23/01/2019 09:22, Stefano Zacchiroli wrote:
>> I also forgot to mention that this version drops the cache for account
>> names used for completion. I tested it on a ledger of mines with more
>> than two years of personal transactions and completion is instantaneous.
>> However, I would appreciate if users with very large ledgers would test
>> it and let me know how responsive it feels.
>
> I've tried it on my ledger --- 5 years, 8 K transactions, 2 MB ledger in
> beancount format --- and it still feels very responsive; I wouldn't say
> it feels *instantaneous*, but it's still waaaay acceptable.

Nice to hear, thank you. I'll try to setup some benchmarking and see if
the completion candidates collection can be optimized a bit. It may be
worth exploring something using syntax-ppss-cache for that.

Cheers,
Dan

Stefan Monnier

unread,
Jan 23, 2019, 1:45:04 PM1/23/19
to bean...@googlegroups.com
> I renamed the two variables that control alignment. Now they are
> beancount-transaction-indent and beancount-number-alignment-column.

I recommend you preserve backward compatibility with
`define-obsolete-variable-alias` (make sure you call it *before* you
declare the new var name).


Stefan

Stefan Monnier

unread,
Jan 23, 2019, 1:50:03 PM1/23/19
to bean...@googlegroups.com
> mode into a major mode and use outline-minor-mode to preserve the
> section folding functionality used by some. I adapted some code from
> outshine-mode to allow headlines visibility cycling ala org-mode.

Looks great, thank you.
Could you submit `outline-cycle` as a patch to outline.el
(via M-x report-emacs-bug) since it seems to be applicable to pretty
much all outline-minor-modes?


Stefan

Daniele Nicolodi

unread,
Jan 23, 2019, 3:18:43 PM1/23/19
to bean...@googlegroups.com
Those variables did never appear in any released beancount.el (as in
distributed or even committed to the beancount mercurial repository). I
just used different names in my earlier experiments (with lived only a
couple of days on my private repository). I thus think preserving
backward compatibility is not needed.

Cheers,
Dan

Daniele Nicolodi

unread,
Jan 23, 2019, 3:27:21 PM1/23/19
to bean...@googlegroups.com
I would be happy to do so, but I lifted that code almost verbatim from
outshine.el and it is likely that it was in turn taken from other
codebases building on top of outline-mode (I wanted to avoid the
dependency on outshine.el). I don't think that this goes well with the
copyright assignment. Probably the outshine.el authors should submit
that code instead.

Cheers,
Dan
Reply all
Reply to author
Forward
0 new messages