emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/org-contrib f5edcb4: Move ob-stan.el here from Org's core


From: ELPA Syncer
Subject: [nongnu] elpa/org-contrib f5edcb4: Move ob-stan.el here from Org's core
Date: Tue, 28 Sep 2021 01:58:02 -0400 (EDT)

branch: elpa/org-contrib
commit f5edcb4de2c8a19f9a6c56fe93d219bbe87f96d5
Author: Bastien Guerry <bzg@gnu.org>
Commit: Bastien Guerry <bzg@gnu.org>

    Move ob-stan.el here from Org's core
---
 README.md       | 41 +++++++++++++--------------
 README.org      | 41 +++++++++++++--------------
 lisp/ob-stan.el | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 128 insertions(+), 40 deletions(-)

diff --git a/README.md b/README.md
index 301c56b..5df1622 100644
--- a/README.md
+++ b/README.md
@@ -34,22 +34,22 @@ later version.  See [COPYING](COPYING).
 These files are maintained in a separate repository, which you can
 find after the "Homepage:" keyword in the files themselves:
 
+-   **ob-arduino.el:** Org-mode Babel support for Arduino
+-   **ob-clojure-literate.el:** Clojure's Org-mode Literate Programming
 -   **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
--   **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
 -   **ob-php.el:** Execute PHP within org-mode blocks
 -   **ob-redis.el:** Execute Redis queries within org-mode blocks
--   **ob-arduino.el:** Org-mode Babel support for Arduino
--   **ob-spice.el:** org-babel functions for spice evaluation
 -   **ob-sclang.el:** SCLang support for Org-mode Babel
 -   **ob-smiles.el:** Org-mode Babel support for SMILES
--   **ob-clojure-literate.el:** Clojure's Org-mode Literate Programming
--   **ox-rss.el:** RSS 2.0 Back-End for Org Export Engine
+-   **ob-spice.el:** org-babel functions for spice evaluation
+-   **ol-notmuch.el:** Links to notmuch messages
 -   **org-attach-embedded-images.el:** Transmute images to attachments
+-   **org-link-edit.el:** Slurp and barf with Org links
+-   **org-mac-link.el:** Insert org-mode links to items selected in various 
Mac apps
+-   **org-notify.el:** Notifications for Org-mode
+-   **org-passwords.el:** org derived mode for managing passwords
 -   **org-velocity.el:** something like Notational Velocity for Org
+-   **ox-rss.el:** RSS 2.0 Back-End for Org Export Engine
 
 
 # Other files
@@ -68,8 +68,8 @@ find after the "Homepage:" keyword in the files themselves:
 -   **org-depend.el:** TODO dependencies for Org-mode
 -   **org-effectiveness.el:** Measuring your personal effectiveness
 -   **org-eldoc.el:** Eldoc documentation for SRC blocks
--   **org-eval-light.el:** Evaluate in-buffer code on demand
 -   **org-eval.el:** The <lisp> tag, adapted from Muse
+-   **org-eval-light.el:** Evaluate in-buffer code on demand
 -   **org-expiry.el:** Expiry mechanism for Org entries
 -   **org-git-link.el:** Provide org links to specific file version
 -   **org-interactive-query.el:** Interactive modification of tags query
@@ -122,32 +122,33 @@ find after the "Homepage:" keyword in the files 
themselves:
 
 ## Org Babel languages
 
--   **ob-J.el:** Org-mode Babel Functions for J
 -   **ob-abc.el:** Org-mode Babel Functions for ABC
+-   **ob-arduino.el:** Org-mode Babel Functions for Arduino
 -   **ob-asymptote.el:** Org-mode Babel Functions for Asymptote
+-   **ob-clojure-literate.el:** Clojure's Org-mode Literate Programming
 -   **ob-coq.el:** Org-mode Babel Functions for Coq
+-   **ob-csharp.el:** Org-mode Babel Functions for csharp evaluation
 -   **ob-ebnf.el:** Org-mode Babel Functions for EBNF
+-   **ob-eukleides.el:** Org-mode Babel Functions for eukleides evaluation
+-   **ob-fomus.el:** Org-mode Babel Functions for fomus evaluation
 -   **ob-hledger.el:** Org-mode Babel Functions for hledger
 -   **ob-io.el:** Org-mode Babel Functions for Io
