2017-05-14 86 views
3

对于guile,是否有像(declare (indent defun))之类的东西,用户定义的宏的缩进工作就像define s?emacs中的guile宏缩进

例如,如果我写了下面的宏,

(define-syntax my-when 
    (syntax-rules() 
    ((my-when condition exp ...) 
    (if condition 
     (begin exp ...))))) 

然后,我得到压痕,看起来像,

(my-when #t 
     (write "hi")) 

但宁愿以下

(my-when #t 
    (write "hi")) 

在elisp,我可以通过

012得到想要的缩进
(defmacro my-when (condition &rest body) 
    (declare (indent defun)) 
    `(if ,condition 
     ,@body)) 

(my-when t 
    (message "hi")) 

版本/模式的注意事项:emacs的26scheme-mode瓦特/ geisergeiser-impl--implementation = guile

回答

3

添加缩进暗示的符号:

(put 'my-when 'scheme-indent-function 1) 

这是多了还是少了什么(declare (indent 1))确实在defmacro


lisp-mode使用lisp-indent-line,看起来对符号的lisp-indent-function财产。内置的scheme-mode使用lisp-indent-function,所以你会认为它会像lisp-mode一样工作。但是,属性名称需要与模式名称匹配。请参阅https://www.gnu.org/software/emacs/manual/html_node/elisp/Indenting-Macros.html#Indenting-Macros了解该属性的值。