[slime-devel] configuring macro indentation

Paulo Madeira acelent at gmail.com
Sun Sep 25 14:42:57 UTC 2011

2011/09/23 Alistair Gee:
> I am using the latest version of slime from cvs. I noticed that macros such
> as iter (from the iterate package) indents differently now than sometime in
> the past.
> Current indentation:
> (iter (for i below 3)
>   (collect i))
> Old indentation:
> (iter (for i below 3)
>       (collect i))    ; "collect" is lined up with "for"
> An example with a macro from the clsql package:
> Current indentation:
> (clsql:with-default-database (db)
>                              (progn))
> Old indentation:
> (clsql:with-default-database (db)
>   (progn)) ; &body is indented 2 spaces
> How do I configure slime to indent with the older styles?
> My .emacs has:
> (slime-setup '(slime-fancy
>                slime-asdf
>                slime-sprof
>                slime-compiler-notes-tree
>                slime-hyperdoc
>                slime-mdot-fu
>                slime-mrepl
>                slime-indentation
>                slime-repl))

The old behaviour depended solely on the Emacs side of things.

The `iter' form didn't actually indent the `collect' form with the
`for' form on purpose, it indented just like it would any other
function call.

The `with-default-database' form has a first element whose name starts
with "with-", a very common prefix for macros with a body, so it was
assumed and indented as such.

When connected to lisp, the new indentation mechanism can detects
`&body' arguments.

If you add a newline right before the `for' form, you'll see it's
indented at 2, because `iter' has a single `&body' arguments.

The `with-default-database' has a `&rest' argument, so it's not
indented like a body.

The best solution would be to update clsql to declare the macro
argument as `&body'. One workaround is to add something like this to
your Emacs init.el (note: I didn't actually test this):

(put 'with-default-database

Paulo Madeira

More information about the slime-devel mailing list