Review of Babel section. Move to Babel name according to new naming.
This commit is contained in:
parent
bd4c264f49
commit
9c5bc8f92d
1 changed files with 74 additions and 74 deletions
102
doc/ledger3.texi
102
doc/ledger3.texi
|
|
@ -4285,20 +4285,20 @@ programming. This allows you to mix text and code within the same
|
||||||
document and automatically execute code which may generate results
|
document and automatically execute code which may generate results
|
||||||
which will then appear in the text.
|
which will then appear in the text.
|
||||||
|
|
||||||
One of the languages supported by @code{org+babel} is Ledger, so that
|
One of the languages supported by Babel is Ledger, so that you can have
|
||||||
you can have ledger commands embedded in a text file and have the
|
ledger commands embedded in a text file and have the output of ledger
|
||||||
output of ledger commands also appear in the text file. The output
|
commands also appear in the text file. The output can be updated
|
||||||
can be updated whenever any new ledger entries are added.
|
whenever any new ledger entries are added.
|
||||||
|
|
||||||
For instance, the following Org mode text document snippet illustrates
|
For instance, the following Org mode text document snippet illustrates
|
||||||
a very naive but still useful of the @code{org+babel} system:
|
a very naive but still useful of the Babel system:
|
||||||
|
|
||||||
@smallexample
|
@smallexample
|
||||||
* A simple test of ledger in an org file
|
* A simple test of ledger in an org file
|
||||||
The following are some entries and I have requested that ledger be run
|
The following are some entries and I have requested that ledger be run
|
||||||
to generate a balance on the accounts. I could have asked for a
|
to generate a balance on the accounts. I could have asked for
|
||||||
register or, in fact, anything at all the ledger can do through command
|
a register or, in fact, anything at all the ledger can do through
|
||||||
line options.
|
command line options.
|
||||||
|
|
||||||
#+begin_src ledger :cmdline -s bal :results value
|
#+begin_src ledger :cmdline -s bal :results value
|
||||||
2010/01/01 * Starting balance
|
2010/01/01 * Starting balance
|
||||||
|
|
@ -4327,8 +4327,8 @@ invoke ledger on the contents of that block and generate a ``results''
|
||||||
block. The results block can appear anywhere in the file but, by
|
block. The results block can appear anywhere in the file but, by
|
||||||
default, will appear immediately below the source code block.
|
default, will appear immediately below the source code block.
|
||||||
|
|
||||||
You can combine multiple source code blocks before executing ledger
|
You can combine multiple source code blocks before executing ledger and
|
||||||
and do all kinds of other wonderful things with Babel (and org).
|
do all kinds of other wonderful things with Babel (and Org mode).
|
||||||
|
|
||||||
@node Org mode with Babel, The pricemap Command, Emacs Org mode, Reports in other Formats
|
@node Org mode with Babel, The pricemap Command, Emacs Org mode, Reports in other Formats
|
||||||
@subsection Org mode with Babel
|
@subsection Org mode with Babel
|
||||||
|
|
@ -4337,10 +4337,9 @@ Using Babel, it is possible to record financial transactions
|
||||||
conveniently in an org file and subsequently generate the financial
|
conveniently in an org file and subsequently generate the financial
|
||||||
reports required.
|
reports required.
|
||||||
|
|
||||||
With a recent version of org (7.01+), Ledger support is provided. To
|
As of Org-mode 7.01, Ledger support is provided. Check the Babel
|
||||||
use it, enable Ledger support. Check the Babel documentation on Worg
|
documentation on Worg for instructions on how to achieve this but
|
||||||
for instructions on how to achieve this but I currently do this
|
I currently do this directly as follows:
|
||||||
directly as follows:
|
|
||||||
|
|
||||||
@smallexample
|
@smallexample
|
||||||
(org-babel-do-load-languages
|
(org-babel-do-load-languages
|
||||||
|
|
@ -4356,16 +4355,17 @@ least) in which these can be included:
|
||||||
@enumerate
|
@enumerate
|
||||||
|
|
||||||
@item
|
@item
|
||||||
place all Ledger entries within one source block and execute this block
|
place all Ledger entries within one single source block and execute this
|
||||||
with different arguments to generate the appropriate reports;
|
block with different arguments to generate the appropriate reports,
|
||||||
|
|
||||||
@item
|
@item
|
||||||
place Ledger entries in more than one source block and use the noweb
|
place Ledger entries in more than one source block and use the
|
||||||
literary programming approach, supported by babel, to combine these into
|
@code{noweb} literary programming approach, supported by Babel, to
|
||||||
one block elsewhere in the file for processing by Ledger; and,
|
combine these into one block elsewhere in the file for processing by
|
||||||
|
Ledger,
|
||||||
|
|
||||||
@item
|
@item
|
||||||
place Ledger entries in different source blocks and use tangling to
|
place Ledger entries in different source blocks and use @code{tangle} to
|
||||||
generate a Ledger file which you can subsequently process using Ledger
|
generate a Ledger file which you can subsequently process using Ledger
|
||||||
directly.
|
directly.
|
||||||
@end enumerate
|
@end enumerate
|
||||||
|
|
@ -4417,13 +4417,13 @@ entries. The following is an example source block:
|
||||||
#+end_src
|
#+end_src
|
||||||
@end smallexample
|
@end smallexample
|
||||||
|
|
||||||
In this example, we have combined both expenses and income into one
|
In this example, we have combined both expenses and income into one set
|
||||||
set of Ledger entries. We can now generate register and balance
|
of Ledger entries. We can now generate register and balance reports (as
|
||||||
reports (as well as many other types of reports) using babel to invoke
|
well as many other types of reports) using Babel to invoke Ledger with
|
||||||
Ledger with specific arguments. The arguments are passed to Ledger
|
specific arguments. The arguments are passed to Ledger using the
|
||||||
using the :cmdline header argument. In the code block above, there is
|
@code{:cmdline} header argument. In the code block above, there is no
|
||||||
no such argument so the system takes the default. For Ledger code
|
such argument so the system takes the default. For Ledger code blocks,
|
||||||
blocks, the default :cmdline argument is bal and the result of
|
the default @code{:cmdline} argument is @code{bal} and the result of
|
||||||
evaluating this code block (@kbd{C-c C-c}) would be:
|
evaluating this code block (@kbd{C-c C-c}) would be:
|
||||||
|
|
||||||
@smallexample
|
@smallexample
|
||||||
|
|
@ -4434,8 +4434,8 @@ evaluating this code block (@kbd{C-c C-c}) would be:
|
||||||
@end smallexample
|
@end smallexample
|
||||||
|
|
||||||
If, instead, you wished to generate a register of all the transactions,
|
If, instead, you wished to generate a register of all the transactions,
|
||||||
you would change the #+begin_src line for the code block to include the
|
you would change the @code{#+begin_src} line for the code block to
|
||||||
required command line option:
|
include the required command line option:
|
||||||
|
|
||||||
@smallexample
|
@smallexample
|
||||||
#+begin_src ledger :cmdline reg
|
#+begin_src ledger :cmdline reg
|
||||||
|
|
@ -4445,15 +4445,15 @@ Evaluating the code block again would generate a different report.
|
||||||
|
|
||||||
Having to change the actual directive on the code block and re-evaluate
|
Having to change the actual directive on the code block and re-evaluate
|
||||||
makes it difficult to have more than one view of your transactions and
|
makes it difficult to have more than one view of your transactions and
|
||||||
financial state. Eventually, babel will support passing arguments to
|
financial state. Eventually, Babel will support passing arguments to
|
||||||
@code{#+call} evaluations of code blocks but this support is missing
|
@code{#+call} evaluations of code blocks but this support is missing
|
||||||
currently. Instead, we can use the concepts of literary programming, as
|
currently. Instead, we can use the concepts of literary programming, as
|
||||||
implemented by the noweb features of babel, to help us.
|
implemented by the @code{noweb} features of Babel, to help us.
|
||||||
|
|
||||||
@node Multiple Ledger source blocks with @command{noweb}, Income Entries, Embedded Ledger example with single source block, Org mode with Babel
|
@node Multiple Ledger source blocks with @command{noweb}, Income Entries, Embedded Ledger example with single source block, Org mode with Babel
|
||||||
@subsubsection Multiple Ledger source blocks with @command{noweb}
|
@subsubsection Multiple Ledger source blocks with @command{noweb}
|
||||||
|
|
||||||
The @command{noweb} feature of babel allows us to expand references to
|
The @command{noweb} feature of Babel allows us to expand references to
|
||||||
other code blocks within a code block. For Ledger, this can be used to
|
other code blocks within a code block. For Ledger, this can be used to
|
||||||
group transactions according to type, say, and then bring various sets
|
group transactions according to type, say, and then bring various sets
|
||||||
of transactions together to generate reports.
|
of transactions together to generate reports.
|
||||||
|
|
@ -4467,8 +4467,8 @@ these into expenses and income, as follows:
|
||||||
The first set of entries relates to income, either monthly pay or
|
The first set of entries relates to income, either monthly pay or
|
||||||
interest, all typically going into one of my bank accounts. Here, I have
|
interest, all typically going into one of my bank accounts. Here, I have
|
||||||
placed several entries, but we could have had each entry in a separate
|
placed several entries, but we could have had each entry in a separate
|
||||||
src block. Note that all code blocks you wish to refer to later must
|
@code{src} block. Note that all code blocks you wish to refer to later
|
||||||
have the :noweb yes babel header argument specified.
|
must have the @code{:noweb yes} header argument specified.
|
||||||
|
|
||||||
@smallexample
|
@smallexample
|
||||||
#+name: income
|
#+name: income
|
||||||
|
|
@ -4495,8 +4495,8 @@ have the :noweb yes babel header argument specified.
|
||||||
@subsubsection Expenses
|
@subsubsection Expenses
|
||||||
|
|
||||||
The following entries relate to personal expenses, such as rent and
|
The following entries relate to personal expenses, such as rent and
|
||||||
food. Again, these have all been placed in a single src block but could
|
food. Again, these have all been placed in a single @code{src} block but
|
||||||
have been done individually.
|
could have been done individually.
|
||||||
|
|
||||||
@smallexample
|
@smallexample
|
||||||
#+name: expenses
|
#+name: expenses
|
||||||
|
|
@ -4514,20 +4514,20 @@ have been done individually.
|
||||||
@subsubsection Financial Summaries
|
@subsubsection Financial Summaries
|
||||||
|
|
||||||
Given the ledger entries defined above in the income and expenses code
|
Given the ledger entries defined above in the income and expenses code
|
||||||
blocks, we can now refer to these using the noweb expansion
|
blocks, we can now refer to these using the noweb expansion directives,
|
||||||
directives, @code{<<name>>}. We can now define different code blocks
|
@code{<<name>>}. We can now define different code blocks to generate
|
||||||
to generate specific reports for those transactions. Below are two
|
specific reports for those transactions. Below are two examples, one to
|
||||||
examples, one to generate a balance report and one to generate
|
generate a balance report and one to generate a register report of all
|
||||||
a register report of all transactions.
|
transactions.
|
||||||
|
|
||||||
@node An overall balance summary, Generating a monthly register, Financial Summaries, Org mode with Babel
|
@node An overall balance summary, Generating a monthly register, Financial Summaries, Org mode with Babel
|
||||||
@subsubsection An overall balance summary
|
@subsubsection An overall balance summary
|
||||||
|
|
||||||
The overall balance of your account and expenditure with a breakdown
|
The overall balance of your account and expenditure with a breakdown
|
||||||
according to category is specified by passing the :cmdline bal
|
according to category is specified by passing the @code{:cmdline bal}
|
||||||
argument to Ledger. This code block can now be evaluated (@kbd{C-c
|
argument to Ledger. This code block can now be evaluated (@kbd{C-c C-c})
|
||||||
C-c}) and the results generated by incorporating the transactions
|
and the results generated by incorporating the transactions referred to
|
||||||
referred to by the @code{<<income>>} and @code{<<expenses>>} lines.
|
by the @code{<<income>>} and @code{<<expenses>>} lines.
|
||||||
|
|
||||||
@smallexample
|
@smallexample
|
||||||
#+name: balance
|
#+name: balance
|
||||||
|
|
@ -4544,8 +4544,8 @@ referred to by the @code{<<income>>} and @code{<<expenses>>} lines.
|
||||||
|
|
||||||
If you want a more detailed breakdown of where your money is and where
|
If you want a more detailed breakdown of where your money is and where
|
||||||
it has been spent, you can specify the @code{-s} flag
|
it has been spent, you can specify the @code{-s} flag
|
||||||
(i.e. @code{:cmdline -s bal}) to tell Ledger to include sub-accounts
|
(i.e. @code{:cmdline -s bal}) to tell Ledger to include sub-accounts in
|
||||||
in the report.
|
the report.
|
||||||
|
|
||||||
@smallexample
|
@smallexample
|
||||||
#+begin_src ledger :cmdline -s bal :noweb yes
|
#+begin_src ledger :cmdline -s bal :noweb yes
|
||||||
|
|
@ -4569,11 +4569,11 @@ in the report.
|
||||||
@node Generating a monthly register, Summary, An overall balance summary, Org mode with Babel
|
@node Generating a monthly register, Summary, An overall balance summary, Org mode with Babel
|
||||||
@subsubsection Generating a monthly register
|
@subsubsection Generating a monthly register
|
||||||
|
|
||||||
You can also generate a monthly register (the reg command) by
|
You can also generate a monthly register (the @command{reg} command) by
|
||||||
executing the following src block. This presents a summary of
|
executing the following @code{src} block. This presents a summary of
|
||||||
transactions for each monthly period (the @code{-M} argument) with
|
transactions for each monthly period (the @code{-M} argument) with
|
||||||
a running total in the final column (which should be 0 at the end if
|
a running total in the final column (which should be 0 at the end if all
|
||||||
all the entries are correct).
|
the entries are correct).
|
||||||
|
|
||||||
@smallexample
|
@smallexample
|
||||||
#+name: monthlyregister
|
#+name: monthlyregister
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue