emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [BABEL] BUG: Can't pass format string (-F) to ledger
@ 2011-05-14 14:41 Viktor Rosenfeld
  2011-05-16 11:21 ` Eric S Fraga
  0 siblings, 1 reply; 3+ messages in thread
From: Viktor Rosenfeld @ 2011-05-14 14:41 UTC (permalink / raw)
  To: emacs-orgmode

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 € |

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-05-16 17:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-14 14:41 [BABEL] BUG: Can't pass format string (-F) to ledger Viktor Rosenfeld
2011-05-16 11:21 ` Eric S Fraga
2011-05-16 17:50   ` Viktor Rosenfeld

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).