[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[O] [BABEL] BUG: Can't pass format string (-F) to ledger
From: |
Viktor Rosenfeld |
Subject: |
[O] [BABEL] BUG: Can't pass format string (-F) to ledger |
Date: |
Sat, 14 May 2011 16:41:15 +0200 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
Hi,
I'm having trouble passing format strings (-F) to ledger using
org-babel. When I pass -F to :cmdline, I get the following error:
Not enough arguments for format string.
This appears to be a problem with the %-markup in the format string.
Posted below is a sample org file containing the steps to reproduce
the error and the expected results.
Cheers,
Viktor
* Setup babel
We need ledger and shell support.
#+begin_src emacs-lisp :results silent
(require 'ob-ledger)
(require 'ob-sh)
#+end_src
* Sample data
Here's some sample data:
- monthly budget 100 € for food
- spent 10 € on groceries
- spent 5 € taxi fare
#+srcname: sample-data
#+begin_src ledger :noweb yes :tangle sample.ledger
~ Monthly
Expenses:Food 100,00 €
Assets
2011/05/13 Groceries
Expenses:Food 10,00 €
Assets
2011/05/13 Taxi fare
Expenses 5,00 €
Assets
#+end_src
#+results: sample-data
: -15,00 € Assets
: 15,00 € Expenses
If you tangle the code above, this block should also produce a balance:
#+begin_src sh :results output
cat sample.ledger | ledger -f - bal
#+end_src
#+results:
: -15,00 € Assets
: 15,00 € Expenses
* How to reproduce the error
I want to create a table containing the budgeted accounts as well as unbudgeted
expenses:
#+begin_src ledger :noweb yes :cmdline -F "%A\t%t\n" -p 2011/5 --budget -M reg
^Expenses
<<sample-data>>
#+end_src
#+begin_src ledger :noweb yes :cmdline -F "%D\t%P\t%t\n" -p 2011/5 --unbudgeted
reg ^Expenses
<<sample-data>>
#+end_src
Evaluating these blocks produces the error. The problem appears to be
the percentage signs. For example, the following works, producing two
lines for the balance block shown above.
#+begin_src ledger :noweb yes :cmdline -F "LINE\n" bal
<<sample-data>>
#+end_src
#+results:
: LINE
: LINE
* Expected results
Here are the same commands (as I understand it) on the shell.
Bundgeted accounts:
#+begin_src sh
cat sample.ledger | \
ledger -f - -F "%A\t%t\n" -p 2011/5 --budget -M reg ^Expenses
#+end_src
#+results:
| Expenses:Food | -90,00 € |
Unbudgeted expenses:
#+begin_src sh
cat sample.ledger | \
ledger -f - -F "%D\t%P\t%t\n" -p 2011/5 --unbudgeted reg ^Expenses
#+end_src
#+results:
| 2011/05/13 | Taxi fare | 5,00 € |
- [O] [BABEL] BUG: Can't pass format string (-F) to ledger,
Viktor Rosenfeld <=