Next: Introduction to Ledger-mode, Previous: (dir), Up: (dir) [Contents][Index]
Ledger is a command line accounting tool that provides double-entry accounting based on a text journal. It provides no bells or whistles, and returns the user to the days before user interfaces were even a 1twinkling in their father’s CRT.
Ledger-mode assists you in maintaining input files for Ledger, running reports and much more...
Next: The Ledger Buffer, Previous: Top, Up: Top [Contents][Index]
• Quick Installation: | ||
• Menus: | ||
• Quick Demo: |
Next: Menus, Previous: Introduction to Ledger-mode, Up: Introduction to Ledger-mode [Contents][Index]
The Emacs lisp source for Ledger-mode is included with the source distribution of Ledger. It is entirely included in the lisp subdirectory. To use Ledger-mode, include the following in your Emacs initialization file (~/.emacs, ~/.emacs.d/init.el, or ~/.Aquamacs/Preferences.el).
(add-to-list 'load-path (expand-file-name "/path/to/ledger/source/lisp/")) (load "ledger-mode") (add-to-list 'auto-mode-alist '("\\.ledger$" . ledger-mode))
This sets up Emacs to automatically recognize files that end with .ledger and start Ledger-mode. Nothing else should be required as long as the ledger command line utility is properly installed.
Next: Quick Demo, Previous: Quick Installation, Up: Introduction to Ledger-mode [Contents][Index]
The vast majority of Ledger-mode functionality is available from the Emacs menu system. The keystrokes are shown in the menu to help you learn the faster keyboard methods.
Previous: Menus, Up: Introduction to Ledger-mode [Contents][Index]
Load the demo file demo.ledger from the Ledger source test/input directory. The ledger will be loaded and font highlighted. At this point you could manually edit transactions and run Ledger from a convenient command line.
• Quick Add: | ||
• Reconciliation: | ||
• Reports: | ||
• Narrowing: |
Next: Reconciliation, Previous: Quick Demo, Up: Quick Demo [Contents][Index]
As simple as the Ledger transaction format is, it can still be daunting to add many transactions manually. Ledger provides two way to add transactions with minimal typing. Both are based on the idea that most transactions are repetitions of earlier transactions.
In the demo.ledger buffer enter a date using the correct format. Then type the first few characters of another payee in the demo.ledger buffer. Type C-c TAB. Ledger-mode will search for a Payee that has the same beginning and copy the rest of the transaction to you new entry.
Additionally you can use the ledger xact
command, by either
typing C-c C-a or using ‘Add Transaction’ menu entry. Then
typing a close match to the payee. Ledger-mode will call ledger
xact
with the data you enter and place the transaction in the proper
chronological place in the ledger.
Next: Reports, Previous: Quick Add, Up: Quick Demo [Contents][Index]
The biggest task of maintaining a ledger is ensuring that it matches the outside world. This process is called reconciliation (see Basics of Reconciliation) and can be quite onerous. Ledger-mode attempts to make it as painless as possible.
In the demo.ledger buffer type C-c C-r. Emacs will prompt for an account to reconcile in the Minibuffer. Enter ‘Checking’. Emacs will then prompt for a target value. The target value is the amount you want the cleared transactions in the buffer to total. Normally this would be the ending value from your bank statement, or the latest value in your on-line transaction summary. Enter ‘1710’. Note that Ledger-mode assumes your are using ‘$’ (USD) as your default commodity, this can be easily changed in the customization variables. See Ledger-mode Customization.
You now see a list of uncleared transactions in a buffer below the demo.ledger buffer. Touching the SPC bar will mark a transaction as pending and display the current cleared (and pending) balance, along with the difference remaining to meet your target. Clear the first three transactions, and you will see the difference to target reach ‘$0’. End the reconciliation by typing C-c C-c. This saves the demo.ledger buffer and marks the transactions and finally cleared. Type q to close out the reconciliation buffer.
Next: Narrowing, Previous: Reconciliation, Up: Quick Demo [Contents][Index]
The real power of Ledger is in it reporting capabilities. Reports can be run and displayed in a separate Emacs buffer. In the demo.ledger buffer, type C-c C-o C-r. In the Minibuffer Emacs will prompt for a report name. There are a few built-in reports, and you can add any report you need See Adding and Editing Reports.
In the Minibuffer type ‘account’. When prompted for an account type ‘checking’. In another buffer you will see a Ledger register report. You can move around the buffer, with the point on a transaction, type C-c C-c. Ledger-mode will take you directly to that transaction in the demo.ledger buffer.
Another built-in report is the balance report. In the demo.ledger buffer, type C-c C-o C-r. When prompted for a report to run, type ‘bal’, and a balance report of all accounts will be shown.
Previous: Reports, Up: Quick Demo [Contents][Index]
A ledger file can get very large. It can be helpful to collapse the
buffer to display only the transactions you are interested in.
Ledger-mode copies the occur
mode functionality. Typing
C-c C-f and entering any regex in the Minibuffer will show only
transactions that match the regex. The regex can be on any field, or
amount.
Next: The Reconcile Buffer, Previous: Introduction to Ledger-mode, Up: Top [Contents][Index]
• Adding Transactions: | ||
• Copying Transactions: | ||
• Editing Amounts: | ||
• Marking Transactions: | ||
• Deleting Transactions: | ||
• Sorting Transactions: | ||
• Narrowing Transactions: |
Next: Copying Transactions, Previous: The Ledger Buffer, Up: The Ledger Buffer [Contents][Index]
Beyond the two ways of quickly adding transactions (see Quick Add) Ledger-mode assists you by providing robust TAB completion for payees and accounts. Ledger-mode will scan the existing buffer for payees and accounts. Included files are not currently included in the completion scan. Repeatedly hitting TAB will cycle through the possible completions.
Ledger-mode can also help you keep your amounts in alignment. Setting ledger-post-auto-adjust-amounts to true tells Ledger-mode to automatically place any amounts such that their last digit is aligned to the column specified by ledger-post-amount-alignment-column, which defaults to ‘52’. See Ledger Post Customization Group.
• Quick Balance Display: |
Previous: Adding Transactions, Up: Adding Transactions [Contents][Index]
You will often want to quickly check the balance of an account. The easiest way it to position point on the account you are interested in, and type C-c C-p. The Minibuffer will ask you to verify the name of the account you want, if it is already correct hit RET, then the balance of the account will be displayed in the Minibuffer.
Next: Editing Amounts, Previous: Adding Transactions, Up: The Ledger Buffer [Contents][Index]
An easy way to copy a transaction is to type C-c C-k or menu entry ‘Copy Trans at Point’. You will be prompted the new date for the copied transaction, and after having confirmed with RET, new transaction will be inserted at date position in buffer.
Next: Marking Transactions, Previous: Copying Transactions, Up: The Ledger Buffer [Contents][Index]
GNU Emacs Calculator, aka ‘Calc’, is a very powerful Reverse Polish
Notation calculator built into all recent version of Emacs. Ledger-mode
makes it easy to calculate values for amount by integrating
Calc
. With the point anywhere in the same line as a posting,
typing C-c C-b will bring up the Calc buffer, and push the
current amount for the posting onto the top of the Calc
stack.
Perform any calculations you need to arrive at the final value, then
type y to yank the value at the top of stack back into the ledger
buffer. Note: Calc
does not directly support commas as
decimal separators. Ledger-mode will translate values from
decimal-comma format to decimal-period format for use in Calc
,
but it cannot intercept the value being yanked form the Calc
stack, so decimal-comma users will have to manually replace the period
with a comma.
Next: Deleting Transactions, Previous: Editing Amounts, Up: The Ledger Buffer [Contents][Index]
Ledger considers transaction or posting to be in one of three states: uncleared, cleared, and pending. For calculation Ledger ignores these states unless specifically instructed to use them. Ledger-mode assigns some additional meaning to the states:
Clearing complete transactions is done by typing C-c C-e with point in a transaction. This places an asterisk ‘*’ after the date. Clearing individual postings is done by typing C-c C-c while in a posting. This places an asterisk prior to the posting.
Next: Sorting Transactions, Previous: Marking Transactions, Up: The Ledger Buffer [Contents][Index]
Along with normal buffer editing methods to delete text, Ledger-mode provides an easy way to delete the transaction under point: C-c C-d. The advantage to using this method is that the complete transaction operation is in the undo buffer.
Next: Narrowing Transactions, Previous: Deleting Transactions, Up: The Ledger Buffer [Contents][Index]
As you operating on the Ledger files, they may become disorganized. For the most part, Ledger doesn’t care, but our human brains prefer a bit of order. Sorting the transactions in a buffer into chronological order can help bring order to chaos. Either using ‘Sort Region’ menu entry or typing C-c C-s will sort all of the transactions in a region by date. Ledger-mode isn’t particularly smart about handling dates and it simply sorts the transactions using the string at the beginning of the transaction. So, you should use the preferred ISO 8601 standard date format ‘YYYY/MM/DD’ which easily sorts.
Note, there is a menu entry ‘Sort Buffer’ to sort the entire buffer. Special transactions like automated transaction, will be moved in the sorting process and may not function correctly afterwards. For this reason there is no key sequence.
You can limit the allowed sort region by using embedded Ledger-mode markup within your ledger. For example:
<<< information to not sort >>> ; Ledger-mode: Start sort <<< transactions to sort >>> ; Ledger-mode: End sort <<< information to not sort >>>
You can use menu entries ‘Mark Sort Beginning’ to insert start and ‘Mark Sort End’ to insert end markers. These functions will automatically delete old markers and put new new marker at point.
Previous: Sorting Transactions, Up: The Ledger Buffer [Contents][Index]
Often you will want to run Ledger register reports just to look at a specific set of transactions. If you don’t need the running total calculation handled by Ledger, Ledger-mode provides a rapid way of narrowing what is displayed in the buffer in a way that is simpler than the Ledger register command.
Based on the Emacs Occur mode by Alexey Veretennikov, Ledger-occur hides all transactions that do not meet a specific regular expression. The regular expression can match on any part of the transaction. If you want to find all transactions whose amount ends in ‘.37’, you can do that (I don’t know why, but hey, whatever ever floats you aerostat).
Using C-c C-f or the ‘Narrow to Regex’ menu entry, enter a regular expression in the Minibuffer. Ledger-mode will hide all other transactions. For details of the regular expression syntax, see (emacs)Syntax of Regular Expressions or (elisp)Regular Expressions. A few examples using the demo.ledger are given here:
Show only transactions that have a posting to the ‘Groceries’ account.
Show only transactions occurring in January of 2011.
Show only transactions occurring on the 25th of the month in 2011.
Show only transactions with payees or accounts or comments containing. ‘auto’
Show only transactions with any line ending with ‘harley’.
To show back all transactions simply invoke ‘Narrow to Regex’ or C-c C-f again.
Next: The Report Buffer, Previous: The Ledger Buffer, Up: Top [Contents][Index]
Next: Starting a Reconciliation, Previous: The Reconcile Buffer, Up: The Reconcile Buffer [Contents][Index]
Even in this relatively modern era, financial transactions do not happen instantaneously, unless you are paying cash. When you swipe your debit card the money may take several days to actually come out of your account, or a check may take several days to clear. That is the root of the difference between obligating funds and expending funds. Obligation says you have agreed to pay it, the expenditure doesn’t happen until the money actually leaves your account. Or in the case of receiving payment, you have an account receivable until the money has actually made it to you.
After an account has been reconciled you have verified that all the transactions in that account have been correctly recorded and all parties agree.
Next: Mark Transactions Pending, Previous: Basics of Reconciliation, Up: The Reconcile Buffer [Contents][Index]
To start reconciling an account you must have a target, both the transactions that you know about and the transactions the bank knows about. You can get this from a monthly statement, or from checking your on-line transaction history. It also helps immensely to know the final cleared balance you are aiming for.
Use menu ‘Reconcile Account’ or C-c C-r and enter the account you wish to reconcile in the Minibuffer. Ledger-mode is not particular about what you enter for the account. You can leave it blank and *Reconcile* buffer will show you all uncleared transactions. After you enter the account enter the target amount. Ledger expects you to enter an amount with a commodity. It assumes initially that you are using ‘$’ (USD) as your default commodity. If you are working in a different currency you can change the default in variable ledger-reconcile-default-commodity to whatever you need. If you work in multiple commodities simply enter the commoditized amount (for example ‘340 VSDX’, for 340 shares of VSDX).
Ledger-mode reconcile cannot currently reconcile accounts that have multiple commodities, such as brokerage accounts. You may use reconciliation mode to clear transactions, but balance calculations will not display the complete list of commodities.
Next: Edit Transactions During Reconciliation, Previous: Starting a Reconciliation, Up: The Reconcile Buffer [Contents][Index]
The *Reconcile* buffer will show all the uncleared transactions that meet the criteria set in the regex. By default uncleared transactions are shown in red. When you have verified that a transaction has been correctly and completely recorded by the opposing party, mark the transaction as pending using the SPC bar. Continue this process until you agree with the opposing party and the difference from your target is zero.
Next: Finalize Reconciliation, Previous: Mark Transactions Pending, Up: The Reconcile Buffer [Contents][Index]
If you find errors during reconciliation. You can visit the transaction under point in the *Reconcile* buffer by hitting the RET key. This will take you to the transaction in the Ledger buffer. When you have finished editing the transaction saving the buffer will automatically return you to the *Reconcile* buffer and you can mark the transaction if appropriate.
Next: Adding and Deleting Transactions during Reconciliation, Previous: Edit Transactions During Reconciliation, Up: The Reconcile Buffer [Contents][Index]
Once you have marked all transactions as pending and the cleared balance is correct. Finish the reconciliation by typing C-c C-c. This marks all pending transaction as cleared and saves the ledger buffer.
Next: Changing Reconciliation Account, Previous: Finalize Reconciliation, Up: The Reconcile Buffer [Contents][Index]
While reconciling, you may find new transactions that need to be entered into your ledger. Simply type a to bring up the quick add for the ledger buffer.
Typing d will delete the transaction under point in the *Reconcile* buffer from the ledger buffer.
Next: Changing Reconciliation Target, Previous: Adding and Deleting Transactions during Reconciliation, Up: The Reconcile Buffer [Contents][Index]
You can conveniently switch the account being reconciled by typing g, and entering a new account to reconcile. This simply restarts the reconcile process. Any transactions that were marked ‘pending’ in the ledger buffer are left in that state when the account is switched.
Previous: Changing Reconciliation Account, Up: The Reconcile Buffer [Contents][Index]
If for some reason during reconciliation your target amount changes, type t and enter the new target value.
Next: Scheduling Transactions, Previous: The Reconcile Buffer, Up: Top [Contents][Index]
• Running Basic Reports: | ||
• Adding and Editing Reports: | ||
• Reversing Report Order: |
Next: Adding and Editing Reports, Previous: The Report Buffer, Up: The Report Buffer [Contents][Index]
The real power behind Ledger is in its amazing reporting capability. Ledger-mode provides easy facility to run reports directly from Emacs. It has four reports built-in and facilities for adding custom reports.
Typing C-c C-o C-r or using menu ‘Ledger Run Report’ prompt for the name of a saved report. The built-in reports are:
Produce a balance reports of all accounts.
Produce a register report of all transactions.
Prompt for a payee, then produce a register report of all transactions involving that payee.
Prompt for an account, then produce a register report of all transactions involving that account.
Next: Reversing Report Order, Previous: Running Basic Reports, Up: The Report Buffer [Contents][Index]
• Expansion Formats: | ||
• Make Report Transactions Active: |
If you type a report name that Ledger-mode doesn’t recognize it will prompt you for a ledger command line to run. That command is automatically saved with the name given and you can re-run it at any time.
There are two ways to edit the command line for a report. The first is to provide a prefix argument to the run-report command. For example, type M-1 C-c C-o C-r. This will prompt you for the report name, then present the report command line to be edited. When you hit RET, the report will be run, but it will not be permanently saved. If you want to save it, type S in the *Ledger Report* buffer you will have the option to give it a new name, or overwrite the old report.
Deleting reports is accomplished by typing C-c C-o C-e or using ‘Edit Reports’ menu in the ledger buffer, or typing e in the *Ledger Report* buffer. This takes you to the Emacs customization window for the Ledger Reports variables. Use the widgets to delete the report you want removed.
Next: Make Report Transactions Active, Previous: Adding and Editing Reports, Up: Adding and Editing Reports [Contents][Index]
It is sometimes convenient to leave room to customize a report without saving the command line every time. For example running a register report for a specific account, enter at runtime by the user. The built-in report account does exactly that, using a variable expansion to prompt the user for the account to use. There are four variables that can be expanded to run a report:
Returns the file to be operated on.
Prompts for a payee.
Prompt for an account.
Prompt for a tag value.
You can use these expansion values in your ledger report commands. For example, if you wanted to specify a register report the displayed transactions from a user-determined account with a particular meta-data tag value, you specify the following command line:
ledger -f %(ledger-file) reg %(account) \ --limit \"tag('my-tag') =~/%(value)/\"
Note how the double-quotes are escaped with back-slashes.
Previous: Expansion Formats, Up: Adding and Editing Reports [Contents][Index]
In a large register report it is convenient to be able to jump to the source transaction. Ledger-mode will automatically include source information in every register file that doesn’t contain a --subtotal option. It does this by adding --prepend-format='%(filename):%(beg_line):' to the register report command-line you specify. You should never have to see this, but if there is an error in your ledger output this additional information may not get stripped out of the visible report.
Previous: Adding and Editing Reports, Up: The Report Buffer [Contents][Index]
Often, banks show their on-line transaction histories with the most recent transaction at the top. Ledger itself cannot do a sensible ledger report in reverse chronological order, if you sort on reverse date the calculation will also run in the opposite direction. If you want to compare a ledger register report to a bank report with the most recent transactions at the top, type R in the *Ledger Report* buffer and it will reverse the order of the transactions and maintain the proper mathematical sense.
Next: Customizing Ledger-mode, Previous: The Report Buffer, Up: Top [Contents][Index]
The Ledger program provide for automating transactions but these transaction aren’t “real”, they only exist inside a ledger session and are not reflected in the actual data file. Many transactions are very repetitive, but may vary slightly in the date they occur on, or the amount. Some transactions are weekly, monthly, quarterly or annually. Ledger mode provides a way to schedule upcoming transaction with a flexible scheduler that allows you to specify the transactions in a separate ledger file and calculate the upcoming occurrences of those transactions. You can then copy the transactions into your live data file.
• Specifying Upcoming Transactions: |
Up: Scheduling Transactions [Contents][Index]
The format for specifying transactions is identical to Ledger’s file format with the exception of the date field. The data field is modified by surrounding it with brackets and using wild cards to specity free months or years.
Next: Generating Ledger Regression Tests, Previous: Scheduling Transactions, Up: Top [Contents][Index]
• Ledger-mode Customization: | ||
• Customization Variables: |
Next: Customization Variables, Previous: Customizing Ledger-mode, Up: Customizing Ledger-mode [Contents][Index]
Ledger-mode has several options available for configuration. All options can be configured through the Emacs customization menus, or specified in your Emacs initialization file. The complete list of options is shown below. To change the option using the Emacs customization menu, simply chose customize in the Options menu and look for Ledger under the data options. Alternately you can choose ‘Customize Specific Group’ and enter ‘Ledger’ as the group.
Previous: Ledger-mode Customization, Up: Customizing Ledger-mode [Contents][Index]
Next: Ledger Reconcile Customization Group, Previous: Customization Variables, Up: Customization Variables [Contents][Index]
If non-nil, use a custom face for transactions shown in ledger-occur mode using ledger-occur-xact-face.
If non-nil, clear whole transactions, not individual postings.
If non-nil, highlight transaction under point using ledger-font-highlight-face.
Next: Ledger Report Customization Group, Previous: Ledger Customization Group, Up: Customization Variables [Contents][Index]
The default commodity for use in target calculations in ledger reconcile. Defaults to ‘$’ (USD).
Name to use for reconciliation buffer. Defaults to *Reconcile*.
If non-nil, limit transactions shown in main buffer to those matching the reconcile regex.
If non-nil, then when the cursor is moved to a new transaction in the reconcile window.
If non-nil, make the reconcile window appear along the bottom of the register window and resize.
If non-nil, then toggle between uncleared and pending ‘!’. If false toggle between uncleared and cleared ‘*’.
Next: Ledger Faces Customization Group, Previous: Ledger Reconcile Customization Group, Up: Customization Variables [Contents][Index]
Definition of reports to run.
An alist mapping ledger report format specifiers to implementing functions.
Next: Ledger Post Customization Group, Previous: Ledger Report Customization Group, Up: Customization Variables [Contents][Index]
Ledger Faces: Ledger-mode highlighting
Default face for Ledger.
Default face for cleared ‘*’ transactions.
Default face for transaction under point.
Default face for pending ‘!’ transactions.
Default face for other transactions.
Face for Ledger accounts.
Face for cleared Ledger accounts.
Face for Ledger pending accounts.
Face for Ledger amounts.
Default face for Ledger occur mode hidden transactions.
Default face for Ledger occur mode shown transactions.
Face for Ledger comments.
Default face for uncleared transactions in the reconcile window.
Default face for cleared ‘*’ transactions in the reconcile window.
Default face for pending ‘!’ transactions in the reconcile window.
FIXME
Next: Ledger Exec Customization Group, Previous: Ledger Faces Customization Group, Up: Customization Variables [Contents][Index]
Ledger Post:
If non-nil, then automatically align amounts to column specified in ledger-post-amount-alignment-column.
The column Ledger-mode uses to align amounts.
Default indentation for account transactions in an entry.
Which completion engine to use: iswitchb, ido, or built-in.
Next: Ledger Test Customization Group, Previous: Ledger Post Customization Group, Up: Customization Variables [Contents][Index]
Ledger Exec: Interface to the Ledger command-line accounting program.
Path to the ledger executable.
Location of the ledger initialization file. nil if you don’t have one.
Next: Ledger Texi Customization Group, Previous: Ledger Exec Customization Group, Up: Customization Variables [Contents][Index]
Directory where the Ledger sources are located.
Directory where the debug binary.
Previous: Ledger Test Customization Group, Up: Customization Variables [Contents][Index]
Location for sample data to be used in texi tests, defaults to ~/ledger/doc/sample.dat.
texi normalization for producing ledger output, defaults to ‘--args-only --columns 80’.
Next: Embedding Example results in Ledger Documentation, Previous: Customizing Ledger-mode, Up: Top [Contents][Index]
Work in Progress.
Next: Hacking Ledger-mode, Previous: Generating Ledger Regression Tests, Up: Top [Contents][Index]
Work in Progress.
Next: Concept Index, Previous: Embedding Example results in Ledger Documentation, Up: Top [Contents][Index]
Work in Progress.
Next: Command & Variable Index, Previous: Hacking Ledger-mode, Up: Top [Contents][Index]
Jump to: | B C D G I M P R T U |
---|
Jump to: | B C D G I M P R T U |
---|
Next: Keystroke Index, Previous: Concept Index, Up: Top [Contents][Index]
Jump to: | L |
---|
Jump to: | L |
---|
Previous: Command & Variable Index, Up: Top [Contents][Index]
Jump to: | A C D E G M Q R S T Y |
---|
Jump to: | A C D E G M Q R S T Y |
---|