You can control such indentation using options lisp-indent-offset
and lisp-body-indent
, option lisp-indent-function
, or symbol property lisp-indent-function
. One possible value for option lisp-indent-function
is the value of common-lisp-indent-function
.
See the Emacs manual, node Lisp Indent (and its parent node, Program Indent), for more information.
See also standard library cl-indent.el
.
For example:
(defun lisp-indentation-hack ()
"Your Lisp indenting. Use in Lisp mode hooks
such as `lisp-mode-hook', `emacs-lisp-mode-hook', and
`lisp-interaction-mode-hook'."
(unless (load-history-filename-element (load-history-regexp "cl-indent"))
(load "cl-indent" nil t))
(set (make-local-variable 'lisp-indent-function) 'common-lisp-indent-function)
(setq lisp-indent-maximum-backtracking 10)
(put 'define-derived-mode 'common-lisp-indent-function '(4 4 4 2 &body))
(put 'if 'common-lisp-indent-function '(nil nil &body))
(when (featurep 'cl-indent)
(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))))
(add-hook 'emacs-lisp-mode-hook 'lisp-indentation-hack)
lispy-save-excursion
, evaluating that will only change indentation of calls tolispy-save-excursion
. If you want to fix the indentation oflispy-dotimes
, you'll have to actually retrieve its source, eval its definition and reindent the example.