2015-12-02 14:23:39 +00:00
#+TITLE : Scheme layer
2016-03-31 02:59:55 +00:00
2019-05-07 08:21:07 +00:00
#+TAGS : dsl|layer|lisp|programming
2019-05-05 17:26:40 +00:00
2019-05-07 20:05:06 +00:00
* Table of Contents :TOC_5_gh:noexport:
2017-05-22 14:16:12 +00:00
- [[#description ][Description ]]
2017-08-28 21:58:10 +00:00
- [[#features ][Features: ]]
2017-05-22 14:16:12 +00:00
- [[#install ][Install ]]
2021-04-14 15:40:19 +00:00
- [[#install-chicken-scheme-example ][Install Chicken scheme example ]]
2019-06-01 17:13:30 +00:00
- [[#structurally-safe-editing ][Structurally safe editing ]]
2018-12-05 03:03:03 +00:00
- [[#key-bindings ][Key bindings ]]
2017-05-22 14:16:12 +00:00
- [[#compiling ][Compiling ]]
- [[#navigation ][Navigation ]]
- [[#documentation ][Documentation ]]
- [[#insertion ][Insertion ]]
- [[#macroexpansion ][Macroexpansion ]]
2021-04-26 13:42:48 +00:00
- [[#repl-interaction ][REPL interaction ]]
2017-05-22 14:16:12 +00:00
- [[#evaluation ][Evaluation ]]
2021-04-26 13:42:48 +00:00
- [[#repl ][REPL ]]
2015-08-15 04:57:09 +00:00
2015-07-11 01:32:10 +00:00
* Description
2018-01-27 16:01:04 +00:00
This layer adds support for Scheme via [[http://geiser.nongnu.org ][Geiser ]]. Note that combined usage of racket-mode and geiser has not been tested.
2015-07-11 01:32:10 +00:00
2017-08-28 21:58:10 +00:00
** Features:
- Support the Scheme compiler [[https://www.call-cc.org/ ][Chicken ]]
- Support for the extension language platform [[https://www.gnu.org/software/guile/ ][Guile ]]
2019-06-01 17:13:30 +00:00
- Structurally safe editing using optional [[https://github.com/luxbock/evil-cleverparens ][evil-cleverparens ]]
2015-07-11 01:32:10 +00:00
2017-08-28 21:58:10 +00:00
* Install
2016-01-06 05:21:55 +00:00
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.
2015-07-11 01:32:10 +00:00
2021-04-14 15:40:19 +00:00
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:
2021-04-15 20:16:34 +00:00
#+BEGIN_SRC elisp
2021-04-14 15:40:19 +00:00
dotspacemacs-configuration-layers
'((scheme :variables
scheme-implementations '(guile racket)))
2021-04-15 20:16:34 +00:00
#+END_SRC
2021-04-14 15:40:19 +00:00
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 [[https://nongnu.org/geiser/geiser_3.html][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.
2021-04-15 20:16:34 +00:00
2015-07-11 01:32:10 +00:00
For full Chicken support, the following commands should be run:
#+BEGIN_SRC shell
$ chicken-install -s apropos chicken-doc
$ cd `csi -p '(chicken-home)'`
2016-02-28 23:26:48 +00:00
$ curl https://3e8.org/pub/chicken-doc/chicken-doc-repo.tgz | sudo tar zx
2015-07-11 01:32:10 +00:00
#+END_SRC
2019-03-09 03:25:19 +00:00
*Note:* Chicken 5 does not have =chicken-home= imported by default,
so the command for changing to that directory can be accomplished with this:
#+BEGIN_SRC shell
$ cd `csi -b -e "(import (chicken platform))" -p "(chicken-home)"`
#+END_SRC
2020-02-28 23:34:58 +00:00
*Note:* Chicken 5 also requires SRFI-18
#+BEGIN_SRC shell
$ chicken-install -s srfi-18
#+END_SRC
2019-03-09 03:25:19 +00:00
Additionally, as of 2018-12-12 there is a [[https://git.archlinux.org/svntogit/community.git/commit/trunk?h=packages/chicken&id=8b9a65eb88d899f7c9c78b56bba5bea5cdba534a ][naming conflict ]]
in some of the Linux package repos:
#+BEGIN_EXAMPLE
2019-04-04 16:29:54 +00:00
# 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.
2019-03-09 03:25:19 +00:00
#+END_EXAMPLE
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
#+BEGIN_SRC emacs-lisp
2019-04-04 16:29:54 +00:00
(setq geiser-chicken-binary "chicken-csi")
2019-03-09 03:25:19 +00:00
#+END_SRC
to your =dotspacemacs/user-config= in order for the REPL to start in spacemacs.
2019-06-01 17:13:30 +00:00
* Structurally safe editing
2018-01-04 06:55:54 +00:00
This layer adds support for =evil-cleverparens= which allows to safely edit
2018-01-04 06:34:23 +00:00
lisp code by keeping the s-expressions balanced.
2018-01-04 06:55:54 +00:00
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).
2018-01-04 06:34:23 +00:00
To turn it on automatically for all =scheme= buffers call the following
function in your =dotspacemacs/user-config= function:
#+BEGIN_SRC emacs-lisp
2018-09-19 03:54:47 +00:00
(spacemacs/toggle-evil-safe-lisp-structural-editing-on-register-hook-scheme-mode)
2018-01-04 06:34:23 +00:00
#+END_SRC
or to enable it for all supported modes:
#+BEGIN_SRC emacs-lisp
2018-09-19 03:54:47 +00:00
(spacemacs/toggle-evil-safe-lisp-structural-editing-on-register-hooks)
2018-01-04 06:34:23 +00:00
#+END_SRC
When enabled the symbol =🆂= should be displayed in the mode-line.
2018-12-05 03:03:03 +00:00
* Key bindings
2016-04-13 03:31:38 +00:00
** Compiling
2015-07-11 01:32:10 +00:00
2018-12-05 03:03:03 +00:00
| Key binding | Description |
2015-07-11 01:32:10 +00:00
|-------------+----------------------------|
| ~SPC m c c~ | Compile current buffer |
| ~SPC m c p~ | Add directory to load path |
** Navigation
2018-12-05 03:03:03 +00:00
| Key binding | Description |
2015-07-11 01:32:10 +00:00
|-------------+---------------------|
| ~SPC m g g~ | Goto Definition |
| ~SPC m g b~ | Go Back |
| ~SPC m g m~ | Goto Module |
| ~SPC m g n~ | Goto next error |
| ~SPC m g N~ | Goto previous error |
** Documentation
2018-12-05 03:03:03 +00:00
| Key binding | Description |
2015-07-11 01:32:10 +00:00
|-------------+------------------------------------------|
| ~SPC m h h~ | Docs for symbol at point |
| ~SPC m h d~ | Look up manual entry for symbol at point |
| ~SPC m h m~ | Display exports for module |
| ~SPC m h <~ | Display callers |
| ~SPC m h >~ | Display callees |
** Insertion
2018-12-05 03:03:03 +00:00
| Key binding | Description |
2015-07-11 01:32:10 +00:00
|-------------+---------------|
| ~SPC m i l~ | Insert Lambda |
** Macroexpansion
2018-12-05 03:03:03 +00:00
| Key binding | Description |
2015-07-11 01:32:10 +00:00
|-------------+------------------------------|
| ~SPC m m e~ | Macroexpand last sexp |
| ~SPC m m f~ | Macroexpand surrounding sexp |
| ~SPC m m r~ | Macroexpand region |
2021-04-26 13:42:48 +00:00
** REPL interaction
2015-07-11 01:32:10 +00:00
2018-12-05 03:03:03 +00:00
| Key binding | Description |
2015-07-11 01:32:10 +00:00
|-------------+------------------------------------------|
| ~SPC m s i~ | Start or switch to the REPL |
2015-11-10 02:08:49 +00:00
| ~SPC m s s~ | Select Scheme implementation |
2015-07-11 01:32:10 +00:00
| ~SPC m s b~ | Send buffer to the REPL |
| ~SPC m s B~ | Send buffer to the REPL and focus it |
| ~SPC m s f~ | Send definition to the REPL |
| ~SPC m s F~ | Send definition to the REPL and focus it |
| ~SPC m s e~ | Send last sexp to the REPL |
| ~SPC m s r~ | Send region to the REPL |
| ~SPC m s R~ | Send region to the REPL and focus it |
2015-11-27 04:34:11 +00:00
** Evaluation
2018-12-05 03:03:03 +00:00
| Key binding | Description |
2015-11-27 04:34:11 +00:00
|-------------+---------------------------|
| ~SPC m e b~ | Evaluate the whole buffer |
| ~SPC m e e~ | Evaluate last sexp |
| ~SPC m e f~ | Evaluate current function |
| ~SPC m e l~ | Evaluate line |
| ~SPC m e r~ | Evaluate region |
2021-04-26 13:42:48 +00:00
** REPL
2021-04-26 13:53:56 +00:00
2021-04-26 13:42:48 +00:00
| Key binding | Description |
|-------------+-----------------------------|
| ~g j~ | geiser-repl-next-prompt |
| ~g k~ | geiser-repl-previous-prompt |
| ~SPC m h~ | geiser-doc-symbol-at-point |
| ~SPC m i~ | geiser-repl-interrupt |
| ~SPC m c~ | geiser-repl-clear-buffer |
| ~SPC m m~ | geiser-repl-import-module |
| ~SPC m u~ | geiser-repl-unload-function |
| ~SPC m q~ | geiser-repl-exit |