emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Orgmode] Re: [Babel] Handling of errors when using Ledger


From: Dan
Subject: [Orgmode] Re: [Babel] Handling of errors when using Ledger
Date: Thu, 25 Nov 2010 16:32:49 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)



Eric S Fraga <ucecesf <at> ucl.ac.uk> writes:

> 
> On Tue, 12 Oct 2010 21:58:46 +0200, Sébastien Vauban <wxhgmqzgwmuf <at>
spammotel.com> wrote:
> > 
> > Hi Dan,
> > 
> > Dan Davison wrote:
> > > Sébastien Vauban writes:
> > > [...]
> > >> Let's imagine I thought (which was the case at some point) I needed to
> > >> enclose the parameters between quotes:
> > >>
> > >> #+srcname: quoted-params
> > >> #+begin_src ledger :cmdline "reg unknown" :noweb yes :session
> > >> <<data>>
> > >> #+end_src
> > >>
> > >> #+results: quoted-params
> > >>
> > >> Nothing is returned. In fact, I would expect an error to be thrown [...] 

[...]

> > > Babel has a standard mechanism for evaluating shell commands and 
> > > displaying
> > > errors if any. It is the function `org-babel-eval' in ob-eval.el. The
> > > problem is that ob-ledger is not using this mechanism.

[...]

This patch should make ob-ledger use the common org-babel error mechanism. It is
in branch ledger of the main repo. However, I'm not yet a ledger user. Could
someone test it?

Incidentally, can any gnus users tell me -- is there a non-painful way of
retrieving an old message from nntp in order to create a reply in the correct
thread? Or do you hack the headers to make it appear in the right thread? I'm
using the gmane web interface to send this.

Thanks,

Dan

----------------------------------------------------------
diff --git a/lisp/ob-ledger.el b/lisp/ob-ledger.el
index 33ec9d3..f06ea5d 100644
--- a/lisp/ob-ledger.el
+++ b/lisp/ob-ledger.el
@@ -43,24 +43,15 @@
   '((:results . "output") (:cmdline . "bal"))
   "Default arguments to use when evaluating a ledger source block.")
 
+(defvar org-babel-ledger-command "ledger"
+  "Command to invoke ledger")
+
 (defun org-babel-execute:ledger (body params)
   "Execute a block of Ledger entries with org-babel.  This function is
 called by `org-babel-execute-src-block'."
-  (message "executing Ledger source code block")
-  (let ((result-params (split-string (or (cdr (assoc :results params)) "")))
-       (cmdline (cdr (assoc :cmdline params)))
-        (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"
-                    " -f " (org-babel-process-file-name in-file)
-                    " " cmdline))
-    (with-output-to-string
-      (shell-command (concat "ledger"
-                            " -f " (org-babel-process-file-name in-file)
-                            " " cmdline
-                            " > " (org-babel-process-file-name out-file))))
-    (with-temp-buffer (insert-file-contents out-file) (buffer-string))))
+  (org-babel-eval
+   (concat org-babel-ledger-command " " (cdr (assoc :cmdline params)))
+   body))
 
 (defun org-babel-prep-session:ledger (session params)
   (error "Ledger does not support sessions"))
----------------------------------------------------------

> 
> Please do!!  As the original author (basing my code on other babel
> codes, mind you), I am happy to lose this fight   I really don't
> know enough babel to make the changes required quickly and I also am
> struggling with "free" time at the moment.
> 
> 
> 







reply via email to

[Prev in Thread] Current Thread [Next in Thread]