New hook to add more properties to new agenda items, or to filter
[org-mode.git] / lisp / ob-ledger.el
blob1c48dad6294a5b49e208565c9843eef33fddfbf3
1 ;;; ob-ledger.el --- org-babel functions for ledger evaluation
3 ;; Copyright (C) 2010 Free Software Foundation, Inc.
5 ;; Author: Eric S Fraga
6 ;; Keywords: literate programming, reproducible research, accounting
7 ;; Homepage: http://orgmode.org
8 ;; Version: 7.01trans
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software: you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation, either version 3 of the License, or
15 ;; (at your option) any later version.
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
25 ;;; Commentary:
27 ;; Org-Babel support for evaluating ledger entries.
29 ;; This differs from most standard languages in that
31 ;; 1) there is no such thing as a "session" in ledger
33 ;; 2) we are generally only going to return output from the leger program
35 ;; 3) we are adding the "cmdline" header argument
37 ;; 4) there are no variables
39 ;;; Code:
40 (require 'ob)
41 (require 'org)
43 (defvar org-babel-default-header-args:ledger
44 '((:results . "output") (:cmdline . "bal"))
45 "Default arguments to use when evaluating a ledger source block.")
47 (defun org-babel-execute:ledger (body params)
48 "Execute a block of Ledger entries with org-babel. This function is
49 called by `org-babel-execute-src-block'."
50 (message "executing Ledger source code block")
51 (let ((result-params (split-string (or (cdr (assoc :results params)) "")))
52 (cmdline (cdr (assoc :cmdline params)))
53 (in-file (make-temp-file "org-babel-ledger"))
54 (out-file (make-temp-file "org-babel-ledger-output"))
56 (with-temp-file in-file (insert body))
57 (message (concat "ledger -f " in-file " " cmdline))
58 (with-output-to-string
59 (shell-command (concat "ledger -f " in-file " " cmdline " > " out-file)))
60 (with-temp-buffer (insert-file-contents out-file) (buffer-string))))
62 (defun org-babel-prep-session:ledger (session params)
63 (error "Ledger does not support sessions"))
65 (provide 'ob-ledger)
67 ;; arch-tag: 7bbb529e-95a1-4236-9d29-b0000b918c7c
69 ;;; ob-ledger.el ends here