A major mode for Pixie already exists, but I would like to use it in evil mode from Spacemacs. Hence, a custom layer.

I repeat the steps I took here in a mini tutorial format.

Create a custom layer for Spacemacs

Start with creating the layer from within Spacemacs:

<SPC> : configuration-layer/create-layer <RET>

Press <RET> again to create the layer in the default directory $HOME/.emacs.d/private.

Choose a layer name, e.g. pixie.

Spacemacs then throws you into the packages.el for your new layer.

Now is a good time to study layers, but the gist is this:

  • hook in the modes you’re layering in (setq <your-layer>-packages ...)
  • set the key combinations for your Evil Leader in the (defun <your-layer>/init-<your-layer> () ...) form
  • optionally define custom commands here and bind to them

PS The Evil Leader in Spacemacs is SPC (YES! that’s where Spacemacs gets its name from).


Here’s what I came up with for Pixie. At the moment, it offers bindings to start the REPL, and eval s-expressions (and an option to jump to the REPL after evaluation).

;;; packages.el --- pixie Layer packages File for Spacemacs
;; Copyright (c) 2012-2014 Sylvain Benner
;; Copyright (c) 2014-2015 Sylvain Benner & Contributors
;; Author: Sylvain Benner <[email protected]>
;; URL: https://github.com/syl20bnr/spacemacs
;; This file is not part of GNU Emacs.
;;; License: GPLv3

;; List of all packages to install and/or initialize. Built-in packages
;; which require an initialization must be listed explicitly in the list.
(setq pixie-packages
    ;; package names go here

;; List of packages to exclude.
(setq pixie-excluded-packages '())

(defun pixie/post-init-inf-clojure ()
(add-hook 'pixie-mode-hook 'inf-clojure-minor-mode))

(defun pixie/init-pixie-mode ()
  (use-package pixie-mode
    :defer t
      (defun spacemacs/pixie-eval-and-switch-to-repl ()
        "Call `inf-clojure-eval-last-sexp' and switch to REPL buffer in `insert state'"
        (inf-clojure-switch-to-repl t)

      (evil-leader/set-key-for-mode 'pixie-mode
        ;; REPL
        "msi" 'inf-clojure-switch-to-repl
        "msb" 'inf-clojure-eval-last-sexp
        "msB" 'spacemacs/pixie-eval-and-switch-to-repl))))

;; For each package, define a function pixie/init-<package-name>
;; (defun pixie/init-my-package ()
;;   "Initialize my package"
;;   )
;; Often the body of an initialize function uses `use-package'
;; For more info on `use-package', see readme:
;; https://github.com/jwiegley/use-package

It’s by no means complete, and I plan to implement basic functionality involving navigation, documentation, tests (Pixie test frameworks permitting), and evaluation of more forms.