Function: sh-basic-indent-line
sh-basic-indent-line is an interactive and byte-compiled function
defined in sh-script.el.gz.
Signature
(sh-basic-indent-line)
Documentation
Indent a line for Sh mode (shell script mode).
Indent as far as preceding non-empty line, then by steps of sh-basic-offset.
Lines containing only comments are considered empty.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/sh-script.el.gz
(defun sh-basic-indent-line ()
"Indent a line for Sh mode (shell script mode).
Indent as far as preceding non-empty line, then by steps of `sh-basic-offset'.
Lines containing only comments are considered empty."
(interactive)
(let ((previous (save-excursion
(while (and (progn (beginning-of-line)
(not (bobp)))
(progn
(forward-line -1)
(back-to-indentation)
(or (eolp)
(eq (following-char) ?#)))))
(current-column)))
current)
(save-excursion
(indent-to (if (or (eq this-command 'newline-and-indent)
(and electric-indent-mode (eq this-command 'newline)))
previous
(if (< (current-column)
(setq current (progn (back-to-indentation)
(current-column))))
(if (eolp) previous 0)
(delete-region (point)
(progn (beginning-of-line) (point)))
(if (eolp)
(max previous (* (1+ (/ current sh-basic-offset))
sh-basic-offset))
(* (1+ (/ current sh-basic-offset)) sh-basic-offset))))))
(if (< (current-column) (current-indentation))
(skip-chars-forward " \t"))))