New fontification Scheme

75 views
Skip to first unread message

Craig Earls

unread,
Sep 8, 2014, 11:49:44 PM9/8/14
to ledge...@googlegroups.com
I have spent the last month overhauling ledger fontification. I gave
up on using the standard REGEX based methods that most font lockers
use. Instead I wrote a few functions that actually understand the
semantics of a ledger xact then had jit-lock and font-lock call those.
Overall there is much more flexibility and it seems to be plenty
fast. The regexes I do use are much simpler. I tested with a file
that had 2,613,072 postings and it was lighting fast. Comments after
amounts are now properly recognized and you can fontify an entire xact
based on its overall status (my favorite part, that font-lock just
really couldn't do).

For those of you who use lots of different directives there are now
separate faces possible for all valid directives (or just use one face
for all directives)

Please check it out and report any bugs you find. I have banged on it
for a while and it has been stable and well behaved. Of course you
will find problems.

--
Craig, Corona De Tucson, AZ
enderw88.wordpress.com

Andrew Schwartzmeyer

unread,
Sep 9, 2014, 12:41:47 AM9/9/14
to ledge...@googlegroups.com

On Sep 8, 2014, at 8:49 PM, Craig Earls <ende...@gmail.com> wrote:

> I have spent the last month overhauling ledger fontification. I gave
> up on using the standard REGEX based methods that most font lockers
> use. Instead I wrote a few functions that actually understand the
> semantics of a ledger xact then had jit-lock and font-lock call those.
> Overall there is much more flexibility and it seems to be plenty
> fast. The regexes I do use are much simpler. I tested with a file
> that had 2,613,072 postings and it was lighting fast. Comments after
> amounts are now properly recognized and you can fontify an entire xact
> based on its overall status (my favorite part, that font-lock just
> really couldn't do).

Awesome! Thanks so much for your work man.

> For those of you who use lots of different directives there are now
> separate faces possible for all valid directives (or just use one face
> for all directives)
>
> Please check it out and report any bugs you find. I have banged on it
> for a while and it has been stable and well behaved. Of course you
> will find problems.

Gotta say for the first thirty seconds I though it was totally broken when everything was white, made sense once I scrolled down (white for cleared transactions, green for budget, normal for uncleared, at least with my theme).

So far it’s recognizing (highlighting properly): assertions, lot value / posting cost / amount expressions, and posting notes. Sweet!

However, it unfortunately doesn’t smartly indent any of the above except plain currency values. What would go into fixing that? I can take a look.

> --
> Craig, Corona De Tucson, AZ
> enderw88.wordpress.com
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups "Ledger" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to ledger-cli+...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Craig Earls

unread,
Sep 9, 2014, 12:43:34 AM9/9/14
to ledge...@googlegroups.com
Indentation is totally independent of font-lock. There is a bug noted already. I just haven't gotten to it. 

Johann Klähn

unread,
Sep 10, 2014, 9:49:10 AM9/10/14
to ledge...@googlegroups.com
Nice work Craig!
One thing I noticed, though: In the following transaction the account name
in the second line (B) is highlighted using `ledger-font-posting-amount-face`.
And the 0 in the first posting is highlighted as if it was part of the account name.

2014/03/11 Whatever
    A                                               0
    B                                           6,75€
    C                                          -6,75€
    
This seems to happen for every posting that follows one ending with a zero
(i.e. for permutations of the example above).

Craig Earls

unread,
Sep 10, 2014, 9:51:06 AM9/10/14
to ledge...@googlegroups.com
I will look into this, but I think single character account names and
single digit amounts are not realistic.

Johann Klähn

unread,
Sep 10, 2014, 9:54:54 AM9/10/14
to ledge...@googlegroups.com
I just stripped this down, I noticed it in my own journal where I use normal account names but happened to have a zero in some auto-generated postings. I agree that this is a corner case and very low priority, as I can just modify my journal. Just wanted to let you know.

Craig Earls

unread,
Sep 10, 2014, 9:58:04 AM9/10/14
to ledge...@googlegroups.com
Thanks, I ran a quick check and the single digit amount is getting by
the filter. It turns out that it doesn't like pure integer amounts so
it isn't as far in the corner as I would like. I will get it fixed.

Craig Earls

unread,
Sep 10, 2014, 11:48:36 PM9/10/14
to ledge...@googlegroups.com
This has been fixed. Thanks for finding it.

On Wed, Sep 10, 2014 at 6:48 AM, Johann Klähn <kljo...@gmail.com> wrote:

John Louis Del Rosario

unread,
Sep 11, 2014, 11:19:45 PM9/11/14
to ledge...@googlegroups.com
Awesome work. Thanks!

Not sure if it's a bug or intentional, but  I like to group my transactions by day. With the recent changes, payees without an empty line before them aren't highlighted correctly anymore.

Screenshot: http://i.imgur.com/EeSsh7z.png (The top one has an empty line before it)

Craig Earls

unread,
Sep 12, 2014, 9:10:24 AM9/12/14
to ledge...@googlegroups.com
The new fontification scheme requires an empty line between transactions to tell where they begin and end. 

I actually thought that was a requirement for the ledger input file. If it isn't I will see if I can get another way working.
--

---
You received this message because you are subscribed to the Google Groups "Ledger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ledger-cli+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

John Louis Del Rosario

unread,
Sep 12, 2014, 9:45:15 AM9/12/14
to ledge...@googlegroups.com
Hmm afaik it's explicitly mentioned in the docs that there should be an empty line between transactions. (Although all examples in the docs do have empty lines in between)

-- 
john2x.com | @john2x

You received this message because you are subscribed to a topic in the Google Groups "Ledger" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ledger-cli/9zyWZW_fJmk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ledger-cli+...@googlegroups.com.

Craig Earls

unread,
Sep 12, 2014, 9:55:41 AM9/12/14
to ledge...@googlegroups.com
I just checked and ledger will work if the xacts are separated by
white space. I always separate them by white space so never noticed
this. I wrote all the examples in the docs too. Put this in as a
feature request. It actually effects a lot more than just
fontification.

On Fri, Sep 12, 2014 at 6:45 AM, John Louis Del Rosario

John Louis Del Rosario

unread,
Sep 12, 2014, 10:14:09 AM9/12/14
to ledge...@googlegroups.com
Oh sorry I meant it's *not* mentioned in the docs. Aww so it's not just fixing the regex of the xact fontification?
Where can I submit a feature request?

-- 
john2x.com | @john2x

Hans Erik van Elburg

unread,
Sep 14, 2014, 12:29:44 PM9/14/14
to ledge...@googlegroups.com
Hi Craig,

Nice work.

I found one issue, in the following posting:

2014/08/23 demo fontification error
    Expense:AAA                              € 10,00
    Expense:BBB                              € 20,00
    cash
    Expense:CCC                              € 10,00
    card                                           -€ 10,00

Expense:CCC is colored red instead of blue, so I guess it is wrongly recognized as a new posting. If I add spaces after cash, then the colouring is correctly.

Best Regards,
Hans Erik

Op dinsdag 9 september 2014 05:49:44 UTC+2 schreef Craig Earls:

Craig Earls

unread,
Sep 14, 2014, 1:08:51 PM9/14/14
to ledge...@googlegroups.com
Thanks. I have seen this as well. I will look into it.
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "Ledger" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ledger-cli+...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



Craig Earls

unread,
Sep 14, 2014, 1:09:13 PM9/14/14
to ledge...@googlegroups.com
This should be fixed in the latest push.

On Fri, Sep 12, 2014 at 7:14 AM, John Louis Del Rosario

Erik Hetzner

unread,
Sep 14, 2014, 8:56:26 PM9/14/14
to ledge...@googlegroups.com
Hi,

Some others may have encountered the same issue I did, so I am posting
this. With the new fontification scheme my cleared transactions did
not have the posting accounts & amounts highlighted. It turns out you
need to set ledger-fontify-xact-state-overrides to nil to get
fontification of amounts & accounts with cleared transactions.

best, Erik

At Mon, 8 Sep 2014 20:49:43 -0700,
> --
>
> ---
> You received this message because you are subscribed to the Google Groups "Ledger" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to ledger-cli+...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

--
Sent from my free software system <http://fsf.org/>.

John Louis Del Rosario

unread,
Sep 14, 2014, 10:23:11 PM9/14/14
to ledge...@googlegroups.com
Yup much better now. Thanks!

-- 
john2x.com | @john2x

Eric Abrahamsen

unread,
Sep 18, 2014, 1:17:06 AM9/18/14
to ledge...@googlegroups.com
Hey I'm using the ledger-git package on archlinux, and this doesn't seem
to have landed there. Does anyone know who is maintaining that package
("Joni" according to the AUR), and if this bit is going to land soon?
The package has otherwise been updated fairly regularly, I'm just not
seeing new fontification.

I'll ask on the AUR page if no one here has anything to do with it...

Thanks,
Eric

Johann Klähn

unread,
Sep 18, 2014, 2:58:58 AM9/18/14
to ledge...@googlegroups.com

I think 'lisp/CMakeLists.txt' still has to be updated to include the new file names. I can take a look at it this evening.

Reply all
Reply to author
Forward
0 new messages