1 ;;; ob-sclang.el --- SCLang support for Org Mode Babel.
2 ;;; -*- coding: utf-8 -*-
4 ;; Copyright (C) 2017-2021 Free Software Foundation, Inc.
6 ;; Authors: stardiviner <numbchild@gmail.com>
7 ;; Package-Version: 0.1
8 ;; Keywords: babel sclang
9 ;; Homepage: https://repo.or.cz/ob-sclang.git
11 ;; This file is not part of GNU Emacs.
13 ;; GNU Emacs is free software: you can redistribute it and/or modify
14 ;; it under the terms of the GNU General Public License as published by
15 ;; the Free Software Foundation, either version 3 of the License, or
16 ;; (at your option) any later version.
18 ;; GNU Emacs is distributed in the hope that it will be useful,
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;; GNU General Public License for more details.
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
28 ;; `ob-sclang' requires `sclang' from SuperCollider.
29 ;; Usually SuperCollider dependencies for Emacs are at /usr/share/emacs/site-lisp/SuperCollider/
30 ;; You can install SuperCollider following this article:
31 ;; https://github.com/supercollider/supercollider#building-the-source-code
35 ;; Support to evaluate sclang Org-mode src block with function `sclang-eval-string'.
39 ;; #+BEGIN_SRC sclang :results none
40 ;; "Hello World".postln;
43 ;; *NOTE* Temporary output to org-babel result output is not supported.
44 ;; Because `sclang-eval-string' will send output to Sclang Post Buffer.
45 ;; And command line `sclang' execute will not automatically stop after finished execution.
47 ;; #+BEGIN_SRC sclang :results none
48 ;; // modulate a sine frequency and a noise amplitude with another sine
49 ;; // whose frequency depends on the horizontal mouse pointer position
51 ;; var x = SinOsc.ar(MouseX.kr(1, 100));
52 ;; SinOsc.ar(300 * x + 800, 0, 0.1)
54 ;; PinkNoise.ar(0.1 * x + 0.1)
60 ;;; ----------------------------------------------------------------------------
63 (require 'sclang nil t
)
65 (defgroup ob-sclang nil
66 "org-mode blocks for SuperCollider SCLang."
70 (defun org-babel-execute:sclang
(body params
)
71 "Org-mode Babel sclang hook for evaluate `BODY' with `PARAMS'."
72 (unless (or (equal (buffer-name) sclang-post-buffer
)
75 (sclang-eval-string body t
))
77 (defvar org-babel-default-header-args
:sclang nil
)
79 (setq org-babel-default-header-args
:sclang
80 '((:session .
"*SCLang:Workspace*")
81 ;; TODO: temporary can't find way to let sclang output to stdout for org-babel.
86 (add-to-list 'org-src-lang-modes
'("sclang" . sclang
))))
88 ;;; ----------------------------------------------------------------------------
92 ;;; ob-sclang.el ends here