summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Guerry <bzg@gnu.org>2021-09-26 13:54:54 +0200
committerBastien Guerry <bzg@gnu.org>2021-09-26 13:54:54 +0200
commitcdc1962bf25c6f0899406a1c27a41780c1bdfa02 (patch)
treea17da03aef378254e4fd50a19d487548c4cdadd7
parent8bed20b1440f4fe26505eb6107dd52038ec993fd (diff)
Migrate some packages from Org's core
-rw-r--r--README.md36
-rw-r--r--README.org34
-rw-r--r--lisp/ob-J.el189
-rw-r--r--lisp/ob-abc.el94
-rw-r--r--lisp/ob-asymptote.el138
-rw-r--r--lisp/ob-coq.el81
-rw-r--r--lisp/ob-ebnf.el81
-rw-r--r--lisp/ob-hledger.el69
-rw-r--r--lisp/ob-io.el105
-rw-r--r--lisp/ob-ledger.el69
-rw-r--r--lisp/ob-mscgen.el82
-rw-r--r--lisp/ob-picolisp.el185
-rw-r--r--lisp/ob-shen.el79
-rw-r--r--lisp/ob-vala.el114
14 files changed, 1332 insertions, 24 deletions
diff --git a/README.md b/README.md
index c4e46e9..301c56b 100644
--- a/README.md
+++ b/README.md
@@ -37,7 +37,6 @@ find after the "Homepage:" keyword in the files themselves:
- **ob-mathematica.el:** org-babel functions for Mathematica evaluation
- **org-link-edit.el:** Slurp and barf with Org links
- **ol-notmuch.el:** Links to notmuch messages
-- **ob-julia.el:** org-babel functions for julia code evaluation
- **org-notify.el:** Notifications for Org-mode
- **org-mac-link.el:** Insert org-mode links to items selected in various Mac apps
- **org-passwords.el:** org derived mode for managing passwords
@@ -123,21 +122,32 @@ find after the "Homepage:" keyword in the files themselves:
## Org Babel languages
-- **ob-arduino.el:** Org-mode Babel support for Arduino
+- **ob-J.el:** Org-mode Babel Functions for J
+- **ob-abc.el:** Org-mode Babel Functions for ABC
+- **ob-asymptote.el:** Org-mode Babel Functions for Asymptote
+- **ob-coq.el:** Org-mode Babel Functions for Coq
+- **ob-ebnf.el:** Org-mode Babel Functions for EBNF
+- **ob-hledger.el:** Org-mode Babel Functions for hledger
+- **ob-io.el:** Org-mode Babel Functions for Io
+- **ob-ledger.el:** Org-mode Babel Functions for Ledger
+- **ob-mscgen.el:** Org-mode Babel Functions for Mscgen
+- **ob-picolisp.el:** Org-mode Babel Functions for Picolisp
+- **ob-shen.el:** Org-mode Babel Functions for Shen
+- **ob-vala.el:** Org-mode Babel Functions for Vala
+- **ob-arduino.el:** Org-mode Babel Functions for Arduino
- **ob-clojure-literate.el:** Clojure's Org-mode Literate Programming
-- **ob-csharp.el:** org-babel functions for csharp evaluation
-- **ob-eukleides.el:** Org-babel functions for eukleides evaluation
-- **ob-fomus.el:** Org-babel functions for fomus evaluation
-- **ob-julia.el:** Org-babel functions for julia evaluation
-- **ob-mathematica.el:** org-babel functions for Mathematica evaluation
-- **ob-mathomatic.el:** Org-babel functions for mathomatic evaluation
-- **ob-oz.el:** Org-babel functions for Oz evaluation
+- **ob-csharp.el:** Org-mode Babel Functions for csharp evaluation
+- **ob-eukleides.el:** Org-mode Babel Functions for eukleides evaluation
+- **ob-fomus.el:** Org-mode Babel Functions for fomus evaluation
+- **ob-mathematica.el:** Org-mode Babel Functions for Mathematica evaluation
+- **ob-mathomatic.el:** Org-mode Babel Functions for mathomatic evaluation
+- **ob-oz.el:** Org-mode Babel Functions for Oz evaluation
- **ob-php.el:** Execute PHP within org-mode blocks
- **ob-redis.el:** Execute Redis queries within org-mode blocks
- **ob-sclang.el:** SCLang support for Org-mode Babel
- **ob-smiles.el:** Org-mode Babel support for SMILES
-- **ob-spice.el:** org-babel functions for spice evaluation
-- **ob-stata.el:** Org-babel functions for Stata evaluation
-- **ob-tcl.el:** Org-babel functions for tcl evaluation
-- **ob-vbnet.el:** org-babel functions for VB.Net evaluation
+- **ob-spice.el:** Org-mode Babel Functions for spice evaluation
+- **ob-stata.el:** Org-mode Babel Functions for Stata evaluation
+- **ob-tcl.el:** Org-mode Babel Functions for tcl evaluation
+- **ob-vbnet.el:** Org-mode Babel Functions for VB.Net evaluation
diff --git a/README.org b/README.org
index ddb9eef..6410042 100644
--- a/README.org
+++ b/README.org
@@ -113,19 +113,31 @@ find after the "Homepage:" keyword in the files themselves:
*** Org Babel languages
-- ob-arduino.el :: Org-mode Babel support for Arduino
+- ob-J.el :: Org-mode Babel Functions for J
+- ob-abc.el :: Org-mode Babel Functions for ABC
+- ob-asymptote.el :: Org-mode Babel Functions for Asymptote
+- ob-coq.el :: Org-mode Babel Functions for Coq
+- ob-ebnf.el :: Org-mode Babel Functions for EBNF
+- ob-hledger.el :: Org-mode Babel Functions for hledger
+- ob-io.el :: Org-mode Babel Functions for Io
+- ob-ledger.el :: Org-mode Babel Functions for Ledger
+- ob-mscgen.el :: Org-mode Babel Functions for Mscgen
+- ob-picolisp.el :: Org-mode Babel Functions for Picolisp
+- ob-shen.el :: Org-mode Babel Functions for Shen
+- ob-vala.el :: Org-mode Babel Functions for Vala
+- ob-arduino.el :: Org-mode Babel Functions for Arduino
- ob-clojure-literate.el :: Clojure's Org-mode Literate Programming
-- ob-csharp.el :: org-babel functions for csharp evaluation
-- ob-eukleides.el :: Org-babel functions for eukleides evaluation
-- ob-fomus.el :: Org-babel functions for fomus evaluation
-- ob-mathematica.el :: org-babel functions for Mathematica evaluation
-- ob-mathomatic.el :: Org-babel functions for mathomatic evaluation
-- ob-oz.el :: Org-babel functions for Oz evaluation
+- ob-csharp.el :: Org-mode Babel Functions for csharp evaluation
+- ob-eukleides.el :: Org-mode Babel Functions for eukleides evaluation
+- ob-fomus.el :: Org-mode Babel Functions for fomus evaluation
+- ob-mathematica.el :: Org-mode Babel Functions for Mathematica evaluation
+- ob-mathomatic.el :: Org-mode Babel Functions for mathomatic evaluation
+- ob-oz.el :: Org-mode Babel Functions for Oz evaluation
- ob-php.el :: Execute PHP within org-mode blocks
- ob-redis.el :: Execute Redis queries within org-mode blocks
- ob-sclang.el :: SCLang support for Org-mode Babel
- ob-smiles.el :: Org-mode Babel support for SMILES
-- ob-spice.el :: org-babel functions for spice evaluation
-- ob-stata.el :: Org-babel functions for Stata evaluation
-- ob-tcl.el :: Org-babel functions for tcl evaluation
-- ob-vbnet.el :: org-babel functions for VB.Net evaluation
+- ob-spice.el :: Org-mode Babel Functions for spice evaluation
+- ob-stata.el :: Org-mode Babel Functions for Stata evaluation
+- ob-tcl.el :: Org-mode Babel Functions for tcl evaluation
+- ob-vbnet.el :: Org-mode Babel Functions for VB.Net evaluation
diff --git a/lisp/ob-J.el b/lisp/ob-J.el
new file mode 100644
index 0000000..8dc6ba7
--- /dev/null
+++ b/lisp/ob-J.el
@@ -0,0 +1,189 @@
+;;; ob-J.el --- Babel Functions for J -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2011-2021 Free Software Foundation, Inc.
+
+;; Author: Oleh Krehel
+;; Maintainer: Joseph Novakovich <josephnovakovich@gmail.com>
+;; Keywords: literate programming, reproducible research
+;; Homepage: https://orgmode.org
+
+;; This file is not part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Org-Babel support for evaluating J code.
+;;
+;; Session interaction depends on `j-console' from package `j-mode'
+;; (available in MELPA).
+
+;;; Code:
+
+(require 'ob)
+(require 'org-macs)
+
+(declare-function j-console-ensure-session "ext:j-console" ())
+
+(defcustom org-babel-J-command "jconsole"
+ "Command to call J."
+ :group 'org-babel
+ :version "26.1"
+ :package-version '(Org . "9.0")
+ :type 'string)
+
+(defun org-babel-expand-body:J (body _params &optional _processed-params)
+ "Expand BODY according to PARAMS, return the expanded body.
+PROCESSED-PARAMS isn't used yet."
+ (org-babel-J-interleave-echos-except-functions body))
+
+(defun org-babel-J-interleave-echos (body)
+ "Interleave echo',' between each source line of BODY."
+ (mapconcat #'identity (split-string body "\n") "\necho','\n"))
+
+(defun org-babel-J-interleave-echos-except-functions (body)
+ "Interleave echo',' between source lines of BODY that aren't functions."
+ (if (obj-string-match-m "\\(?:^\\|\n\\)[^\n]*\\(?:0\\|1\\|2\\|3\\|4\\|dyad\\) : 0\n.*\n)\\(?:\n\\|$\\)" body)
+ (let ((s1 (substring body 0 (match-beginning 0)))
+ (s2 (match-string 0 body))
+ (s3 (substring body (match-end 0))))
+ (concat
+ (if (string= s1 "")
+ ""
+ (concat (org-babel-J-interleave-echos s1)
+ "\necho','\n"))
+ s2
+ "\necho','\n"
+ (org-babel-J-interleave-echos-except-functions s3)))
+ (org-babel-J-interleave-echos body)))
+
+(defalias 'org-babel-execute:j 'org-babel-execute:J)
+
+(defun org-babel-execute:J (body params)
+ "Execute a block of J code BODY.
+PARAMS are given by org-babel.
+This function is called by `org-babel-execute-src-block'."
+ (message "executing J source code block")
+ (let* ((processed-params (org-babel-process-params params))
+ (sessionp (cdr (assq :session params)))
+ (sit-time (let ((sit (assq :sit params)))
+ (if sit (cdr sit) .1)))
+ (full-body (org-babel-expand-body:J
+ body params processed-params))
+ (tmp-script-file (org-babel-temp-file "J-src")))
+ (org-babel-j-initiate-session sessionp)
+ (org-babel-J-strip-whitespace
+ (if (string= sessionp "none")
+ (progn
+ (with-temp-file tmp-script-file
+ (insert full-body))
+ (org-babel-eval (format "%s < %s" org-babel-J-command tmp-script-file) ""))
+ (org-babel-J-eval-string full-body sit-time)))))
+
+(defun org-babel-J-eval-string (str sit-time)
+ "Sends STR to the `j-console-cmd' session and execute it."
+ (let ((session (j-console-ensure-session)))
+ (with-current-buffer (process-buffer session)
+ (goto-char (point-max))
+ (insert (format "\n%s\n" str))
+ (let ((beg (point)))
+ (comint-send-input)
+ (sit-for sit-time)
+ (buffer-substring-no-properties
+ beg (point-max))))))
+
+(defun org-babel-J-strip-whitespace (str)
+ "Remove whitespace from jconsole output STR."
+ (mapconcat
+ #'identity
+ (delete "" (mapcar
+ #'org-babel-J-print-block
+ (split-string str "^ *,\n" t)))
+ "\n\n"))
+
+(defun obj-get-string-alignment (str)
+ "Return a number to describe STR alignment.
+STR represents a table.
+Positive/negative/zero result means right/left/undetermined.
+Don't trust first line."
+ (let* ((str (org-trim str))
+ (lines (split-string str "\n" t))
+ n1 n2)
+ (cond ((<= (length lines) 1)
+ 0)
+ ((= (length lines) 2)
+ ;; numbers are right-aligned
+ (if (and
+ (numberp (read (car lines)))
+ (numberp (read (cadr lines)))
+ (setq n1 (obj-match-second-space-right (nth 0 lines)))
+ (setq n2 (obj-match-second-space-right (nth 1 lines))))
+ n2
+ 0))
+ ((not (obj-match-second-space-left (nth 0 lines)))
+ 0)
+ ((and
+ (setq n1 (obj-match-second-space-left (nth 1 lines)))
+ (setq n2 (obj-match-second-space-left (nth 2 lines)))
+ (= n1 n2))
+ n1)
+ ((and
+ (setq n1 (obj-match-second-space-right (nth 1 lines)))
+ (setq n2 (obj-match-second-space-right (nth 2 lines)))
+ (= n1 n2))
+ (- n1))
+ (t 0))))
+
+(defun org-babel-J-print-block (x)
+ "Prettify jconsole output X."
+ (let* ((x (org-trim x))
+ (a (obj-get-string-alignment x))
+ (lines (split-string x "\n" t))
+ b)
+ (cond ((< a 0)
+ (setq b (obj-match-second-space-right (nth 0 lines)))
+ (concat (make-string (+ a b) ? ) x))
+ ((> a 0)
+ (setq b (obj-match-second-space-left (nth 0 lines)))
+ (concat (make-string (- a b) ? ) x))
+ (t x))))
+
+(defun obj-match-second-space-left (s)
+ "Return position of leftmost space in second space block of S or nil."
+ (and (string-match "^ *[^ ]+\\( \\)" s)
+ (match-beginning 1)))
+
+(defun obj-match-second-space-right (s)
+ "Return position of rightmost space in second space block of S or nil."
+ (and (string-match "^ *[^ ]+ *\\( \\)[^ ]" s)
+ (match-beginning 1)))
+
+(defun obj-string-match-m (regexp string &optional start)
+ "Call (string-match REGEXP STRING START).
+REGEXP is modified so that .* matches newlines as well."
+ (string-match
+ (replace-regexp-in-string "\\.\\*" "[\0-\377[:nonascii:]]*" regexp)
+ string
+ start))
+
+(defun org-babel-j-initiate-session (&optional session)
+ "Initiate a J session.
+SESSION is a parameter given by org-babel."
+ (unless (string= session "none")
+ (require 'j-console)
+ (j-console-ensure-session)))
+
+(provide 'ob-J)
+
+;;; ob-J.el ends here
diff --git a/lisp/ob-abc.el b/lisp/ob-abc.el
new file mode 100644
index 0000000..837feaf
--- /dev/null
+++ b/lisp/ob-abc.el
@@ -0,0 +1,94 @@
+;;; ob-abc.el --- Org Babel Functions for ABC -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2013-2021 Free Software Foundation, Inc.
+
+;; Author: William Waites
+;; Maintainer: William Waites
+;; Keywords: literate programming, music
+;; Homepage: https://www.tardis.ed.ac.uk/~wwaites
+
+;; This file is not part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;; This file adds support to Org Babel for music in ABC notation.
+;;; It requires that the abcm2ps program is installed.
+;;; See http://moinejf.free.fr/
+
+;;; Code:
+
+(require 'ob)
+
+;; optionally define a file extension for this language
+
+(add-to-list 'org-babel-tangle-lang-exts '("abc" . "abc"))
+
+;; optionally declare default header arguments for this language
+(defvar org-babel-default-header-args:abc
+ '((:results . "file") (:exports . "results"))
+ "Default arguments to use when evaluating an ABC source block.")
+
+(defun org-babel-expand-body:abc (body params)
+ "Expand BODY according to PARAMS, return the expanded body."
+ (let ((vars (org-babel--get-vars params)))
+ (mapc
+ (lambda (pair)
+ (let ((name (symbol-name (car pair)))
+ (value (cdr pair)))
+ (setq body
+ (replace-regexp-in-string
+ (concat "\\$" (regexp-quote name))
+ (if (stringp value) value (format "%S" value))
+ body))))
+ vars)
+ body))
+
+(defun org-babel-execute:abc (body params)
+ "Execute a block of ABC code with org-babel.
+This function is called by `org-babel-execute-src-block'."
+ (message "executing Abc source code block")
+ (let* ((cmdline (cdr (assq :cmdline params)))
+ (out-file (let ((file (cdr (assq :file params))))
+ (if file (replace-regexp-in-string "\\.pdf$" ".ps" file)
+ (error "abc code block requires :file header argument"))))
+ (in-file (org-babel-temp-file "abc-"))
+ (render (concat "abcm2ps" " " cmdline
+ " -O " (org-babel-process-file-name out-file)
+ " " (org-babel-process-file-name in-file))))
+ (with-temp-file in-file (insert (org-babel-expand-body:abc body params)))
+ (org-babel-eval render "")
+ ;;; handle where abcm2ps changes the file name (to support multiple files
+ (when (or (string= (file-name-extension out-file) "eps")
+ (string= (file-name-extension out-file) "svg"))
+ (rename-file (concat
+ (file-name-sans-extension out-file) "001."
+ (file-name-extension out-file))
+ out-file t))
+ ;;; if we were asked for a pdf...
+ (when (string= (file-name-extension (cdr (assq :file params))) "pdf")
+ (org-babel-eval (concat "ps2pdf" " " out-file " " (cdr (assq :file params))) ""))
+ ;;; indicate that the file has been written
+ nil))
+
+;; This function should be used to assign any variables in params in
+;; the context of the session environment.
+(defun org-babel-prep-session:abc (_session _params)
+ "Return an error because abc does not support sessions."
+ (error "ABC does not support sessions"))
+
+(provide 'ob-abc)
+
+;;; ob-abc.el ends here
diff --git a/lisp/ob-asymptote.el b/lisp/ob-asymptote.el
new file mode 100644
index 0000000..86f7773
--- /dev/null
+++ b/lisp/ob-asymptote.el
@@ -0,0 +1,138 @@
+;;; ob-asymptote.el --- Babel Functions for Asymptote -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2009-2021 Free Software Foundation, Inc.
+
+;; Author: Eric Schulte
+;; Maintainer: Luc Pellissier <luc.pellissier@crans.org>
+;; Keywords: literate programming, reproducible research
+;; Homepage: https://orgmode.org
+
+;; This file is not part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Org-Babel support for evaluating asymptote source code.
+;;
+;; This differs from most standard languages in that
+;;
+;; 1) there is no such thing as a "session" in asymptote
+;;
+;; 2) we are generally only going to return results of type "file"
+;;
+;; 3) we are adding the "file" and "cmdline" header arguments, if file
+;; is omitted then the -V option is passed to the asy command for
+;; interactive viewing
+
+;;; Requirements:
+
+;; - The asymptote program :: http://asymptote.sourceforge.net/
+;;
+;; - asy-mode :: Major mode for editing asymptote files
+
+;;; Code:
+(require 'ob)
+
+(defvar org-babel-tangle-lang-exts)
+(add-to-list 'org-babel-tangle-lang-exts '("asymptote" . "asy"))
+
+(defvar org-babel-default-header-args:asymptote
+ '((:results . "file") (:exports . "results"))
+ "Default arguments when evaluating an Asymptote source block.")
+
+(defun org-babel-execute:asymptote (body params)
+ "Execute a block of Asymptote code.
+This function is called by `org-babel-execute-src-block'."
+ (let* ((out-file (cdr (assq :file params)))
+ (format (or (file-name-extension out-file)
+ "pdf"))
+ (cmdline (cdr (assq :cmdline params)))
+ (in-file (org-babel-temp-file "asymptote-"))
+ (cmd
+ (concat "asy "
+ (if out-file
+ (concat
+ "-globalwrite -f " format
+ " -o " (org-babel-process-file-name out-file))
+ "-V")
+ " " cmdline
+ " " (org-babel-process-file-name in-file))))
+ (with-temp-file in-file
+ (insert (org-babel-expand-body:generic
+ body params
+ (org-babel-variable-assignments:asymptote params))))
+ (message cmd) (shell-command cmd)
+ nil)) ;; signal that output has already been written to file
+
+(defun org-babel-prep-session:asymptote (_session _params)
+ "Return an error if the :session header argument is set.
+Asymptote does not support sessions."
+ (error "Asymptote does not support sessions"))
+
+(defun org-babel-variable-assignments:asymptote (params)
+ "Return list of asymptote statements assigning the block's variables."
+ (mapcar #'org-babel-asymptote-var-to-asymptote
+ (org-babel--get-vars params)))
+
+(defun org-babel-asymptote-var-to-asymptote (pair)
+ "Convert an elisp value into an Asymptote variable.
+The elisp value PAIR is converted into Asymptote code specifying
+a variable of the same value."
+ (let ((var (car pair))
+ (val (let ((v (cdr pair)))
+ (if (symbolp v) (symbol-name v) v))))
+ (cond
+ ((integerp val)
+ (format "int %S=%S;" var val))
+ ((floatp val)
+ (format "real %S=%S;" var val))
+ ((stringp val)
+ (format "string %S=\"%s\";" var val))
+ ((and (listp val) (not (listp (car val))))
+ (let* ((type (org-babel-asymptote-define-type val))
+ (fmt (if (eq 'string type) "\"%s\"" "%s"))
+ (vect (mapconcat (lambda (e) (format fmt e)) val ", ")))
+ (format "%s[] %S={%s};" type var vect)))
+ ((listp val)
+ (let* ((type (org-babel-asymptote-define-type val))
+ (fmt (if (eq 'string type) "\"%s\"" "%s"))
+ (array (mapconcat (lambda (row)
+ (concat "{"
+ (mapconcat (lambda (e) (format fmt e))
+ row ", ")
+ "}"))
+ val ",")))
+ (format "%S[][] %S={%s};" type var array))))))
+
+(defun org-babel-asymptote-define-type (data)
+ "Determine type of DATA.
+
+DATA is a list. Return type as a symbol.
+
+The type is `string' if any element in DATA is a string.
+Otherwise, it is either `real', if some elements are floats, or
+`int'."
+ (letrec ((type 'int)
+ (find-type
+ (lambda (row)
+ (dolist (e row type)
+ (cond ((listp e) (setq type (funcall find-type e)))
+ ((stringp e) (throw 'exit 'string))
+ ((floatp e) (setq type 'real)))))))
+ (catch 'exit (funcall find-type data)) type))
+
+(provide 'ob-asymptote)
+
+;;; ob-asymptote.el ends here
diff --git a/lisp/ob-coq.el b/lisp/ob-coq.el
new file mode 100644
index 0000000..16143be
--- /dev/null
+++ b/lisp/ob-coq.el
@@ -0,0 +1,81 @@
+;;; ob-coq.el --- Babel Functions for Coq -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2010-2021 Free Software Foundation, Inc.
+
+;; Author: Eric Schulte
+;; Maintainer: Luc Pellissier <luc.pellissier@crans.org>
+;; Keywords: literate programming, reproducible research
+;; Homepage: https://orgmode.org
+
+;; This file is not part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Rudimentary support for evaluating Coq code blocks. Currently only
+;; session evaluation is supported. Requires both coq.el and
+;; coq-inferior.el, both of which are distributed with Coq.
+;;
+;; https://coq.inria.fr/
+
+;;; Code:
+(require 'ob)
+
+(declare-function run-coq "ext:coq-inferior.el" (cmd))
+(declare-function coq-proc "ext:coq-inferior.el" ())
+
+(defvar coq-program-name "coqtop"
+ "Name of the coq toplevel to run.")
+
+(defvar org-babel-coq-buffer "*coq*"
+ "Buffer in which to evaluate coq code blocks.")
+
+(defun org-babel-coq-clean-prompt (string)
+ (if (string-match "^[^[:space:]]+ < " string)
+ (substring string 0 (match-beginning 0))
+ string))
+
+(defun org-babel-execute:coq (body params)
+ (let ((full-body (org-babel-expand-body:generic body params))
+ (session (org-babel-coq-initiate-session))
+ (pt (lambda ()
+ (marker-position
+ (process-mark (get-buffer-process (current-buffer)))))))
+ (org-babel-coq-clean-prompt
+ (org-babel-comint-in-buffer session
+ (let ((start (funcall pt)))
+ (with-temp-buffer
+ (insert full-body)
+ (comint-send-region (coq-proc) (point-min) (point-max))
+ (comint-send-string (coq-proc)
+ (if (string= (buffer-substring (- (point-max) 1) (point-max)) ".")
+ "\n"
+ ".\n")))
+ (while (equal start (funcall pt)) (sleep-for 0.1))
+ (buffer-substring start (funcall pt)))))))
+
+(defun org-babel-coq-initiate-session ()
+ "Initiate a coq session.
+If there is not a current inferior-process-buffer in SESSION then
+create one. Return the initialized session."
+ (unless (fboundp 'run-coq)
+ (error "`run-coq' not defined, load coq-inferior.el"))
+ (save-window-excursion (run-coq coq-program-name))
+ (sit-for 0.1)
+ (get-buffer org-babel-coq-buffer))
+
+(provide 'ob-coq)
+
+;;; ob-coq.el ends here
diff --git a/lisp/ob-ebnf.el b/lisp/ob-ebnf.el
new file mode 100644
index 0000000..2f5f330
--- /dev/null
+++ b/lisp/ob-ebnf.el
@@ -0,0 +1,81 @@
+;;; ob-ebnf.el --- Babel Functions for EBNF -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2013-2021 Free Software Foundation, Inc.
+
+;; Author: Michael Gauland
+;; Keywords: literate programming, reproducible research
+;; Homepage: https://orgmode.org
+
+;; This file is not part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Org-Babel support for using ebnf2ps to generate encapsulated postscript
+;; railroad diagrams. It recognizes these arguments:
+;;
+;; :file is required; it must include the extension '.eps.' All the rules
+;; in the block will be drawn in the same file. This is done by
+;; inserting a '[<file>' comment at the start of the block (see the
+;; documentation for ebnf-eps-buffer for more information).
+;;
+;; :style specifies a value in ebnf-style-database. This provides the
+;; ability to customize the output. The style can also specify the
+;; grammar syntax (by setting ebnf-syntax); note that only ebnf,
+;; iso-ebnf, and yacc are supported by this file.
+
+;;; Requirements:
+
+;;; Code:
+(require 'ob)
+(require 'ebnf2ps)
+
+;; optionally declare default header arguments for this language
+(defvar org-babel-default-header-args:ebnf '((:style . nil)))
+
+;; Use ebnf-eps-buffer to produce an encapsulated postscript file.
+;;
+(defun org-babel-execute:ebnf (body params)
+ "Execute a block of Ebnf code with org-babel.
+This function is called by `org-babel-execute-src-block'."
+ (save-excursion
+ (let* ((dest-file (cdr (assq :file params)))
+ (dest-dir (file-name-directory dest-file))
+ (dest-root (file-name-sans-extension
+ (file-name-nondirectory dest-file)))
+ (style (cdr (assq :style params)))
+ (result nil))
+ (with-temp-buffer
+ (when style (ebnf-push-style style))
+ (let ((comment-format
+ (cond ((string= ebnf-syntax 'yacc) "/*%s*/")
+ ((string= ebnf-syntax 'ebnf) ";%s")
+ ((string= ebnf-syntax 'iso-ebnf) "(*%s*)")
+ (t (setq result
+ (format "EBNF error: format %s not supported."
+ ebnf-syntax))))))
+ (setq ebnf-eps-prefix dest-dir)
+ (insert (format comment-format (format "[%s" dest-root)))
+ (newline)
+ (insert body)
+ (newline)
+ (insert (format comment-format (format "]%s" dest-root)))
+ (ebnf-eps-buffer)
+ (when style (ebnf-pop-style))))
+ result)))
+
+(provide 'ob-ebnf)
+
+;;; ob-ebnf.el ends here
diff --git a/lisp/ob-hledger.el b/lisp/ob-hledger.el
new file mode 100644
index 0000000..79afa62
--- /dev/null
+++ b/lisp/ob-hledger.el
@@ -0,0 +1,69 @@
+;;; ob-hledger.el --- Babel Functions for hledger -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2010-2021 Free Software Foundation, Inc.
+
+;; Author: Simon Michael
+;; Keywords: literate programming, reproducible research, plain text accounting
+;; Homepage: https://orgmode.org
+
+;; This file is not part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Babel support for evaluating hledger entries.
+;;
+;; Based on ob-ledger.el.
+;; If the source block is empty, hledger will use a default journal file,
+;; probably ~/.hledger.journal (it may not notice your $LEDGER_FILE env var).
+;; So make ~/.hledger.journal a symbolic link to the real file if necessary.
+
+;; TODO Unit tests are more than welcome, too.
+
+;;; Code:
+(require 'ob)
+
+(defvar org-babel-default-header-args:hledger
+ '((:results . "output") (:exports . "results") (:cmdline . "bal"))
+ "Default arguments to use when evaluating a hledger source block.")
+
+(defun org-babel-execute:hledger (body params)
+ "Execute a block of hledger entries with org-babel.
+This function is called by `org-babel-execute-src-block'."
+ (message "executing hledger source code block")
+ (letrec ( ;(result-params (split-string (or (cdr (assq :results params)) "")))
+ (cmdline (cdr (assq :cmdline params)))
+ (in-file (org-babel-temp-file "hledger-"))
+ (out-file (org-babel-temp-file "hledger-output-"))
+ (hledgercmd (concat "hledger"
+ (if (> (length body) 0)
+ (concat " -f " (org-babel-process-file-name in-file))
+ "")
+ " " cmdline)))
+ (with-temp-file in-file (insert body))
+;; TODO This is calling for some refactoring:
+;; (concat "hledger" (if ...) " " cmdline)
+;; could be built only once and bound to a symbol.
+ (message "%s" hledgercmd)
+ (with-output-to-string
+ (shell-command (concat hledgercmd " > " (org-babel-process-file-name out-file))))
+ (with-temp-buffer (insert-file-contents out-file) (buffer-string))))
+
+(defun org-babel-prep-session:hledger (_session _params)
+ (error "hledger does not support sessions"))
+
+(provide 'ob-hledger)
+
+;;; ob-hledger.el ends here
diff --git a/lisp/ob-io.el b/lisp/ob-io.el
new file mode 100644
index 0000000..3a2fea2
--- /dev/null
+++ b/lisp/ob-io.el
@@ -0,0 +1,105 @@
+;;; ob-io.el --- Babel Functions for Io -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2012-2021 Free Software Foundation, Inc.
+
+;; Author: Andrzej Lichnerowicz
+;; Keywords: literate programming, reproducible research
+;; Homepage: https://orgmode.org
+
+;; This file is not part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;; Currently only supports the external execution. No session support yet.
+;; :results output -- runs in scripting mode
+;; :results output repl -- runs in repl mode
+
+;;; Requirements:
+;; - Io language :: https://iolanguage.org/
+;; - Io major mode :: Can be installed from Io sources
+;; https://github.com/stevedekorte/io/blob/master/extras/SyntaxHighlighters/Emacs/io-mode.el
+
+;;; Code:
+(require 'ob)
+
+(defvar org-babel-tangle-lang-exts) ;; Autoloaded
+(add-to-list 'org-babel-tangle-lang-exts '("io" . "io"))
+(defvar org-babel-default-header-args:io '())
+(defvar org-babel-io-command "io"
+ "Name of the command to use for executing Io code.")
+
+(defun org-babel-execute:io (body params)
+ "Execute a block of Io code with org-babel.
+This function is called by `org-babel-execute-src-block'."
+ (message "executing Io source code block")
+ (let* ((processed-params (org-babel-process-params params))
+ (session (org-babel-io-initiate-session (nth 0 processed-params)))
+ (result-params (nth 2 processed-params))
+ (result-type (cdr (assq :result-type params)))
+ (full-body (org-babel-expand-body:generic
+ body params))
+ (result (org-babel-io-evaluate
+ session full-body result-type result-params)))
+
+ (org-babel-reassemble-table
+ result
+ (org-babel-pick-name
+ (cdr (assq :colname-names params)) (cdr (assq :colnames params)))
+ (org-babel-pick-name
+ (cdr (assq :rowname-names params)) (cdr (assq :rownames params))))))
+
+(defvar org-babel-io-wrapper-method
+ "(
+%s
+) asString print
+")
+
+
+(defun org-babel-io-evaluate (session body &optional result-type result-params)
+ "Evaluate BODY in external Io process.
+If RESULT-TYPE equals `output' then return standard output as a string.
+If RESULT-TYPE equals `value' then return the value of the last statement
+in BODY as elisp."
+ (when session (error "Sessions are not (yet) supported for Io"))
+ (pcase result-type
+ (`output
+ (if (member "repl" result-params)
+ (org-babel-eval org-babel-io-command body)
+ (let ((src-file (org-babel-temp-file "io-")))
+ (progn (with-temp-file src-file (insert body))
+ (org-babel-eval
+ (concat org-babel-io-command " " src-file) "")))))
+ (`value (let* ((src-file (org-babel-temp-file "io-"))
+ (wrapper (format org-babel-io-wrapper-method body)))
+ (with-temp-file src-file (insert wrapper))
+ (let ((raw (org-babel-eval
+ (concat org-babel-io-command " " src-file) "")))
+ (org-babel-result-cond result-params
+ raw
+ (org-babel-script-escape raw)))))))
+
+(defun org-babel-prep-session:io (_session _params)
+ "Prepare SESSION according to the header arguments specified in PARAMS."
+ (error "Sessions are not (yet) supported for Io"))
+
+(defun org-babel-io-initiate-session (&optional _session)
+ "If there is not a current inferior-process-buffer in SESSION then create.
+Return the initialized session. Sessions are not
+supported in Io."
+ nil)
+
+(provide 'ob-io)
+
+;;; ob-io.el ends here
diff --git a/lisp/ob-ledger.el b/lisp/ob-ledger.el
new file mode 100644
index 0000000..b1812ac
--- /dev/null
+++ b/lisp/ob-ledger.el
@@ -0,0 +1,69 @@
+;;; ob-ledger.el --- Babel Functions for Ledger -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2010-2021 Free Software Foundation, Inc.
+
+;; Author: Eric S Fraga
+;; Maintainer: Eric S Fraga
+;; Keywords: literate programming, reproducible research, accounting
+;; Homepage: https://orgmode.org
+
+;; This file is not part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Org-Babel support for evaluating ledger entries.
+;;
+;; This differs from most standard languages in that
+;;
+;; 1) there is no such thing as a "session" in ledger
+;;
+;; 2) we are generally only going to return output from the ledger program
+;;
+;; 3) we are adding the "cmdline" header argument
+;;
+;; 4) there are no variables
+
+;;; Code:
+(require 'ob)
+
+(defvar org-babel-default-header-args:ledger
+ '((:results . "output") (:cmdline . "bal"))
+ "Default arguments to use when evaluating a ledger source block.")
+
+(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 ((cmdline (cdr (assq :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 "%s" (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))))
+
+(defun org-babel-prep-session:ledger (_session _params)
+ (error "Ledger does not support sessions"))
+
+(provide 'ob-ledger)
+
+;;; ob-ledger.el ends here
diff --git a/lisp/ob-mscgen.el b/lisp/ob-mscgen.el
new file mode 100644
index 0000000..09f20c2
--- /dev/null
+++ b/lisp/ob-mscgen.el
@@ -0,0 +1,82 @@
+;;; ob-mscgen.el --- Babel Functions for Mscgen -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2010-2021 Free Software Foundation, Inc.
+
+;; Author: Juan Pechiar
+;; Maintainer: Justin Abrahms
+;; Keywords: literate programming, reproducible research
+;; Homepage: https://orgmode.org
+
+;; This file is not part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;;
+;; This software provides EMACS org-babel export support for message
+;; sequence charts. The mscgen utility is used for processing the
+;; sequence definition, and must therefore be installed in the system.
+;;
+;; Mscgen is available and documented at
+;; https://www.mcternan.me.uk/mscgen/index.html
+;;
+;; This code is directly inspired by Eric Schulte's ob-dot.el
+;;
+;; Example:
+;;
+;; #+begin_src mscgen :file example.png
+;; msc {
+;; A,B;
+;; A -> B [ label = "send message" ];
+;; A <- B [ label = "get answer" ];
+;; }
+;; #+end_src
+;;
+;; Header for alternative file type:
+;;
+;; #+begin_src mscgen :file ex2.svg :filetype svg
+
+;; This differs from most standard languages in that
+;;
+;; 1) there is no such thing as a "session" in mscgen
+;; 2) we are generally only going to return results of type "file"
+;; 3) we are adding the "file" and "filetype" header arguments
+;; 4) there are no variables
+
+;;; Code:
+(require 'ob)
+
+(defvar org-babel-default-header-args:mscgen
+ '((:results . "file") (:exports . "results"))
+ "Default arguments to use when evaluating a mscgen source block.")
+
+(defun org-babel-execute:mscgen (body params)
+ "Execute a block of Mscgen code with Babel.
+This function is called by `org-babel-execute-src-block'.
+Default filetype is png. Modify by setting :filetype parameter to
+mscgen supported formats."
+ (let* ((out-file (or (cdr (assq :file params)) "output.png" ))
+ (filetype (or (cdr (assq :filetype params)) "png" )))
+ (unless (cdr (assq :file params))
+ (error "ERROR: no output file specified. Add \":file name.png\" to the src header"))
+ (org-babel-eval (concat "mscgen -T " filetype " -o " out-file) body)
+ nil)) ;; signal that output has already been written to file
+
+(defun org-babel-prep-session:mscgen (_session _params)
+ "Raise an error because Mscgen doesn't support sessions."
+ (error "Mscgen does not support sessions"))
+
+(provide 'ob-mscgen)
+
+;;; ob-mscgen.el ends here
diff --git a/lisp/ob-picolisp.el b/lisp/ob-picolisp.el
new file mode 100644
index 0000000..f7faff0
--- /dev/null
+++ b/lisp/ob-picolisp.el
@@ -0,0 +1,185 @@
+;;; ob-picolisp.el --- Babel Functions for Picolisp -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2010-2021 Free Software Foundation, Inc.
+
+;; Authors: Thorsten Jolitz
+;; Eric Schulte
+;; Keywords: literate programming, reproducible research
+;; Homepage: https://orgmode.org
+
+;; This file is not part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; This library enables the use of PicoLisp in the multi-language
+;; programming framework Org-Babel. PicoLisp is a minimal yet
+;; fascinating Lisp dialect and a highly productive application
+;; framework for web-based client-server applications on top of
+;; object-oriented databases. A good way to learn PicoLisp is to first
+;; read Paul Grahams essay "The hundred year language"
+;; (http://www.paulgraham.com/hundred.html) and then study the various
+;; documents and essays published in the PicoLisp wiki
+;; (https://picolisp.com/5000/-2.html). PicoLisp is included in some
+;; GNU/Linux Distributions, and can be downloaded here:
+;; https://software-lab.de/down.html. It ships with a picolisp-mode and
+;; an inferior-picolisp-mode for Emacs (to be found in the /lib/el/
+;; directory).
+
+;; Although it might seem more natural to use Emacs Lisp for most
+;; Lisp-based programming tasks inside Org, an Emacs library written
+;; in Emacs Lisp, PicoLisp has at least two outstanding features that
+;; make it a valuable addition to Org Babel:
+
+;; PicoLisp _is_ an object-oriented database with a Prolog-based query
+;; language implemented in PicoLisp (Pilog). Database objects are
+;; first-class members of the language.
+
+;; PicoLisp is an extremely productive framework for the development
+;; of interactive web-applications (on top of a database).
+
+;;; Requirements:
+
+;;; Code:
+(require 'ob)
+(require 'comint)
+
+(declare-function run-picolisp "ext:inferior-picolisp" (cmd))
+(defvar org-babel-tangle-lang-exts) ;; Autoloaded
+
+;; optionally define a file extension for this language
+(add-to-list 'org-babel-tangle-lang-exts '("picolisp" . "l"))
+
+;;; interferes with settings in org-babel buffer?
+;; optionally declare default header arguments for this language
+;; (defvar org-babel-default-header-args:picolisp
+;; '((:colnames . "no"))
+;; "Default arguments for evaluating a picolisp source block.")
+
+(defvar org-babel-picolisp-eoe "org-babel-picolisp-eoe"
+ "String to indicate that evaluation has completed.")
+
+(defcustom org-babel-picolisp-cmd "pil"
+ "Name of command used to evaluate picolisp blocks."
+ :group 'org-babel
+ :version "24.1"
+ :type 'string)
+
+(defun org-babel-expand-body:picolisp (body params)
+ "Expand BODY according to PARAMS, return the expanded body."
+ (let ((vars (org-babel--get-vars params))
+ (print-level nil)
+ (print-length nil))
+ (if (> (length vars) 0)
+ (concat "(prog (let ("
+ (mapconcat
+ (lambda (var)
+ (format "%S '%S)"
+ (print (car var))
+ (print (cdr var))))
+ vars "\n ")
+ " \n" body ") )")
+ body)))
+
+(defun org-babel-execute:picolisp (body params)
+ "Execute a block of Picolisp code with org-babel.
+This function is called by `org-babel-execute-src-block'."
+ (message "executing Picolisp source code block")
+ (let* (
+ ;; Name of the session or "none".
+ (session-name (cdr (assq :session params)))
+ ;; Set the session if the session variable is non-nil.
+ (session (org-babel-picolisp-initiate-session session-name))
+ ;; Either OUTPUT or VALUE which should behave as described above.
+ (result-params (cdr (assq :result-params params)))
+ ;; Expand the body with `org-babel-expand-body:picolisp'.
+ (full-body (org-babel-expand-body:picolisp body params))
+ ;; Wrap body appropriately for the type of evaluation and results.
+ (wrapped-body
+ (cond
+ ((or (member "code" result-params)
+ (member "pp" result-params))
+ (format "(pretty (out \"%s\" %s))" null-device full-body))
+ ((and (member "value" result-params) (not session))
+ (format "(print (out \"%s\" %s))" null-device full-body))
+ ((member "value" result-params)
+ (format "(out \"%s\" %s)" null-device full-body))
+ (t full-body)))
+ (result
+ (if (not (string= session-name "none"))
+ ;; Session based evaluation.
+ (mapconcat ;; <- joins the list back into a single string
+ #'identity
+ (butlast ;; <- remove the org-babel-picolisp-eoe line
+ (delq nil
+ (mapcar
+ (lambda (line)
+ (org-babel-chomp ;; Remove trailing newlines.
+ (when (> (length line) 0) ;; Remove empty lines.
+ (cond
+ ;; Remove leading "-> " from return values.
+ ((and (>= (length line) 3)
+ (string= "-> " (substring line 0 3)))
+ (substring line 3))
+ ;; Remove trailing "-> <<return-value>>" on the
+ ;; last line of output.
+ ((and (member "output" result-params)
+ (string-match-p "->" line))
+ (substring line 0 (string-match "->" line)))
+ (t line)
+ )
+ ;;(if (and (>= (length line) 3);Remove leading "<-"
+ ;; (string= "-> " (substring line 0 3)))
+ ;; (substring line 3)
+ ;; line)
+ )))
+ ;; Returns a list of the output of each evaluated exp.
+ (org-babel-comint-with-output
+ (session org-babel-picolisp-eoe)
+ (insert wrapped-body) (comint-send-input)
+ (insert "'" org-babel-picolisp-eoe)
+ (comint-send-input)))))
+ "\n")
+ ;; external evaluation
+ (let ((script-file (org-babel-temp-file "picolisp-script-")))
+ (with-temp-file script-file
+ (insert (concat wrapped-body "(bye)")))
+ (org-babel-eval
+ (format "%s %s"
+ org-babel-picolisp-cmd
+ (org-babel-process-file-name script-file))
+ "")))))
+ (org-babel-result-cond result-params
+ result
+ (read result))))
+
+(defun org-babel-picolisp-initiate-session (&optional session-name)
+ "If there is not a current inferior-process-buffer in SESSION then create.
+Return the initialized session."
+ (unless (string= session-name "none")
+ (require 'inferior-picolisp)
+ ;; provide a reasonable default session name
+ (let ((session (or session-name "*inferior-picolisp*")))
+ ;; check if we already have a live session by this name
+ (if (org-babel-comint-buffer-livep session)
+ (get-buffer session)
+ (save-window-excursion
+ (run-picolisp org-babel-picolisp-cmd)
+ (rename-buffer session-name)
+ (current-buffer))))))
+
+(provide 'ob-picolisp)
+
+;;; ob-picolisp.el ends here
diff --git a/lisp/ob-shen.el b/lisp/ob-shen.el
new file mode 100644
index 0000000..6eccce1
--- /dev/null
+++ b/lisp/ob-shen.el
@@ -0,0 +1,79 @@
+;;; ob-shen.el --- Babel Functions for Shen -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2010-2021 Free Software Foundation, Inc.
+
+;; Author: Eric Schulte
+;; Keywords: literate programming, reproducible research, shen
+;; Homepage: https://orgmode.org
+
+;; This file is not part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Currently this only works using session evaluation as there is no
+;; defined method for executing shen code outside of a session.
+
+;;; Requirements:
+
+;; - shen-mode and inf-shen will soon be available through the GNU
+;; elpa, however in the interim they are available at
+;; https://github.com/eschulte/shen-mode
+
+;;; Code:
+(require 'ob)
+
+(declare-function shen-eval-defun "ext:inf-shen" (&optional and-go))
+(declare-function org-babel-ruby-var-to-ruby "ob-ruby" (var))
+
+(defvar org-babel-default-header-args:shen '()
+ "Default header arguments for shen code blocks.")
+
+(defun org-babel-expand-body:shen (body params)
+ "Expand BODY according to PARAMS, return the expanded body."
+ (let ((vars (org-babel--get-vars params)))
+ (if (> (length vars) 0)
+ (concat "(let "
+ (mapconcat (lambda (var)
+ (format "%s %s" (car var)
+ (org-babel-shen-var-to-shen (cdr var))))
+ vars " ")
+ body ")")
+ body)))
+
+(defun org-babel-shen-var-to-shen (var)
+ "Convert VAR into a shen variable."
+ (if (listp var)
+ (concat "[" (mapconcat #'org-babel-ruby-var-to-ruby var " ") "]")
+ (format "%S" var)))
+
+(defun org-babel-execute:shen (body params)
+ "Execute a block of Shen code with org-babel.
+This function is called by `org-babel-execute-src-block'."
+ (require 'inf-shen)
+ (let* ((result-params (cdr (assq :result-params params)))
+ (full-body (org-babel-expand-body:shen body params)))
+ (let ((results
+ (with-temp-buffer
+ (insert full-body)
+ (call-interactively #'shen-eval-defun))))
+ (org-babel-result-cond result-params
+ results
+ (condition-case nil (org-babel-script-escape results)
+ (error results))))))
+
+(provide 'ob-shen)
+
+;;; ob-shen.el ends here
diff --git a/lisp/ob-vala.el b/lisp/ob-vala.el
new file mode 100644
index 0000000..826d32f
--- /dev/null
+++ b/lisp/ob-vala.el
@@ -0,0 +1,114 @@
+;;; ob-vala.el --- Babel functions for Vala -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2017-2021 Free Software Foundation, Inc.
+
+;; Author: Christian Garbs <mitch@cgarbs.de>
+;; Keywords: literate programming, reproducible research
+;; Homepage: https://orgmode.org
+
+;; This file is not part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; ob-vala.el provides Babel support for the Vala language
+;; (see https://live.gnome.org/Vala for details)
+
+;;; Requirements:
+
+;; - Vala compiler binary (valac)
+;; - Vala development environment (Vala libraries etc.)
+;;
+;; vala-mode.el is nice to have for code formatting, but is not needed
+;; for ob-vala.el
+
+;;; Code:
+
+(require 'ob)
+(require 'org-macs)
+
+;; File extension.
+(add-to-list 'org-babel-tangle-lang-exts '("vala" . "vala"))
+
+;; Header arguments empty by default.
+(defvar org-babel-default-header-args:vala '())
+
+(defcustom org-babel-vala-compiler "valac"
+ "Command used to compile a C source code file into an executable.
+May be either a command in the path, like \"valac\"
+or an absolute path name, like \"/usr/local/bin/valac\".
+Parameters may be used like this: \"valac -v\""
+ :group 'org-babel
+ :version "26.1"
+ :package-version '(Org . "9.1")
+ :type 'string)
+
+;; This is the main function which is called to evaluate a code
+;; block.
+;;
+;; - run Vala compiler and create a binary in a temporary file
+;; - compiler/linker flags can be set via :flags header argument
+;; - if compilation succeeded, run the binary
+;; - commandline parameters to the binary can be set via :cmdline
+;; header argument
+;; - stdout will be parsed as RESULT (control via :result-params
+;; header argument)
+;;
+;; There is no session support because Vala is a compiled language.
+;;
+;; This function is heavily based on ob-C.el
+(defun org-babel-execute:vala (body params)
+ "Execute a block of Vala code with Babel.
+This function is called by `org-babel-execute-src-block'."
+ (message "executing Vala source code block")
+ (let* ((tmp-src-file (org-babel-temp-file
+ "vala-src-"
+ ".vala"))
+ (tmp-bin-file (org-babel-temp-file "vala-bin-" org-babel-exeext))
+ (cmdline (cdr (assq :cmdline params)))
+ (flags (cdr (assq :flags params))))
+ (with-temp-file tmp-src-file (insert body))
+ (org-babel-eval
+ (format "%s %s -o %s %s"
+ org-babel-vala-compiler
+ (mapconcat #'identity
+ (if (listp flags) flags (list flags)) " ")
+ (org-babel-process-file-name tmp-bin-file)
+ (org-babel-process-file-name tmp-src-file)) "")
+ (when (file-executable-p tmp-bin-file)
+ (let ((results
+ (org-trim
+ (org-babel-eval
+ (concat tmp-bin-file (if cmdline (concat " " cmdline) "")) ""))))
+ (org-babel-reassemble-table
+ (org-babel-result-cond (cdr (assq :result-params params))
+ (org-babel-read results)
+ (let ((tmp-file (org-babel-temp-file "vala-")))
+ (with-temp-file tmp-file (insert results))
+ (org-babel-import-elisp-from-file tmp-file)))
+ (org-babel-pick-name
+ (cdr (assq :colname-names params)) (cdr (assq :colnames params)))
+ (org-babel-pick-name
+ (cdr (assq :rowname-names params)) (cdr (assq :rownames params))))))))
+
+(defun org-babel-prep-session:vala (_session _params)
+ "Prepare a session.
+This function does nothing as Vala is a compiled language with no
+support for sessions."
+ (error "Vala is a compiled language -- no support for sessions"))
+
+(provide 'ob-vala)
+
+;;; ob-vala.el ends here