Skip to content

Latest commit

 

History

History
 
 

scheme

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Scheme layer

Table of Contents

Description

This layer adds support for Scheme via Geiser. Note that combined usage of racket-mode and geiser has not been tested.

Features:

  • Support the Scheme compiler Chicken
  • Support for the extension language platform Guile
  • Structurally safe editing using optional evil-cleverparens

Install

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

Additionally, before geiser can be used with a scheme implementation, support for the implementation must be enabled by adding its name to the list of scheme-implementations. It is recommended to set the value of the list directly in the dotspacemacs-configuration-layers list as shown in the following example for guile and racket:

dotspacemacs-configuration-layers
'((scheme :variables
           scheme-implementations '(guile racket)))

Currently support is available for the following scheme implementations: chez, chibi, chicken, gambit, gauche, guile, kawa, mit and racket.

Finally, to use a scheme implementation its binary must be available in your PATH (or you can manually set the location of the binary as explained in this section of the geiser documentation).

The following subsection shows how to install Chicken scheme and activate geiser support.

Install Chicken scheme example

First add chicken to the list of scheme-implementations as explained above.

For full Chicken support, the following commands should be run:

$ chicken-install -s apropos chicken-doc
$ cd `csi -p '(chicken-home)'`
$ curl https://3e8.org/pub/chicken-doc/chicken-doc-repo.tgz | sudo tar zx

Note: Chicken 5 does not have chicken-home imported by default, so the command for changing to that directory can be accomplished with this:

$ cd `csi -b -e "(import (chicken platform))" -p "(chicken-home)"`

Note: Chicken 5 also requires SRFI-18

$ chicken-install -s srfi-18

Additionally, as of 2018-12-12 there is a naming conflict in some of the Linux package repos:

# Chicken had csc and csi first, but then mono introduced a conflict and
# does not seem to want to change this. OpenBSD renamed csc and csi to
# chicken-csc and chicken-csi 2018-12-12.

You may need to modify the csi command accordingly. If the name of the REPL binary on your system is chicken-csi, you will also need to add

(setq geiser-chicken-binary "chicken-csi")

to your dotspacemacs/user-config in order for the REPL to start in spacemacs.

Structurally safe editing

This layer adds support for evil-cleverparens which allows to safely edit lisp code by keeping the s-expressions balanced.

By default this mode is not activated. You can turn it on locally on the active buffer with SPC m T s (s for safe).

To turn it on automatically for all scheme buffers call the following function in your dotspacemacs/user-config function:

(spacemacs/toggle-evil-safe-lisp-structural-editing-on-register-hook-scheme-mode)

or to enable it for all supported modes:

(spacemacs/toggle-evil-safe-lisp-structural-editing-on-register-hooks)

When enabled the symbol 🆂 should be displayed in the mode-line.

Key bindings

Compiling

Key bindingDescription
SPC m c cCompile current buffer
SPC m c pAdd directory to load path

Navigation

Key bindingDescription
SPC m g dGoto Definition
SPC m g bGo Back
SPC m g mGoto Module
SPC m g nGoto next error
SPC m g NGoto previous error

Documentation

Key bindingDescription
SPC m h hDocs for symbol at point
SPC m h dLook up manual entry for symbol at point
SPC m h mDisplay exports for module
SPC m h <Display callers
SPC m h >Display callees

Insertion

Key bindingDescription
SPC m i lInsert Lambda

Macroexpansion

Key bindingDescription
SPC m m eMacroexpand last sexp
SPC m m fMacroexpand surrounding sexp
SPC m m rMacroexpand region

REPL interaction

Key bindingDescription
SPC m s iStart or switch to the REPL
SPC m s sSelect Scheme implementation
SPC m s bSend buffer to the REPL
SPC m s BSend buffer to the REPL and focus it
SPC m s fSend definition to the REPL
SPC m s FSend definition to the REPL and focus it
SPC m s eSend last sexp to the REPL
SPC m s rSend region to the REPL
SPC m s RSend region to the REPL and focus it

Evaluation

Key bindingDescription
SPC m e bEvaluate the whole buffer
SPC m e eEvaluate last sexp
SPC m e fEvaluate current function
SPC m e lEvaluate line
SPC m e rEvaluate region

REPL-mode

Insert state

Key bindingDescription
S-RETInsert newline
C-lClear buffer
C-dExit

Normal state

Key bindingDescription
g j / ]]Goto next prompt
g k / [[Goto previous prompt
SPC m h hShow documentation for symbol at point
SPC m CClear buffer
SPC m i lInsert lambda
SPC m i mImport module
SPC m uUnload function
SPC m sToggle surrounding parenthesis <-> brackets
SPC m kREPL interrupt
SPC m qREPL exit

Geiser-doc-mode

Key bindingDescription
oFollow link
]]/[[Next/previous-section
g p / <Previous page
g n / >Next page
g dGoto definition
g zSwitch to repl
TAB / C-jNext button
S-TAB~ / C-kPrevious button