gpt4 book ai didi

emacs - 自定义 Elisp plist 缩进

转载 作者:行者123 更新时间:2023-12-04 03:43:56 25 4
gpt4 key购买 nike

我不喜欢 Elisp 中 plists 的缩进方式。

;; current   desired   Python (for comparison)
;; '(a 1 '(a 1 {'a': 1,
;; b 2 b 2 'b': 2,
;; c 3) c 3) 'c': 3}

在 M-x emacs-version 24.3.1 上尝试,运行 emacs -Q ,输入 plist 并按下 C-x h C-M-\。

当它不是列表时,这种缩进是有意义的:
(mapcar (lambda (x) (x + 1))
'(1 2 3 4))

如何更改格式设置,以便 只有 plists (或者,如果不可能,所有引用的列表)具有所需的矩形缩进,但 其他所有内容的缩进保持不变 ?我需要将其本地存储在 .el 文件中,以便当我编辑此文件时,它会根据需要缩进,但这种行为不会在其他任何地方结束。

最佳答案

找到了:

(setq lisp-indent-function 'common-lisp-indent-function)

这是一个示例文件:

(setq x  '(a 1
b 2
c 3))

;;; Local Variables:
;;; lisp-indent-function: common-lisp-indent-function
;;; End:

我将在这里转储我的整个缩进配置:

(setq lisp-indent-function 'common-lisp-indent-function)
(put 'cl-flet 'common-lisp-indent-function
(get 'flet 'common-lisp-indent-function))
(put 'cl-labels 'common-lisp-indent-function
(get 'labels 'common-lisp-indent-function))
(put 'if 'common-lisp-indent-function 2)
(put 'dotimes-protect 'common-lisp-indent-function
(get 'when 'common-lisp-indent-function))

关于emacs - 自定义 Elisp plist 缩进,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22166895/

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