gpt4 book ai didi

elisp - 我如何告诉 emacs 我的 elisp 函数的参数应该如何缩进?

转载 作者:行者123 更新时间:2023-12-02 06:43:56 27 4
gpt4 key购买 nike

我已经编写了类似于 progn 的函数(实际上是一个宏,但无论如何)。如何告诉 emacs 这个函数应该像 progn 一样缩进?

最佳答案

应该这样做

(put 'myfunc 'lisp-indent-function 0)

lisp-indent-function 的文档(由 C-h f lisp-indent-function RET 找到):

lisp-indent-function is a compiled Lisp function in `lisp-mode.el'.

(lisp-indent-function indent-point state)

This function is the normal value of the variable
`lisp-indent-function`. It is used when indenting a line within
a function call, to see if the called function says anything
special about how to indent the line.

indent-point is the position where the user typed TAB, or
equivalent. Point is located at the point to indent under
(for default indentation); state is the `parse-partial-sexp`
state for that position.

If the current line is in a call to a Lisp function which has
a non-nil property `lisp-indent-function`, that specifies how
to do the indentation. The property value can be:

* `defun`, meaning indent `defun`-style;

* an integer N, meaning indent the first N arguments specially
like ordinary function arguments and then indent any further
arguments like a body;

* a function to call just as this function was called. If that
function returns nil, that means it doesn't specify
the indentation.

This function also returns nil meaning don't specify the
indentation.

关于elisp - 我如何告诉 emacs 我的 elisp 函数的参数应该如何缩进?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3412109/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com