1 ;;; ob-fomus.el --- org-babel functions for fomus evaluation
3 ;; Copyright (C) 2011-2012 Torsten Anders
5 ;; Author: Torsten Anders
6 ;; Keywords: literate programming, reproducible research
7 ;; Homepage: http://orgmode.org
12 ;; This program 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, or (at your option)
17 ;; This program 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; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25 ;; Boston, MA 02110-1301, USA.
29 ;; Org-Babel support for evaluating Fomus source code.
30 ;; For information on Fomus see http://fomus.sourceforge.net/
32 ;; This differs from most standard languages in that
34 ;; 1) there is no such thing as a "session" in fomus
36 ;; 2) we are generally only going to return results of type "file"
38 ;; 3) we are adding the "file" and "cmdline" header arguments
40 ;; 4) there are no variables (at least for now)
46 (defvar org-babel-default-header-args
:fomus
47 '((:results .
"file") (:exports .
"results"))
48 "Default arguments to use when evaluating a fomus source block.")
50 (defun org-babel-expand-body:fomus
(body params
)
51 "Expand BODY according to PARAMS, return the expanded body."
52 (let ((vars (mapcar #'cdr
(org-babel-get-header params
:var
))))
55 (let ((name (symbol-name (car pair
)))
58 (replace-regexp-in-string
59 (concat "\$" (regexp-quote name
))
60 (if (stringp value
) value
(format "%S" value
))
65 (defun org-babel-execute:fomus
(body params
)
66 "Execute a block of Fomus code with org-babel.
67 This function is called by `org-babel-execute-src-block'."
68 (let* ((result-params (cdr (assoc :result-params params
)))
69 (out-file (cdr (assoc :file params
)))
70 (cmdline (cdr (assoc :cmdline params
)))
71 (cmd (or (cdr (assoc :cmd params
)) "fomus"))
72 (in-file (org-babel-temp-file "fomus-" ".fms")))
73 (with-temp-file in-file
74 (insert (org-babel-expand-body:fomus body params
)))
76 ;; (message (concat cmd
77 ;; " " (org-babel-process-file-name in-file)
79 ;; " -o " (org-babel-process-file-name out-file)))
82 " " (org-babel-process-file-name in-file
)
84 " -o " (org-babel-process-file-name out-file
)) "")
85 nil
)) ;; signal that output has already been written to file
87 (defun org-babel-prep-session:fomus
(session params
)
88 "Return an error because Fomus does not support sessions."
89 (error "Fomus does not support sessions"))
93 ;;; ob-fomus.el ends here