In ledger-mode, how can I color posting account names differently depending on an initial substring?

11 views
Skip to first unread message

dersuchmann

unread,
Jun 9, 2020, 9:24:39 AM6/9/20
to Ledger
Hello there, I've just started to work with ledger a week ago and am now switching to emacs for a couple of reasons.

For my personal ledger workflow, there are two things I would like to acheive, the first one of which I'm addressing in this topic.
--------------------
How can I adjust ledger-mode syntax highlighting such that a posting's account name is colored differently depending on an initial substring? I put all accounts either under "Assets:", "Equity:", "Liabilities:", or "Budgets:" and would love to see each of these four groups being colored differently while I work on the file.

I already found ledger-fonts.el and tried to replace ,ledger-posting-regex near the end of the file by my own regexes, but it seems to have no effect. Even if I comment out this part, syntax highlighting stays the same. Do I still need to update the emacs settings somehow? And is there maybe a "cleaner" way to acheive this? As I'm really new to emacs and elisp, I'm not sure how I can do this best.

Any help is greatly appreciated!

Eric S Fraga

unread,
Jun 9, 2020, 11:01:21 AM6/9/20
to ledge...@googlegroups.com
On Tuesday, 9 Jun 2020 at 06:24, dersuchmann wrote:
> How can I adjust ledger-mode syntax highlighting such that a posting's
> account name is colored differently depending on an initial substring? I
> put all accounts either under "Assets:", "Equity:", "Liabilities:", or
> "Budgets:" and would love to see each of these four groups being colored
> differently while I work on the file.

hi-lock-mode will allow you to do this by specifying regular expressions
at the beginning of the file.

--
Eric S Fraga via Emacs 28.0.50 & org 9.3.7 on Debian bullseye/sid

Reply all
Reply to author
Forward
0 new messages