【问题标题】:guile macro indentation in emacsemacs 中的 guile 宏缩进
【发布时间】:2017-10-13 01:52:51
【问题描述】:

是否有类似 (declare (indent defun)) 的东西用于 guile,所以用户定义的宏的缩进就像 defines 一样工作?

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

(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 中,我可以通过

获得所需的缩进
(defmacro my-when (condition &rest body)
  (declare (indent defun))
  `(if ,condition
       ,@body))

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

版本/模式说明:emacs 26、scheme-mode w/ geisergeiser-impl--implementation = guile

【问题讨论】:

    标签: emacs macros scheme indentation guile


    【解决方案1】:

    为符号添加缩进提示:

    (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

    【讨论】:

    • 在您的 init.el 中
    猜你喜欢
    • 2010-12-12
    • 1970-01-01
    • 2018-10-08
    • 1970-01-01
    • 1970-01-01
    • 2016-08-08
    • 1970-01-01
    • 1970-01-01
    • 2011-08-20
    相关资源
    最近更新 更多