Beancount Autocomplete in Emacs

436 views
Skip to first unread message

trs...@tutanota.com

unread,
Jun 21, 2018, 1:10:25 PM6/21/18
to Beancount Mailing List
First, I wanted to compliment you Martin (and other contributors) on this excellent software package you have created and especially for taking the time and effort to produce such great documentation! I am sure those factors (along with the snazzy fava) are the reasons for Beancount's exploding popularity more recently. My family could testify to you as to how excited I am about starting to use Beancount, even though strangely for some reason they don't seem to share my enthusiasm around text based methods of doing things. ;)

Alas, on to the actual issue...

At first I thought that autocomplete in Emacs (beancount minor mode) was broken (or that I hadn't installed / configured it correctly, which still may be the case). However after a discussion with someone in #emacs (who took a look at beancount.el, some of which is still above my head) their opinion was that what I was expecting was just not what it is supposed to do.

I was expecting to start typing for instance an account name in my ledger.beancount file eEmacs, and then some sort of dialog would either come up in the text entry area, or maybe in the minibuffer at bottom, or maybe even just automagically somehow finish the account name, or give me options to chose from, or something... But none of those things happened. Just regular text entry with no magic. :(

Picking through beancount.el my friend did find completion-at-point which he had me try and that does work when invoked with M-x completion-at-point however I guess I was expecting it to be more automagical and recognize my keypresses somehow. Someone I think in #beancount told me that's how it works in ledger. But my friend in #emacs said it's just a hook and that I would need to install something like company-mode or auto-complete mode to get the functionality that I am expecting. But that didn't seem right to me, what with autocomplete being touted as a major feature (and with the length that account names can be). So at minimum I wanted to confirm if that was the case or not?

Pls halp! :)

Regards,
TRS-80
--
Securely sent with Tutanota. Claim your encrypted mailbox today!
https://tutanota.com

Júlio Maranhão

unread,
Jun 21, 2018, 4:12:32 PM6/21/18
to Beancount
On Thursday, 21 June 2018 14:10:25 UTC-3, trs...@tutanota.com wrote:
At first I thought that autocomplete in Emacs (beancount minor mode) was broken (or that I hadn't installed / configured it correctly, which still may be the case). However after a discussion with someone in #emacs (who took a look at beancount.el, some of which is still above my head) their opinion was that what I was expecting was just not what it is supposed to do.

I know this is off-topic but it's short and related to beancount.el (emacs minor mode).
Beancount manual (Beancount Options Reference) talks about customizing the root account names:

option "name_assets" "Assets"

option "name_liabilities" "Liabilities"

option "name_equity" "Equity"

option "name_income" "Income"

option "name_expenses" "Expenses"

 
It seams beancount.el ignore this feature (hardcoded). My solution: I chose to give up on non-reliable or non-globally-implemented features. Even if only beancount.el does not work, I prefer to be cautious. Following this rule, I decided to only use ascii outside double-quoted text as new issues are still been discovered (issue tracker).


That said, for on-topic talk, "C-c ' " is some kind of magic to me. I hope for better ones but I can save some strokes. Do you use it?

About company-mode, auto-complete or any other emacs packages, I am a noobie. But I hope there is a simple way to enhance beancount file edition. Some features in this area:

1) A beautifier command (alignments, etc). I just quit aligning amounts per transaction (C-c ;) after some account renames.
2) A better autocomplete. Typing MyBank and MyName could suggest all accounts with these words in any order, etc.
3) Use of templates (transactions) is a real saver.
4) A correct color coding syntax. But I can live without it.
5) Am I forgetting some important feature?

As I am an emacs noobie (ido for files, org), I believe we can get help with suggestions and hints from experienced (e-)users. I'd really appreciate.

Cheers.

Júlio

trs...@tutanota.com

unread,
Jun 21, 2018, 4:28:24 PM6/21/18
to bean...@googlegroups.com
I am pretty new to it also, but I think there is 'C-c :' which will do the same as "C-c ;" on an area instead of a single transaction, but you have to highlight the area first. C-<SPC> to set mark then move wherever then C-c : to format. IIRC

On the other stuff, I'm pretty new to Emacs myself, so I'll wait with interest for additional replies. :)


TRS-80
--
Securely sent with Tutanota. Claim your encrypted mailbox today!
https://tutanota.com

21. Jun 2018 16:12 by julio.m...@gmail.com:


1) A beautifier command (alignments, etc). I just quit aligning amounts per transaction (C-c ;) after some account renames.

Júlio


Martin Blais

unread,
Jun 22, 2018, 8:54:29 AM6/22/18
to Beancount
Use C-c ' (beancount-insert-account), either without any text or after entering a substring of the account name.
You can also use Ledger's Emacs support if you prefer, some of it should be applicable.


--
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+...@googlegroups.com.
To post to this group, send email to bean...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/LFYJpp---3-0%40tutanota.com.
For more options, visit https://groups.google.com/d/optout.

Martin Blais

unread,
Jun 22, 2018, 8:56:14 AM6/22/18
to Beancount
The emacs support cannot read those as it doesn't call out to Beancount.
In theory, a very lightweight version of the Beancount parser could be produced to feed some of this behavior into Emacs but that's never been done and just an idea.

C-c '   could definitely use some improvement.


