Indenting a macro in emacs
Is there something like it (declare (indent defun))
for guile, so indenting custom macros works like define
s?
For example, if I write the following macro,
(define-syntax my-when
(syntax-rules ()
((my-when condition exp ...)
(if condition
(begin exp ...)))))
Then I get padding that looks like
(my-when #t
(write "hi"))
But prefers the following
(my-when #t
(write "hi"))
In elisp, I could get the desired indentation via
(defmacro my-when (condition &rest body)
(declare (indent defun))
`(if ,condition
,@body))
(my-when t
(message "hi"))
Version / Mode Notes: emacs 26, scheme-mode
w / geiser
, geiser-impl--implementation
=guile
source to share
Add an indent mark for the character:
(put 'my-when 'scheme-indent-function 1)
It's more or less what (declare (indent 1))
makes it in defmacro
.
lisp-mode
uses lisp-indent-line
that looks for a property lisp-indent-function
in a symbol. The built-in scheme-mode
uses lisp-indent-function
, so you might think it will work the same as in lisp-mode
. However, the property name must match the mode name. See https://www.gnu.org/software/emacs/manual/html_node/elisp/Indenting-Macros.html#Indenting-Macros for property values.
source to share