Function: lua-indent-line

lua-indent-line is a byte-compiled function defined in lua-mode.el.gz.

Signature

(lua-indent-line)

Documentation

Indent current line for Lua mode.

Return the amount the indentation changed by.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/lua-mode.el.gz
(defun lua-indent-line ()
  "Indent current line for Lua mode.
Return the amount the indentation changed by."
  (let (indent
        (case-fold-search nil)
        ;; Save point as a distance to eob - it's invariant w.r.t
        ;; indentation.
        (pos (- (point-max) (point))))
    (back-to-indentation)
    (setq indent (if (lua-comment-or-string-p)
                     ;; Just restore point position.
                     (lua-calculate-string-or-comment-indentation)
                   (max 0 (lua-calculate-indentation))))

    (unless (equal indent (current-column))
      (delete-region (line-beginning-position) (point))
      (indent-to indent))

    ;; If initial point was within line's indentation, position after
    ;; the indentation.  Else stay at same point in text.
    (when (> (- (point-max) pos) (point))
      (goto-char (- (point-max) pos)))

    indent))