+-   **ob-J.el:** Org-mode Babel Functions for J
 -   **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-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-mscgen.el:** Org-mode Babel Functions for Mscgen
 -   **ob-oz.el:** Org-mode Babel Functions for Oz evaluation
 -   **ob-php.el:** Execute PHP within org-mode blocks
+-   **ob-picolisp.el:** Org-mode Babel Functions for Picolisp
 -   **ob-redis.el:** Execute Redis queries within org-mode blocks
 -   **ob-sclang.el:** SCLang support for Org-mode Babel
+-   **ob-shen.el:** Org-mode Babel Functions for Shen
 -   **ob-smiles.el:** Org-mode Babel support for SMILES
 -   **ob-spice.el:** Org-mode Babel Functions for spice evaluation
+-   **ob-stan.el:** Babel Functions for Stan
 -   **ob-stata.el:** Org-mode Babel Functions for Stata evaluation
 -   **ob-tcl.el:** Org-mode Babel Functions for tcl evaluation
+-   **ob-vala.el:** Org-mode Babel Functions for Vala
 -   **ob-vbnet.el:** Org-mode Babel Functions for VB.Net evaluation
 
diff --git a/README.org b/README.org
index 6410042..d451778 100644
--- a/README.org
+++ b/README.org
@@ -31,22 +31,22 @@ later version.  See [[file:COPYING][COPYING]].
 These files are maintained in a separate repository, which you can
 find after the "Homepage:" keyword in the files themselves:
 
+- ob-arduino.el :: Org-mode Babel support for Arduino
+- ob-clojure-literate.el :: Clojure's Org-mode Literate Programming
 - 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
-- 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
 - ob-php.el :: Execute PHP within org-mode blocks
 - ob-redis.el :: Execute Redis queries within org-mode blocks
-- ob-arduino.el :: Org-mode Babel support for Arduino
-- ob-spice.el :: org-babel functions for spice evaluation
 - ob-sclang.el :: SCLang support for Org-mode Babel
 - ob-smiles.el :: Org-mode Babel support for SMILES
-- ob-clojure-literate.el :: Clojure's Org-mode Literate Programming
-- ox-rss.el :: RSS 2.0 Back-End for Org Export Engine
+- ob-spice.el :: org-babel functions for spice evaluation
+- ol-notmuch.el :: Links to notmuch messages
 - org-attach-embedded-images.el :: Transmute images to attachments
+- org-link-edit.el :: Slurp and barf with Org links
+- org-mac-link.el :: Insert org-mode links to items selected in various Mac 
apps
+- org-notify.el :: Notifications for Org-mode
+- org-passwords.el :: org derived mode for managing passwords
 - org-velocity.el :: something like Notational Velocity for Org
+- ox-rss.el :: RSS 2.0 Back-End for Org Export Engine
 
 ** Other files
 *** Org utils
@@ -62,8 +62,8 @@ find after the "Homepage:" keyword in the files themselves:
 - org-depend.el :: TODO dependencies for Org-mode
 - org-effectiveness.el :: Measuring your personal effectiveness
 - org-eldoc.el :: Eldoc documentation for SRC blocks
-- org-eval-light.el :: Evaluate in-buffer code on demand
 - org-eval.el :: The <lisp> tag, adapted from Muse
+- org-eval-light.el :: Evaluate in-buffer code on demand
 - org-expiry.el :: Expiry mechanism for Org entries
 - org-git-link.el :: Provide org links to specific file version
 - org-interactive-query.el :: Interactive modification of tags query
@@ -113,31 +113,32 @@ find after the "Homepage:" keyword in the files 
themselves:
 
 *** Org Babel languages
 
-- ob-J.el :: Org-mode Babel Functions for J
 - ob-abc.el :: Org-mode Babel Functions for ABC
+- ob-arduino.el :: Org-mode Babel Functions for Arduino
 - ob-asymptote.el :: Org-mode Babel Functions for Asymptote
+- ob-clojure-literate.el :: Clojure's Org-mode Literate Programming
 - ob-coq.el :: Org-mode Babel Functions for Coq
+- ob-csharp.el :: Org-mode Babel Functions for csharp evaluation
 - ob-ebnf.el :: Org-mode Babel Functions for EBNF
