Here’s another tutorial for a useful feature using the world’s best text editor: directory-local variables. Specifically, this will be about proper CL macro indentation, even when you don’t have a Sly/Slynk client running and connected to Nyxt.
Turns out, you can customize lisp-indent-function
(or rather, common-lisp-indent-function
) so that macros are indented properly instead of being treated like just another function. My .dir-locals.el
file looks something like the following:
((lisp-mode
.
((eval . (let ((macros (list 'define-configuration
'alex:if-let
'alex:when-let)))
(mapc
(lambda (sym)
(put sym 'common-lisp-indent-function 1))
macros))))))
The first line indicates that the following would be eval
’d (with user consent) whenever Emacs’ lisp-mode
gets enabled. The define-configuration
macro in the list is obviously Nyxt-specific, with the alex
namespace / nickname being a re-exported alexandria package, which has plenty of useful general macros.
This .dir-locals.el
file you would place at either the root directory of your dotfiles’ project, or the directory where your config.lisp
etc are located.
Enjoy!