(声明(缩进*))是如何工作的?

问题描述 投票:3回答:2

信息页面未提及此声明。我找到了用于设置为1,2或3的用途,但还有哪些其他选项?它到底是做什么用的?

在它的表面上,看起来数字意味着宏名称后面的行数进一步向右缩进,但在这种情况下,我如何告诉它将所有表单缩进为第一个?

例子:

(declare (indent 1))这样做:

(-iter 
    (with (a b c))
  (for i from 0 to 5)
  (collect i)
  (message "i: %s" i))

(declare (indent 2))这样做:

(-iter 
    (with (a b c))
    (for i from 0 to 5)
  (collect i)
  (message "i: %s" i))

(declare (indent 256))(或任何足够大的数字)这样做:

(-iter 
    (with (a b c))
    (for i from 0 to 5)
    (collect i)
    (message "i: %s" i))

我想做最后一个,除了提供任意大数字。有没有办法告诉“全部”或某些事情?

emacs elisp
2个回答
1
投票

这是in the manual

C-hig (elisp) Indenting Macros RET

declare,FYI的索引条目相关联。 (Emacs 24.2.1)


0
投票

由于接受的答案实际上没有回答问题,并且手册相当迟钝,让我指出this blog,它揭示了0的值实际上在这里工作,并且是defun的同义词。

但是,缩进级别并没有达到数字。检查:

使用(indent nil)或没有(indent ...)声明:

(-iter
 (with (a b c))
 (for i from 0  to 5)
 (collect i)
 (message "i: %s" i))

使用(indent defun)(indent 0)

(-iter
  (with (a b c))
  (for i from 0 to 5)
  (collect i)
  (message "i: %s" i))

使用(indent 256)

(-iter
    (with (a b c))
    (for i from 0 to 5)
    (collect i)
    (message "i: %s" i))

使用(indent (lambda (x y) 4)),你得到的结果与(indent 256)相同。虽然硬编码缩进可能与使用lisp-indent-function指定不同缩进样式的机制略有冲突。

© www.soinside.com 2019 - 2024. All rights reserved.