From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dan Subject: Re: [Babel] Handling of errors when using Ledger Date: Thu, 25 Nov 2010 16:32:49 +0000 (UTC) Message-ID: References: <877hhudxor.fsf@mundaneum.com> <87sk0inmys.fsf@stats.ox.ac.uk> <807hhnfaix.fsf@mundaneum.com> <87mxqiv7q3.wl%ucecesf@ucl.ac.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Received: from [140.186.70.92] (port=39025 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PLerj-0004C0-5a for emacs-orgmode@gnu.org; Thu, 25 Nov 2010 11:40:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PLerh-0008U2-Dk for emacs-orgmode@gnu.org; Thu, 25 Nov 2010 11:40:10 -0500 Received: from lo.gmane.org ([80.91.229.12]:35670) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PLerh-0008Tq-30 for emacs-orgmode@gnu.org; Thu, 25 Nov 2010 11:40:09 -0500 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1PLerd-0002V2-CE for emacs-orgmode@gnu.org; Thu, 25 Nov 2010 17:40:05 +0100 Received: from 94.196.153.77.threembb.co.uk ([94.196.153.77]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 25 Nov 2010 17:40:05 +0100 Received: from dandavison7 by 94.196.153.77.threembb.co.uk with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 25 Nov 2010 17:40:05 +0100 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Eric S Fraga ucl.ac.uk> writes: > > On Tue, 12 Oct 2010 21:58:46 +0200, Sébastien Vauban 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 > > >> <> > > >> #+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. > > >