Function: lua-calculate-indentation-info

lua-calculate-indentation-info is a byte-compiled function defined in lua-mode.el.gz.

Signature

(lua-calculate-indentation-info &optional PARSE-END)

Documentation

Compute how each block token on the line affects indentation.

The effect of each token can be either a shift relative to the current indentation level, or indentation to some absolute column. This information is collected in a list of indentation info pairs, which denote absolute and relative each, and the shift/column to indent to.

The argument PARSE-END is a buffer position that bounds the calculation.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/lua-mode.el.gz
(defun lua-calculate-indentation-info (&optional parse-end)
  "Compute how each block token on the line affects indentation.
The effect of each token can be either a shift relative to the current
indentation level, or indentation to some absolute column.  This
information is collected in a list of indentation info pairs, which
denote absolute and relative each, and the shift/column to indent to.

The argument PARSE-END is a buffer position that bounds the calculation."
  (let (indentation-info cont-stmt-pos)
    (while (setq cont-stmt-pos (lua-is-continuing-statement-p))
      (lua-forward-line-skip-blanks 'back)
      (when (< cont-stmt-pos (point))
        (goto-char cont-stmt-pos)))

    ;; Calculate indentation modifiers for the line itself
    (setq indentation-info (list (cons 'absolute (current-indentation))))

    (back-to-indentation)
    (setq indentation-info
          (lua-calculate-indentation-info-1
           indentation-info (min parse-end (line-end-position))))

    ;; And do the following for each continuation line before PARSE-END
    (while (and (eql (forward-line 1) 0)
                (<= (point) parse-end))

      ;; Handle continuation lines:
      (if (lua-is-continuing-statement-p)
          ;; If it's the first continuation line, add one level
          (unless (eq (car (car indentation-info)) 'continued-line)
            (push (cons 'continued-line lua-indent-level) indentation-info))

        ;; If it's the first non-continued line, subtract one level
        (when (eq (car (car indentation-info)) 'continued-line)
          (push (cons 'stop-continued-line (- lua-indent-level)) indentation-info)))

      ;; Add modifiers found in this continuation line
      (setq indentation-info
            (lua-calculate-indentation-info-1
             indentation-info (min parse-end (line-end-position)))))

    indentation-info))