#+TITLE: Forth layer

#+TAGS: general|imperative|layer|programming

* Table of Contents                     :TOC_5_gh:noexport:
- [[#description][Description]]
  - [[#features][Features:]]
- [[#install][Install]]
- [[#key-bindings][Key bindings]]

* Description
This layer adds basic support for the Forth family of languages to spacemacs.

** Features:
- Syntax highlighting
- Showing meaning of objects in context of the current =Forth= session.
- Eval of entire files or regions in current =Forth= session.
- Passing interactive commands to current =Forth= session.

* Install
To use this configuration layer, add it to your =~/.spacemacs=. You will need to
add =forth= to the existing =dotspacemacs-configuration-layers= list in this
file.

A local installation of =Forth= needs to be present as well. =GNU Forth= is
commonly available on Unix systems via the package manager. To bypass the query
when calling ~run-forth~, the default Forth can be configured by setting the
appropriate variable.

#+BEGIN_SRC emacs-lisp
  (setq-default dotspacemacs-configuration-layers
                '((forth :variables forth-executable "gforth")))
#+END_SRC

* Key bindings

| Key binding | Description                                                       |
|-------------+-------------------------------------------------------------------|
| ~SPC m d s~ | See definition (show decompiled body)                             |
| ~SPC m e E~ | Evaluate expression in minibuffer                                 |
| ~SPC m e e~ | Evaluate last expression                                          |
| ~SPC m e r~ | Evaluate region                                                   |
| ~SPC m s b~ | Load file in interactive Forth                                    |
| ~SPC m s i~ | Start interactive Forth (prompts for Forth executable if not set) |
| ~SPC m s k~ | Kill interactive Forth                                            |
