Subject: bug#6556: html-mode does not align to prev non-empty line when indenting

From: Lennart Borgman <[email-masked]>
Date: Sat, 3 Jul 2010 12:44:19 +0200

On Sat, Jul 3, 2010 at 2:14 AM, Lennart Borgman
<[email-masked]> wrote:
> In a buffer like this
>
>   <p>
>      row 1
>         row 2
>     row 3
>
> the "row 3" gets indented like above. I think it instead should be
> aligned with row2. (I need this for mumamo.)
>
> The comment in sgml-calculate-indent seems to say that this is the
> intention, but the code is maybe unfinished, line 1483:
>
>            (context
>             ;; If possible, align on the previous non-empty text line.
>             ;; Otherwise, do a more serious parsing to find the
>             ;; tag(s) relative to which we should be indenting.
>             (if (and (not unclosed) (skip-chars-backward " \t")
>                      (< (skip-chars-backward " \t\n") 0)
>                      (back-to-indentation)
>                      (> (point) (cdr lcon)))
>                 nil
>               (goto-char here)
>               (nreverse (sgml-get-context (if unclosed nil 'empty)))))
>
> I do not know how it is supposed to work, but I notice that
> (back-to-indentation) is not supposed to return anything special so
> the argument to if may fail (and this seems to happen). Writing that
> part as
>
>

A test for beginning of buffer is needed too since we are looking for
non-blank lines (not non-empty as the comment says):

                      (not (bobp))

>                    (progn
>                      (back-to-indentation)
>                      (> (point) (cdr lcon))))
>
>
> seems to work as expected.
>
>
>
>