A Spacemacs layer for Pixie

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).

Result

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 
;; 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
    inf-clojure
    pixie-mode
    ))

;; 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
    :config
    (progn
      (defun spacemacs/pixie-eval-and-switch-to-repl ()
        "Call `inf-clojure-eval-last-sexp' and switch to REPL buffer in `insert state'"
        (interactive)
        (inf-clojure-eval-last-sexp)
        (inf-clojure-switch-to-repl t)
        (evil-insert-state))

      (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-
;;
;; (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.