/common-lisp-sly

Maintaining mfiano's spacemacs config for Sly for anyone to use.

Primary LanguageEmacs Lisp

Common Lisp Sly layer

Unlike other forks, this one is intended to actually be maintained for public use. Feel free to make improvements and pull requests.

   _____    __   __  __
  / ___/   / /   \ \/ /               |\      _,,,---,,_
  \__ \   / /     \  /                /,`.-'`'    -.  ;-;;,_
 ___/ /  / /___   / /                |,4-  ) )-,_..;\ (  `'-'
/____/  /_____/  /_/                '---''(_/--'  `-'\_)

Table of Contents

Todo

It’s been five years since mfiano was working on this project, and it was a bit crusty.

  • [X] Make it work
  • [ ] Fix evil bindings in: (Where else? Definitely some other places.)
    • [ ] The debugger (weird effects with normal mode vs insert mode)
    • [ ] the repl (while chaning to insert on an empty repl is nice,

    it can also be annoying, so it should only switch when the user manually opens the repl, and not when the user gets automatically jumped there by automatic windowing.

    • [ ] make company mode’s selection menu more evil-like when vim mode is on.

Description

This layer provides support for Common Lisp to Spacemacs using Sly. This layer should be used instead of the common-lisp layer if you want to use Sly – a more featureful Common Lisp environment.

Features

  • Syntax highlighting
  • [optional] Fuzzy auto-completion using company (see below)
  • REPL and introspection support via Sly
  • Support for specific Lisp navigation styles via common-lisp-mode
  • Support for the SBCL backend or any other Common Lisp implementation
  • Ability to save a layout with a REPL and have it restored the next time that layout is loaded
  • Multiple REPL connections for the same or different Common Lisp images
  • REPLs have full ANSI color code support via sly-repl-ansi-color
  • Stickers, a more advanced, non-intrusive alternative to print debugging, and a means for live code annotation.

Layer Installation

If you have previously installed SLIME in any other way, it is recommended that you uninstall it before proceeding. You should clean up any configuration files tied to SLIME that are left behind as well.

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

This layer defaults to using SBCL. If you want to use a different implementation of Common Lisp, you can specify it in your ~/.spacemacs:

(defun dotspacemacs/user-config ()
  (setq inferior-lisp-program "/path/to/your/lisp"))

Structurally Safe Editing

This layer adds support for evil-cleverparens which allows safe editing of 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 common-lisp buffers call the following function in your dotspacemacs/user-config function:

(spacemacs/toggle-evil-safe-lisp-structural-editing-on-register-hook-common-lisp-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.

Company completion

Company provides a little pop-up window under the cursor with completions, which really beats the default sly choice of opening a whole buffer and messing up the layout.

If you only want company for sly, add the mode hooks to `dotspacemacs/user-config`..

`~/.spacemacs`

;; only in sly
(add-hook 'sly-mode-hook 'company-mode)
(add-hook 'sly-mrepl-mode-hook 'company-mode)
;; global mode if you want it everywhere
;(global-company-mode)

And add the company package too

dotspacemacs-additional-packages '(company)
dotspacemacs-frozen-packages '(company) ; prevent startup slowdown

Key Bindings

Working with Lisp files (slurpage, barfage, and more)

Spacemacs comes with a special lisp-state for working with Lisp code that supports slurpage, barfage and more tools you’ll likely want when working with Lisp.

As this state works the same for all files, the documentation is in global DOCUMENTATION.org. In general, use SPC k to interact with lisp-state.

Help

Key BindingDescription
SPC m h aApropos - search for any symbol matching input (prompted)
SPC m h bShow who binds the global variable at point
SPC m h dShow disassembly of symbol at point
SPC m h hDescribe symbol at point
SPC m h HLookup symbol at point in the Common Lisp HyperSpec
SPC m h mShow the usages of macro at point
SPC m h pBrowse package’s exported symbols
SPC m h rShow who refers to the global variable at point
SPC m h sShow all methods specialized on class symbol at point
SPC m h SShow who sets the global variable at point
SPC m h <Show who calls the function symbol at point
SPC m h >Show all functions called by function symbol at point

Compilation

Key BindingDescription
SPC m c cCompile file
SPC m c CCompile and load file
SPC m c fCompile function
SPC m c lLoad file
SPC m c nRemove compilation notes
SPC m c rCompile region

Evaluation

Key BindingDescription
SPC m e bEvaluate buffer
SPC m e eEvaluate last s-expression
SPC m e EEvaluate last s-expression and print result as a comment
SPC m e fEvaluate top-level function s-expression
SPC m e FUndefine the function at point
SPC m e rEvaluate region

Navigation

Key BindingDescription
SPC m gEnter the navigation transient state

Macro-expansion

Key BindingDescription
SPC m m eMacro-expand the form at point once
SPC m m EMacro-expand the form at point completely
SPC m m sEnter the macrostep transient state

REPL

Key BindingDescription
SPC m s cClear the REPL
SPC m s iStart a new Common Lisp image
SPC m s IChoose a new Common Lisp implementation and start a new image
SPC m s qQuit the REPL, terminating the Common Lisp image
SPC m s rRestart the Common Lisp image associated with the current REPL
SPC m s sSync the REPL with the current file buffer’s package and directory

Stickers

Key BindingDescription
SPC m S bToggle breaking stickers, to have debugger come up when sticker is reached during execution
SPC m S cClear all stickers for function at point
SPC m S CClear all stickers for buffer
SPC m S fFetch recordings for sticker at point
SPC m S rCycle through the recordings of all stickers
SPC m S sAdd or remove (if one already exists) sticker at point

Tracing

Key BindingDescription
SPC m t tToggle trace
SPC m t TToggle fancy trace
SPC m t uUntrace all