Function: lisp-indent-specform
lisp-indent-specform is a byte-compiled function defined in
lisp-mode.el.gz.
Signature
(lisp-indent-specform COUNT STATE INDENT-POINT NORMAL-INDENT)
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/lisp-mode.el.gz
(defun lisp-indent-specform (count state indent-point normal-indent)
(let ((containing-form-start (elt state 1))
(i count)
body-indent containing-form-column)
;; Move to the start of containing form, calculate indentation
;; to use for non-distinguished forms (> count), and move past the
;; function symbol. lisp-indent-function guarantees that there is at
;; least one word or symbol character following open paren of containing
;; form.
(goto-char containing-form-start)
(setq containing-form-column (current-column))
(setq body-indent (+ lisp-body-indent containing-form-column))
(forward-char 1)
(forward-sexp 1)
;; Now find the start of the last form.
(parse-partial-sexp (point) indent-point 1 t)
(while (and (< (point) indent-point)
(condition-case ()
(progn
(setq count (1- count))
(forward-sexp 1)
(parse-partial-sexp (point) indent-point 1 t))
(error nil))))
;; Point is sitting on first character of last (or count) sexp.
(if (> count 0)
;; A distinguished form. If it is the first or second form use double
;; lisp-body-indent, else normal indent. With lisp-body-indent bound
;; to 2 (the default), this just happens to work the same with if as
;; the older code, but it makes unwind-protect, condition-case,
;; with-output-to-temp-buffer, et. al. much more tasteful. The older,
;; less hacked, behavior can be obtained by replacing below with
;; (list normal-indent containing-form-start).
(if (<= (- i count) 1)
(list (+ containing-form-column (* 2 lisp-body-indent))
containing-form-start)
(list normal-indent containing-form-start))
;; A non-distinguished form. Use body-indent if there are no
;; distinguished forms and this is the first undistinguished form,
;; or if this is the first undistinguished form and the preceding
;; distinguished form has indentation at least as great as body-indent.
(if (or (and (= i 0) (= count 0))
(and (= count 0) (<= body-indent normal-indent)))
body-indent
normal-indent))))