Account name length

49 views
Skip to first unread message

Luciano

unread,
Aug 1, 2016, 8:26:56 PM8/1/16
to Beancount
Hi Martin,

Quick question. Is there a reason why account and commodity names need to be at least two characters? 
Does it make parsing easier or is it just a matter of preference?

I have some holdings of stock with single letter tickers and it'd be nice to use their actual tickers in account and commodity names.
Obviously not a big deal, just a minor annoyance, but if it's a trivial change to the grammar I'd welcome it.

I'll dig into the codebase at some point but I'm just now learning Python so it might be a while.

Regards,
Luciano 

Alan Post

unread,
Aug 1, 2016, 8:44:47 PM8/1/16
to bean...@googlegroups.com
Hello Martin,

My name is Alan Post. I subscribed to the list shortly after starting
to use beancount. This is my first post. I would use this feature too;
Please excuse my laziness in not checking the source code, but if I
had to guess it's that you want to restrict account names to starting
with a ~letter, permit things like numbers in the second position, and
match one or more rather than zero or more characters. Roughly the code
behaves like:

[a-z][a-z0-9]+

rather than:

[a-z][a-z0-9]*

If it is that easy and you think this kind of change is acceptable, I'd
be happy to try my hand at producing a patch. (I know the details in
the code may be whelmingly different; I'm going for brevity over email)
I will obviously be pleased just to have the feature if you don't want
to try coordinating such a change.

Thank you for considering Luciano's request, and for beancount,

-A

Martin Blais

unread,
Aug 4, 2016, 12:09:48 AM8/4/16
to Beancount
I'm not 100% sure, but I think the limitation is related to the lexer.
The grammar for flags plays not to nicely with other things, and I think this is one of them.
However, I think I _may_ be able to change the definition to that of Alan's suggestion for account name components beyond the first one.



--
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/79428dba-3a12-4160-8122-89bd3c301ddf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Martin Blais

unread,
Aug 4, 2016, 1:06:33 AM8/4/16
to Martin Blais, Beancount
Looks like that works.
Try it.

Reply all
Reply to author
Forward
0 new messages