diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..bcbf145 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,41 @@ +name: CI + +on: + push: + paths-ignore: + - '**.org' + pull_request: + paths-ignore: + - '**.org' + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + emacs_version: + - 28.1 + - 27.2 + - 26.3 + - 25.3 + + steps: + - name: Set up Emacs + uses: purcell/setup-emacs@master + with: + version: ${{matrix.emacs_version}} + + - name: Install Eldev + run: curl -fsSL https://raw.github.com/doublep/eldev/master/webinstall/github-eldev | sh + + - name: Check out the elisp source code + uses: actions/checkout@v2 + + - name: Test the uncompiled source + run: | + eldev -p -dtT test + + - name: Compile and run tests again + run: | + eldev compile + eldev -p -dtT test diff --git a/.gitignore b/.gitignore index e4e5f6c..6302bc3 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -*~ \ No newline at end of file +*~ +*.elc diff --git a/README.org b/README.org index ab118c7..2232522 100644 --- a/README.org +++ b/README.org @@ -3,10 +3,21 @@ #+STARTUP: showstars ** Why do I even? -[[https://orgmode.org/][Org-mode]] makes [[http://literateprogramming.com/][literate programming]] easy via [[https://orgmode.org/worg/library-of-babel.html][Library of Babel]]. Il simply allows to mix text with executable /code blocks/ (which can also be extracted (/tangled/) into separate, executable files. The beauty of the Library of Babel implementation in org-mode lies in the fact that it supports many languages. I craved support for [[https://github.com/supercollider/supercollider][SuperCollider]] and craving became an itch when I needed to document a working pipeline alternating between executing sclang and shell scripts. I scratched an itch with this little module. +[[https://orgmode.org/][Org-mode]] makes [[http://literateprogramming.com/][literate programming]] easy via [[https://orgmode.org/worg/library-of-babel.html][Library of Babel]]. Il simply allows to mix text with executable /code blocks/ which can also be extracted (/tangled/) into separate, executable files. The beauty of the Library of Babel implementation in org-mode lies in the fact that it supports many languages. I craved support for [[https://github.com/supercollider/supercollider][SuperCollider]] and craving became an itch when I needed to document a working pipeline alternating between executing sclang and shell scripts. I scratched an itch with this little module. ** How to install? -First of all, you will need emacs (>=25) and SuperCollider (with emacs support) installed. Modern emacsen and Spacemacs come with bundled org-mode. At this point I am the sole user of this plugin and have just written it so I am not itching yet for MELPA or inclusion in the official org-mode repositories, so installation is manual. You can either drop [[file:ob-sclang.el]] somewhere in your Emacs' path or add its containing directory to ~load-path~ in =.init= file: +First of all, you will need emacs (>=26) and SuperCollider (with emacs support) installed. Modern emacsen and Spacemacs come with bundled org-mode. + +It can be installed as a package via [[https://melpa.org/#/i-ching][Melpa]] or manually. + +#+BEGIN_SRC emacs-lisp +(use-package ob-sclang + :config (org-babel-do-load-languages + 'org-babel-load-languages + '((sclang . t)))) +#+END_SRC + +To install manually you can either drop [[file:ob-sclang.el]] somewhere in your Emacs' path or add its containing directory to ~load-path~ in =.init= file: #+BEGIN_SRC elisp (add-to-list 'load-path "/path/to/ob-sclang/") diff --git a/ob-sclang.el b/ob-sclang.el index 510e08a..ce2593f 100644 --- a/ob-sclang.el +++ b/ob-sclang.el @@ -1,11 +1,12 @@ -;;; ob-sclang.el --- org-babel functions for sclang evaluation +;;; ob-sclang.el --- Org-babel interface for SuperCollider -*- coding: utf-8; ;; Copyright (C) 2018 Michal Seta ;; Author: Michal Seta -;; Keywords: supercollider, literate programming, reproducible research -;; Homepage: https://github.com/djiamnot/ob-sclang.git -;; Version: 0.02 +;; Keywords: supercollider, literate programming, multimedia, languages, tools +;; URL: https://github.com/djiamnot/ob-sclang +;; Package-Requires: ((emacs "26.1") (sclang "1.0")) +;; Version: 0.3 ;;; License: @@ -24,21 +25,21 @@ ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, ;; Boston, MA 02110-1301, USA. -;;; Requirements: -;;; sclang requires SuperCollider, of course. You need to have both the SuperCollider -;;; system installed and the sclang-mode -;;; SuperCollider can be found at https://github.com/supercollider/supercollider +;;; Commentary: +;; ob-sclang enables SuperCollider source blocks to be used in org files + ;;; Code: (require 'ob) (require 'sclang) -;; optionally define a file extension for this language +;; add file extensions for sclang (add-to-list 'org-babel-tangle-lang-exts '("sclang" . "scd")) -;; optionally declare default header arguments for this language +;; declare default header arguments for sclang code blocks (defvar org-babel-default-header-args:sclang - '((:results . "none"))) + '((:session . "*SCLang:Workspace*") + (:result . "none"))) (defun org-babel-expand-body:sclang (body params) "Expand BODY according to PARAMS, return the expanded body." @@ -56,37 +57,34 @@ body)) (defun org-babel-sclang-var-to-sclang (var) - "Convert an elisp value to a string of sclang code represting the value of the - variable with correct type." + "Convert an elisp value VAR to a string of sclang code. +The value of the variable should be represented with correct type." (if (listp var) (concat "[" (mapconcat #'org-babel-sclang-var-to-sclang var ", ") "]") (cond ((stringp var) (format "%S" var)) ((floatp var) (format "%f" var)) ((integerp var) (format "%d" var)) - ((symbolp var) (concat (format "%S" (symbol-name var)) ".asSymbol"))) - )) + ((symbolp var) (concat (format "%S" (symbol-name var)) ".asSymbol"))))) (defun org-babel-execute:sclang (body params) - "Execute a block of Sclang code with org-babel. -This function is called by `org-babel-execute-src-block'" - - (sclang-eval-string (org-babel-expand-body:sclang body params)) - ) + "Execute a block of sclang code with org-babel. +This function is called by `org-babel-execute-src-block' with BODY and PARAMS" + (sclang-eval-string (org-babel-expand-body:sclang body params))) (defun org-babel-prep-session:sclang (session params) "Prepare SESSION according to the header arguments specified in PARAMS." - (error "No need for session preparation") - ) + (message "No need for session preparation")) (defun org-babel-sclang-initiate-session (&optional session) - "If there is not a current inferior-process-buffer in SESSION then create. + "If there is not a current inferior-process-buffer in SESSION then create one. Return the initialized session." (unless (string= session "none") - (let (session (if sclang-library-initialized-p + (let ((session (if sclang-library-initialized-p sclang-post-buffer (save-window-excursion (sclang-start) - (current-buffer) )))))) + (current-buffer))))) + session))) (provide 'ob-sclang) ;;; ob-sclang.el ends here