From: Dan <dandavison7@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: [Babel] Handling of errors when using Ledger
Date: Thu, 25 Nov 2010 16:32:49 +0000 (UTC) [thread overview]
Message-ID: <loom.20101125T162526-124@post.gmane.org> (raw)
In-Reply-To: 87mxqiv7q3.wl%ucecesf@ucl.ac.uk
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.
>
>
>
next prev parent reply other threads:[~2010-11-25 16:40 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-07 11:55 [Babel] Handling of errors when using Ledger Sébastien Vauban
2010-10-07 13:36 ` Dan Davison
2010-10-12 19:58 ` Sébastien Vauban
2010-10-13 8:04 ` Eric S Fraga
2010-11-25 16:32 ` Dan [this message]
2010-11-25 19:59 ` Bernt Hansen
2010-11-25 21:00 ` [OT] retrieving old messages [WAS] " Dan Davison
2010-11-26 0:19 ` [OT] retrieving old messages Bernt Hansen
2010-11-29 2:34 ` [OT] retrieving old messages [WAS] Re: [Babel] Handling of errors when using Ledger Matt Lundin
2010-11-29 9:14 ` [OT] retrieving old messages Sébastien Vauban
2010-11-29 14:11 ` Matt Lundin
2010-11-25 21:13 ` [Babel] Handling of errors when using Ledger Sébastien Vauban
2010-11-25 20:03 ` Sébastien Vauban
2010-11-26 8:34 ` Eric S Fraga
2010-11-26 11:47 ` Dan Davison
2010-11-26 12:39 ` Eric S Fraga
2010-12-23 10:28 ` Dan Davison
2010-12-23 15:52 ` Sébastien Vauban
2010-12-23 19:07 ` Eric S Fraga
2011-03-05 0:29 ` Dan Davison
2011-03-07 9:11 ` Eric S Fraga
2010-11-27 22:04 ` [Babel] Piping between code blocks Was: " Eric Schulte
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=loom.20101125T162526-124@post.gmane.org \
--to=dandavison7@gmail.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).