123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- (require 'ob)
- (require 'org-compat)
- (defcustom org-babel-stan-cmdstan-directory nil
- "CmdStan source directory.
- 'make' will be called from this directory to compile the Stan
- block. When nil, executing Stan blocks dumps the content to a
- plain text file."
- :group 'org-babel
- :type 'string)
- (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)
- (org-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))
- (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)
|