emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Viktor Rosenfeld <listuser36@googlemail.com>
To: emacs-orgmode@gnu.org
Subject: [BABEL] BUG: Can't pass format string (-F) to ledger
Date: Sat, 14 May 2011 16:41:15 +0200	[thread overview]
Message-ID: <20110514144115.GA416@kenny.fritz.box> (raw)

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

             reply	other threads:[~2011-05-14 14:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-14 14:41 Viktor Rosenfeld [this message]
2011-05-16 11:21 ` [BABEL] BUG: Can't pass format string (-F) to ledger Eric S Fraga
2011-05-16 17:50   ` Viktor Rosenfeld

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110514144115.GA416@kenny.fritz.box \
    --to=listuser36@googlemail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).