--
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+...@googlegroups.com.
To post to this group, send email to bean...@googlegroups.com.

Stefano Zacchiroli

unread,
Jun 22, 2018, 9:05:17 AM6/22/18
to bean...@googlegroups.com
On Fri, Jun 22, 2018 at 08:54:15AM -0400, Martin Blais wrote:
> You can also use Ledger's Emacs support if you prefer, some of it should be
> applicable.

I think that what's really needed is making ledger-mode parametric in
the plain text accounting "dialect" it supports, similarly to what shell
mode does for shell script, sql mode does for SQL variants, etc. That
way beancount-mode can still be used for those who prefer having it as
minor mode, e.g., for language embedding in org-mode; and others can
have a full major mode which is on many other fronts more practical.

My elisp-fu is too basic for this, but maybe some of the great Emacs
gurus we have on the list would be interested in looking into this?

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 »

trs...@tutanota.com

unread,
Jun 22, 2018, 9:18:27 AM6/22/18
to bean...@googlegroups.com
Aha! OK, that's workable. Thanks Martin!

I was just experimenting and I ran into a problem however. Maybe I am doing something wrong but I think this is how Ido is supposed to work (because I have started using Ido elsewhere).

Anyway, I have an account Expenses:Food:EatingOut and as I type E I can see it in the list in the minibuffer but then as soon as I type either ":F" or "F" or "f" it disappears from the available options. :/


TRS-80
--
Securely sent with Tutanota. Claim your encrypted mailbox today!
https://tutanota.com

22. Jun 2018 08:54 by bl...@furius.ca:

trs...@tutanota.com

unread,
Jun 22, 2018, 9:21:44 AM6/22/18
to bean...@googlegroups.com
OK apologies for self reply but I figured something out. If I instead type "Eat C-c '" it comes right up. Which is plenty workable however isn't the complete supposed to work like I expected in my previous email?

In which case, I am either expecting/doing something wrong, or it's a bug?


TRS-80
--
Securely sent with Tutanota. Claim your encrypted mailbox today!
https://tutanota.com

22. Jun 2018 09:18 by trs...@tutanota.com:

Aha! OK, that's workable. Thanks Martin!

I was just experimenting and I ran into a problem however. Maybe I am doing something wrong but I think this is how Ido is supposed to work (because I have started using Ido elsewhere).

Anyway, I have an account Expenses:Food:EatingOut and as I type E I can see it in the list in the minibuffer but then as soon as I type either ":F" or "F" or "f" it disappears from the available options. :/

TRS-80
--
Securely sent with Tutanota. Claim your encrypted mailbox today!
https://tutanota.com

22. Jun 2018 08:54 by bl...@furius.ca:


For more options, visit https://groups.google.com/d/optout.

--
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+...@googlegroups.com.
To post to this group, send email to bean...@googlegroups.com.

Júlio Maranhão

unread,
Jun 22, 2018, 2:38:57 PM6/22/18
to Beancount
On Friday, 22 June 2018 10:18:27 UTC-3, trs...@tutanota.com wrote:
Anyway, I have an account Expenses:Food:EatingOut and as I type E I can see it in the list in the minibuffer but then as soon as I type either ":F" or "F" or "f" it disappears from the available options. :/

As soon as there is only common following chars, Ido shows then in brackets. Just type SPC bar to complete and continue.

Example, if there is only a term with E, F and E in the first, second and third level, respectively than 'e SPC f SPC e ENTER' gives Expenses:Food:EatingOut. You can type chars until resolves ambiguity. For instance, 'e SPC fo SPC e SPC o ENTER' in case there is a Expenses:Farm and Expenses:Food:EatingInsideHome.

All above is under (C-c ') environment.

Thanks for (C-c :) hint.

Júlio

trs...@tutanota.com

unread,
Jun 22, 2018, 2:43:41 PM6/22/18
to bean...@googlegroups.com
Julio,

Thanks for reply however I actually already tried exactly what you describe, before posting to the mailing list! Does that work for you? Because it doesn't for me. Maybe something is broken in my setup?


TRS-80
--
Securely sent with Tutanota. Claim your encrypted mailbox today!
https://tutanota.com

22. Jun 2018 14:38 by julio.m...@gmail.com:

--
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+...@googlegroups.com.
To post to this group, send email to bean...@googlegroups.com.

Martin Blais

unread,
Jun 22, 2018, 11:25:26 PM6/22/18
to Beancount
I'm not sure if it's related, but note that the Emacs mode doesn't refresh its list of accounts when you insert one for the first time. Type C-c r   to refresh that internal completion list. This will be more common if you're starting out; however, after a while, it's pretty rare that one inserts new accounts for the first time.


trs...@tutanota.com

unread,
Jun 23, 2018, 11:22:21 AM6/23/18
to bean...@googlegroups.com
Just tried refreshing account list with C-c r, received "Accounts updated." message at bottom however behavior remains the same for me.

I can get to that account (Expenses:Food:EatingOut) by typing "foo" (lol) or "out" etc. so that's workable. I'm sure I will work out and come to know the shortest number of keypresses to any account in short order.

Thanks for all replies and help!


TRS-80

--
Securely sent with Tutanota. Claim your encrypted mailbox today!
https://tutanota.com

22. Jun 2018 23:25 by bl...@furius.ca:

Reply all
Reply to author
Forward
0 new messages