Function: scheme-indent-function
scheme-indent-function is a byte-compiled function defined in
scheme.el.gz.
Signature
(scheme-indent-function INDENT-POINT STATE)
Documentation
Scheme mode function for the value of the variable lisp-indent-function(var)/lisp-indent-function(fun).
This behaves like the function lisp-indent-function(var)/lisp-indent-function(fun), except that:
i) it checks for a non-nil value of the property scheme-indent-function
(or the deprecated scheme-indent-hook), rather than lisp-indent-function(var)/lisp-indent-function(fun).
ii) if that property specifies a function, it is called with three arguments (not two), the third argument being the default (i.e., current) indentation.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/scheme.el.gz
;; FIXME this duplicates almost all of lisp-indent-function.
;; Extract common code to a subroutine.
(defun scheme-indent-function (indent-point state)
"Scheme mode function for the value of the variable `lisp-indent-function'.
This behaves like the function `lisp-indent-function', except that:
i) it checks for a non-nil value of the property `scheme-indent-function'
\(or the deprecated `scheme-indent-hook'), rather than `lisp-indent-function'.
ii) if that property specifies a function, it is called with three
arguments (not two), the third argument being the default (i.e., current)
indentation."
(let ((normal-indent (current-column)))
(goto-char (1+ (elt state 1)))
(parse-partial-sexp (point) calculate-lisp-indent-last-sexp 0 t)
(if (and (elt state 2)
(not (looking-at "\\sw\\|\\s_")))
;; car of form doesn't seem to be a symbol
(progn
(if (not (> (save-excursion (forward-line 1) (point))
calculate-lisp-indent-last-sexp))
(progn (goto-char calculate-lisp-indent-last-sexp)
(beginning-of-line)
(parse-partial-sexp (point)
calculate-lisp-indent-last-sexp 0 t)))
;; Indent under the list or under the first sexp on the same
;; line as calculate-lisp-indent-last-sexp. Note that first
;; thing on that line has to be complete sexp since we are
;; inside the innermost containing sexp.
(backward-prefix-chars)
(current-column))
(let ((function (buffer-substring (point)
(progn (forward-sexp 1) (point))))
method)
(setq method (or (get (intern-soft function) 'scheme-indent-function)
(get (intern-soft function) 'scheme-indent-hook)))
(cond ((or (eq method 'defun)
(and (null method)
(> (length function) 3)
(string-match "\\`def" function)))
(lisp-indent-defform state indent-point))
((integerp method)
(lisp-indent-specform method state
indent-point normal-indent))
(method
(funcall method state indent-point normal-indent)))))))