Table of Contents

Factor Layer

Table of ContentsClose

logo.png

1. Description

A spacemacs layer for Factor language support.

1.1. Features:

  • Syntax Highlighting
  • Factor REPL integration
  • Auto-Completion in REPL
  • Scaffolding support
  • Refactoring support
  • Running graphical Listeners
  • Reloading emacs-lisp portion of FUEL

2. Install

This layer depends on the elisp files that are bundled with factor. To use this layer, make sure that factor is installed and the bundled elisp files are picked up by emacs (usually somewhere in site-lisp).

To use this layer, add it to your ./spacemacs file. Add factor to the dotspacemacs-configuration-layers list there.

3. Key bindings

3.1. factor-mode (editing source files)

Key binding Description
SPC m ' Jump to the factor listener, start if required
SPC m c c Compile and run the current file
   
SPC m e f Evaluate definition at point
SPC m e r Evaluate region
SPC m e R Evaluate region extended to nearest definition
   
SPC m g g Jump to definition of word (under point)
SPC m g a Cycle between source, test, and documentation
   
SPC m t a Run tests for current vocab
   
SPC m r s Extract innermost sexp as separate word
SPC m r r Extract region as separate word
SPC m r v Create new Vocab with words in region
SPC m r i Inline word
SPC m r w Rename all occurrences of word
SPC m r a Extract region as new ARTICLE form
SPC m r g Turn current definition into generic word
SPC m r u Update USING: line according to actually used words
   
SPC m s s Switch to factor listener
   
SPC m h h Help for thing at point
SPC m h e Infer stack effect for sexp/region
SPC m h p Apropos
SPC m h v List all words in current file/vocab
SPC m h < Show calling words of current word
SPC m h > Show words called by current word
   
SPC m S v Scaffold vocab
SPC m S h Scaffold help for current vocab

3.2. fuel-listener-mode

Key binding Description
SPC m r Refresh all loaded vocabs
SPC m T s Toggle stack mode
SPC m h Help for word at point
SPC m v Edit vocab
SPC m S v Scaffold vocab

4. Snippets

This layer provides a yasnippet for colon definitions, which can be expanded after typing a single :. Note that you might have to set yas-triggers-in-field to nil if you use x for stack effect declaration elements a lot, as this will trigger a builtin snippet from prog-mode instead of advancing to the next field when pressing <TAB>.

5. Starting a Graphical Listener

The command factor/start-ui-listener can be used to run a Factor process which sets up a FUEL server on the standard port and runs the graphical listener. If successful, the command connect-to-factor will connect to that factor instance.

This procedure can be influenced with the following variables, which can also be set as directory-local variables to make it easier to work with projects which require different Factor versions, for example. (See their respective documentation for details)

  • fuel-factor-root-dir
  • fuel-listener-factor-binary
  • fuel-listener-factor-image
  • factor-ui-listener-args

Note that the commands described in the Key bindings section which start a factor listener are supplied by FUEL and don't take the last of these variables, factor-ui-listener-args into account.

Author: root

Created: 2024-10-11 Fri 01:37

Validate