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

* Re: [BABEL] BUG: Can't pass format string (-F) to ledger
  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
  0 siblings, 1 reply; 3+ messages in thread
From: Eric S Fraga @ 2011-05-16 11:21 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 400 bytes --]

Viktor Rosenfeld <listuser36@googlemail.com> writes:

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

yes, sorry, this is an error in formatting a message which doesn't
actually do anything.  

Can somebody please apply the attached patch?

Thanks,
eric


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: fix problems with percent signs in command line arguments --]
[-- Type: text/x-diff, Size: 507 bytes --]

diff --git a/lisp/ob-ledger.el b/lisp/ob-ledger.el
index e2709a7..e678137 100644
--- a/lisp/ob-ledger.el
+++ b/lisp/ob-ledger.el
@@ -52,7 +52,7 @@ called by `org-babel-execute-src-block'."
         (in-file (org-babel-temp-file "ledger-"))
 	(out-file (org-babel-temp-file "ledger-output-")))
     (with-temp-file in-file (insert body))
-    (message (concat "ledger"
+    (message "%s" (concat "ledger"
 		     " -f " (org-babel-process-file-name in-file)
 		     " " cmdline))
     (with-output-to-string

[-- Attachment #3: Type: text/plain, Size: 127 bytes --]


-- 
: Eric S Fraga (GnuPG: 0xC89193D8FFFCF67D) in Emacs 24.0.50.1
: using Org-mode version 7.5 (release_7.5.284.g2a8fb.dirty)

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

* Re: [BABEL] BUG: Can't pass format string (-F) to ledger
  2011-05-16 11:21 ` Eric S Fraga
@ 2011-05-16 17:50   ` Viktor Rosenfeld
  0 siblings, 0 replies; 3+ messages in thread
From: Viktor Rosenfeld @ 2011-05-16 17:50 UTC (permalink / raw)
  To: emacs-orgmode

Hi Eric,

I applied your patch locally and can confirm that it works.

Thank you,
Viktor

Eric S Fraga wrote:

> Viktor Rosenfeld <listuser36@googlemail.com> writes:
> 
> > 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.
> 
> yes, sorry, this is an error in formatting a message which doesn't
> actually do anything.  
> 
> Can somebody please apply the attached patch?
> 
> Thanks,
> eric
> 

> diff --git a/lisp/ob-ledger.el b/lisp/ob-ledger.el
> index e2709a7..e678137 100644
> --- a/lisp/ob-ledger.el
> +++ b/lisp/ob-ledger.el
> @@ -52,7 +52,7 @@ called by `org-babel-execute-src-block'."
>          (in-file (org-babel-temp-file "ledger-"))
>  	(out-file (org-babel-temp-file "ledger-output-")))
>      (with-temp-file in-file (insert body))
> -    (message (concat "ledger"
> +    (message "%s" (concat "ledger"
>  		     " -f " (org-babel-process-file-name in-file)
>  		     " " cmdline))
>      (with-output-to-string

> 
> -- 
> : Eric S Fraga (GnuPG: 0xC89193D8FFFCF67D) in Emacs 24.0.50.1
> : using Org-mode version 7.5 (release_7.5.284.g2a8fb.dirty)

^ 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).