Reputation: 32466
Is there something like (declare (indent defun))
for guile so indentation of user-defined 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 indentation that looks like,
(my-when #t
(write "hi"))
But would prefer 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
Upvotes: 3
Views: 442
Reputation: 9437
Add an indent hint for the symbol:
(put 'my-when 'scheme-indent-function 1)
This is more or less what (declare (indent 1))
does in defmacro
.
lisp-mode
uses lisp-indent-line
, which looks for the lisp-indent-function
property on the symbol. The built-in scheme-mode
uses lisp-indent-function
, so you would think that it would work just like in lisp-mode
. However the property name needs to match the mode name. See https://www.gnu.org/software/emacs/manual/html_node/elisp/Indenting-Macros.html#Indenting-Macros for the values of the property.
Upvotes: 3