From 54c87e271407e94a42851cfe1c32c0591e7168f8 Mon Sep 17 00:00:00 2001 From: "Richard M. Stallman" Date: Sat, 23 Aug 1997 05:19:09 +0000 Subject: [PATCH] (sh-indent-line): Avoid infinite loop on indented line at start of buffer, when calculating PREVIOUS. --- lisp/progmodes/sh-script.el | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index df71e91ad3e..3e2e2d8d849 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el @@ -928,11 +928,13 @@ in ALIST." (defun sh-indent-line () - "Indent as far as preceding non-empty line, then by steps of `sh-indentation'. + "Indent a line for Sh mode (shell script mode). +Indent as far as preceding non-empty line, then by steps of `sh-indentation'. Lines containing only comments are considered empty." (interactive) (let ((previous (save-excursion - (while (and (not (bobp)) + (while (and (progn (beginning-of-line) + (not (bobp))) (progn (forward-line -1) (back-to-indentation) @@ -940,6 +942,7 @@ Lines containing only comments are considered empty." (eq (following-char) ?#))))) (current-column))) current) + (debug) (save-excursion (indent-to (if (eq this-command 'newline-and-indent) previous