3.11 Using Emacs to Keep Your Ledger
In the Ledger tarball is an Emacs module, ledger.el. This
module makes the process of keeping a text ledger much easier for
Emacs users. I recommend putting this at the top of your ledger file:
; -*-ledger-*-
And this in your .emacs file, after copying ledger.el to
your site-lisp directory:
(load "ledger")
Now when you edit your ledger file, it will be in
ledger-mode. ledger-mode adds these commands:
- C-c C-a
- For quickly adding new entries based on the form of older ones (see
previous section).
- C-c C-c
- Toggles the “cleared” flag of the transaction under point.
- C-c C-d
- Delete the entry under point.
- C-c C-r
- Reconciles an account by displaying the transactions in another
buffer, where simply hitting the spacebar will toggle the pending flag
of the transaction in the ledger. Once all the appropriate
transactions have been marked, press C-c C-c in the reconcile buffer
to “commit” the reconciliation, which will mark all of the entries
as cleared, and display the new cleared balance in the minibuffer.
- C-c C-m
- Set the default month for new entries added with C-c C-a. This is
handy if you have a large number of transactions to enter from a
previous month.
- C-c C-y
- Set the default year for new entries added with C-c C-a. This is
handy if you have a large number of transactions to enter from a
previous year.
Once you enter the reconcile buffer, there are several key commands
available:
- RET
- Visit the ledger file entry corresponding to the reconcile entry.
- C-c C-c
- Commit the reconcialation. This marks all of the marked transactions
as “cleared”, saves the ledger file, and then displays the new
cleared balance.
- C-l
- Refresh the reconcile buffer by re-reading transactions from the
ledger data file.
- SPC
- Toggle the transaction under point as cleared.
- a
- Add a new entry to the ledger data file, and refresh the reconcile
buffer to include its transactions (if the entry is added to the same
account as the one being reconciled).
- d
- Delete the entry related to the transaction under point. Note: This
may result in multiple transactions being deleted.
- n
- Move to the next line.
- p
- Move to the previous line.
- C-c C-r
- r
- Attempt to auto-reconcile the transactions to the entered balance. If
it can do so, it will mark all those transactions as pending that
would yield the specified balance.
- C-x C-s
- s
- Save the ledger data file, and show the current cleared balance for
the account being reconciled.
- q
- Quit the reconcile buffer.
There is also an emacs command which can be used to output
reports in a format directly read
-able from Emacs Lisp.