Skip to content

xchrishawk/ob-racket

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Org-Mode Babel Support for Racket

This Emacs module enables support for the Racket programming language in Emacs’ Org-mode Babel. This allows executing Racket code blocks directly from Org mode, embedding the results of those code blocks in your Org files, and even chaining the result from one code block into another code block. See the Babel intro for more details on what’s possible.

Example Usage

This example shows how to add a code block implementing the classic recursive factorial. With point inside the code block, press C-c C-c to execute the block. The result will be inserted immediately beneath it.

#+BEGIN_SRC racket :var input=10
  (define (factorial n)
    (if (= n 1)
        1
        (* n (factorial (sub1 n)))))
  (factorial input)
#+END_SRC

#+RESULTS:
: 3628800

Supported Header Arguments

:results
Can be set to either value or output. If set to value, the code block will be wrapped in a (let …) form, and only the result of the form will recorded. If set to output, the code block will be run as a script, and all standard output will be recorded. Defaults to value.
:lang
Specifies the language used in the #lang directive at the beginning of the script. Defaults to “racket”.
:var
Allows defining a variable for use in the block. If using the value output type, the variable will be passed to the wrapping function as an argument. Otherwise, it will be defined at the top level of the script using a (define ...) form.

Installation

  • Install ob-racket.el in your Emacs load path
  • Add the following to your .emacs.d file:
;; Enable Racket in Org-mode Babel
(org-babel-do-load-languages
 'org-babel-load-languages
 '((racket . t)))
  • If your Racket interpreter is installed in a non-standard location (anywhere other than /usr/bin/racket), also add the following to your .emacs.d file:
;; Set path to racket interpreter
(setq org-babel-command:racket "/path/goes/here")

Author

Chris Vig (chris@invictus.so)

About

Org-Mode Babel Support for Racket

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published