OM# Documentation

Lisp Programming in OM#

Sometime a few lines of code are more efficient and easier to write than a visual program ! OM# includes a whole Lisp programming interface, and there exist several ways to edit and input/execute Lisp programs and commands in the environment.

OM# is a Lisp environment, that is, it embeds the whole Common Lisp language and interpreter. Visual programs created in OM# are just compiled into Lisp functions before to execute, and can therefore seamlessly call and interact with pure Lisp program components.

Any function that is defined in Lisp can be instantiated as a “box” in OM# visual program. Just type its name (prefixed by its Lisp package name if not in the :om package).

See how to write functions and classes for OM#.


Listener

The Listener is the main entry point and connection between OM# and its underlying Lisp environment.

In the Listener you can input simple commands (standard Lisp function calls) or load files (menu “Lisp/Load File…”) that are edited in external Lisp/text editors.


Lisp-buffers

In addition to OM#-specific document types (see Document management) it is also possible to open Lisp files (from the menu “File/Open”, extension: “.lisp”) or new Lisp buffers to be saved as Lisp files (from the menu “File/New…”).

Note that Lisp files are not listed in the general OM# document manager, but Lisp-buffer windows are listed in the “Windows” menu.

In addition to standard text-editing commands, the OM# Lisp-buffer editor offers a few Lisp-specific commands and short-cuts accessible from the “Lisp” menu:


Load your Lisp files

OM# can load Lisp files on startup, allowing you to quickly fix or extend the environment, or experiment with your own tools and functions.

Two main locations are possible:


Lisp in OM# patches

“Find Definition” in Visual Programs

The equivalent of the previous “Find Definition” command is also available in visual programs, from the menu “Help/Find source” or using the short-cut Ctrl/⌘+shift+E when a box is selected.

This command will take you the Lisp source of the visual program component (if it can be found). You can eventually edit it, re-evaluate it from there, and modify its behaviour (be careful!).

Using “Lisp-functions”

Lisp-functions are specific kinds of OM# documents or internal abstractions, representing a single functions written as a Lisp “lambda expression”.

=> See Lisp Functions.

Getting the equivalent Lisp code of a patch

An interesting feature of the OM# patch editor is the possibility to display on a side panel, the equivalent Lisp code corresponding to part or all of a visual program.

Open the “Lisp” pane in a patch editor with the button , from the menu “Edit/Show Lisp Code”, or using the Ctrl/⌘+L shortcut.

The Lisp code corresponding to the evaluation of the selected box is displayed (if any) or otherwise, to the whole patch, as if it were compiled and used as an abstraction in another patch: this patch must have at least one OUT box in order to do/return anything !

Hint: The generated Lisp translation can be copied (button “Copy Lisp Code”) and reused in Lisp-buffers or Lisp-functions.