7

The current indentation for cl-flet seems really ugly to me. See for instance:

(defun foo (lst)
  (cl-flet ((unusually-long-bar (x)
                                (1+ x)
                                (1+ x)
                                (1+ x)))
    (mapcar #'unusually-long-bar lst)))

I'd like to set it to something more sensible, like:

(defun foo (lst)
  (cl-flet ((unusually-long-bar (x)
              (1+ x)
              (1+ x)
              (1+ x)))
    (mapcar #'unusually-long-bar lst)))

How can I do this?

4

2 回答 2

6

以下应该有效:

(setq lisp-indent-function 'common-lisp-indent-function)
(eval-after-load "cl-indent"
  '(progn

    (put 'cl-flet 'common-lisp-indent-function 
     (get 'flet 'common-lisp-indent-function))

    ))
于 2013-07-20T22:12:05.277 回答
3

作为对 Sabof 答案的补充,这里有一个片段cl-,当后者存在时,它将所有 Common Lisp 符号的缩进规则复制到它们的前缀 Emacs 等效项:

(load-library "cl-indent") ; defines the common-lisp-indent-function properties
(cl-loop for symbol being the symbols
         for cl-indent-rule = (get symbol 'common-lisp-indent-function)
         for elisp-equivalent = (intern-soft (concat "cl-" (symbol-name symbol)))
         when (and cl-indent-rule elisp-equivalent (fboundp elisp-equivalent))
         do (put elisp-equivalent 'common-lisp-indent-function cl-indent-rule))
于 2013-07-20T22:22:07.217 回答