1 ;;; ob-fomus.el --- Org-babel functions for fomus evaluation
3 ;; Copyright (C) 2011-2013 Torsten Anders
5 ;; Author: Torsten Anders
6 ;; Keywords: literate programming, reproducible research
7 ;; Homepage: http://orgmode.org
9 ;; This file is not part of GNU Emacs.
11 ;; This program is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 3, or (at your option)
16 ;; This program is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
28 ;; Org-Babel support for evaluating Fomus source code.
29 ;; For information on Fomus see http://fomus.sourceforge.net/
31 ;; This differs from most standard languages in that
33 ;; 1) there is no such thing as a "session" in fomus
35 ;; 2) we are generally only going to return results of type "file"
37 ;; 3) we are adding the "file" and "cmdline" header arguments
39 ;; 4) there are no variables (at least for now)
45 (defvar org-babel-default-header-args
:fomus
46 '((:results .
"file") (:exports .
"results"))
47 "Default arguments to use when evaluating a fomus source block.")
49 (defun org-babel-expand-body:fomus
(body params
)
50 "Expand BODY according to PARAMS, return the expanded body."
51 (let ((vars (mapcar #'cdr
(org-babel-get-header params
:var
))))
54 (let ((name (symbol-name (car pair
)))
57 (replace-regexp-in-string
58 (concat "\$" (regexp-quote name
))
59 (if (stringp value
) value
(format "%S" value
))
64 (defun org-babel-execute:fomus
(body params
)
65 "Execute a block of Fomus code with org-babel.
66 This function is called by `org-babel-execute-src-block'."
67 (let* ((result-params (cdr (assoc :result-params params
)))
68 (out-file (cdr (assoc :file params
)))
69 (cmdline (cdr (assoc :cmdline params
)))
70 (cmd (or (cdr (assoc :cmd params
)) "fomus"))
71 (in-file (org-babel-temp-file "fomus-" ".fms")))
72 (with-temp-file in-file
73 (insert (org-babel-expand-body:fomus body params
)))
75 ;; (message (concat cmd
76 ;; " " (org-babel-process-file-name in-file)
78 ;; " -o " (org-babel-process-file-name out-file)))
81 " " (org-babel-process-file-name in-file
)
83 " -o " (org-babel-process-file-name out-file
)) "")
84 nil
)) ;; signal that output has already been written to file
86 (defun org-babel-prep-session:fomus
(session params
)
87 "Return an error because Fomus does not support sessions."
88 (error "Fomus does not support sessions"))
92 ;;; ob-fomus.el ends here