+- ob-eukleides.el :: Org-mode Babel Functions for eukleides evaluation
+- ob-fomus.el :: Org-mode Babel Functions for fomus evaluation
 - ob-hledger.el :: Org-mode Babel Functions for hledger
 - ob-io.el :: Org-mode Babel Functions for Io
+- ob-J.el :: Org-mode Babel Functions for J
 - 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-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-mscgen.el :: Org-mode Babel Functions for Mscgen
 - ob-oz.el :: Org-mode Babel Functions for Oz evaluation
 - ob-php.el :: Execute PHP within org-mode blocks
+- ob-picolisp.el :: Org-mode Babel Functions for Picolisp
 - ob-redis.el :: Execute Redis queries within org-mode blocks
 - ob-sclang.el :: SCLang support for Org-mode Babel
+- ob-shen.el :: Org-mode Babel Functions for Shen
 - ob-smiles.el :: Org-mode Babel support for SMILES
 - ob-spice.el :: Org-mode Babel Functions for spice evaluation
+- ob-stan.el :: Babel Functions for Stan
 - ob-stata.el :: Org-mode Babel Functions for Stata evaluation
 - ob-tcl.el :: Org-mode Babel Functions for tcl evaluation
+- ob-vala.el :: Org-mode Babel Functions for Vala
 - ob-vbnet.el :: Org-mode Babel Functions for VB.Net evaluation
diff --git a/lisp/ob-stan.el b/lisp/ob-stan.el
new file mode 100644
index 0000000..398ccec
--- /dev/null
+++ b/lisp/ob-stan.el
@@ -0,0 +1,86 @@
+;;; ob-stan.el --- Babel Functions for Stan          -*- lexical-binding: t; 
-*-
+
+;; Copyright (C) 2015-2021 Free Software Foundation, Inc.
+
+;; Author: Kyle Meyer
+;; Keywords: literate programming, reproducible research
+;; Homepage: https://git.kyleam.com/ob-stan
+
+;; 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 Stan [1] source code.
+;;
+;; Evaluating a Stan block can produce two different results.
+;;
+;; 1) Dump the source code contents to a file.
+;;
+;;    This file can then be used as a variable in other blocks, which
+;;    allows interfaces like RStan to use the model.
+;;
+;; 2) Compile the contents to a model file.
+;;
+;;    This provides access to the CmdStan interface.  To use this, set
+;;    `org-babel-stan-cmdstan-directory' and provide a :file argument
+;;    that does not end in ".stan".
+;;
+;; For more information and usage examples, visit
+;; https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-stan.html
+;;
+;; [1] https://mc-stan.org/
+
+;;; Code:
+(require 'ob)
+(require 'org-compat)
+
+(defcustom org-babel-stan-cmdstan-directory nil
+  "CmdStan source directory.
+Call \"make\" from this directory to compile the Stan block.
+When nil, executing Stan blocks dumps the content to a file."
+  :group 'org-babel
+  :type '(choice
+         (directory :tag "Compilation directory")
+         (const :tag "Dump to a file" nil)))
+
+(defvar org-babel-default-header-args:stan
+  '((:results . "file")))
+
+(defun org-babel-execute:stan (body params)
+  "Generate Stan file from BODY according to PARAMS.
+A :file header argument must be given.  If
+`org-babel-stan-cmdstan-directory' is non-nil and the file name
+does not have a \".stan\" extension, save an intermediate
+\".stan\" file and compile the block to the named file.
+Otherwise, write the Stan code directly to the named file."
+  (let ((file (expand-file-name
+              (or (cdr (assq :file params))
+                  (user-error "Set :file argument to execute Stan blocks")))))
+    (if (or (not org-babel-stan-cmdstan-directory)
+           (string-match-p "\\.stan\\'" file))
+       (with-temp-file file (insert body))
+      (with-temp-file (concat file ".stan") (insert body))
+      (let ((default-directory org-babel-stan-cmdstan-directory))
+       (call-process-shell-command (concat "make " file))))
+    nil))              ; Signal that output has been written to file.
+
+(defun org-babel-prep-session:stan (_session _params)
+  "Return an error because Stan does not support sessions."
+  (user-error "Stan does not support sessions"))
+
+(provide 'ob-stan)
+
+;;; ob-stan.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]