always ends in a magicline. Changes to cut_line(),
do_cut_till_end(), open_buffer(), read_file(), write_file(),
do_last_line(), do_para_end(), backup_lines(),
- find_paragraph(), do_justify() (not completely fixed yet),
- do_alt_speller(), and do_wordlinechar_count(). (DLR)
+ find_paragraph(), do_justify(), do_alt_speller(), and
+ do_wordlinechar_count(). (DLR)
- Tweak a few functions to rely on fileage and filebot instead
of NULL for their checks to detect the top or bottom of the
file. Changes to cut_line(), cut_to_eol(), do_page_up(),
return FALSE;
/* If the current line isn't in a paragraph, move forward to the
- * line after the last line of the next paragraph, if any. If the
- * line before that isn't in a paragraph, it means that there aren't
- * any paragraphs left, so get out. Otherwise, move back to the
- * last line of the paragraph. If the current line is in a
- * paragraph and it isn't the first line of that paragraph, move
- * back to the first line of the paragraph. */
+ * last line of the next paragraph, if any. */
if (!inpar(openfile->current)) {
- current_save = openfile->current;
do_para_end(FALSE);
- if (!inpar(openfile->current->prev))
- return FALSE;
- if (openfile->current != openfile->fileage)
- openfile->current = openfile->current->prev;
+ /* If we end up past the beginning of the line, it means that
+ * we're at the end of the last line of the file, and the line
+ * isn't blank, in which case the last line of the file is the
+ * last line of the next paragraph.
+ *
+ * Otherwise, if we end up on a line that's in a paragraph, it
+ * means that we're on the line after the last line of the next
+ * paragraph, in which case we should move back to the last line
+ * of the next paragraph. */
+ if (openfile->current_x == 0) {
+ if (!inpar(openfile->current->prev))
+ return FALSE;
+ if (openfile->current != openfile->fileage)
+ openfile->current = openfile->current->prev;
+ }
}
+ /* If the current line isn't the first line of the paragraph, move
+ * back to the first line of the paragraph. */
if (!begpar(openfile->current))
do_para_begin(FALSE);
/* Now current is the first line of the paragraph. Set quote_len to
* the quotation length of that line, and set par_len to the number
- * of lines in this paragraph. If, while calculating the latter, we
- * end up past the beginning of the line, it means that we're at the
- * end of the last line of the file, and the line isn't blank, in
- * which case the last line of the file is part of this
- * paragraph. */
+ * of lines in this paragraph. */
quote_len = quote_length(openfile->current->data);
current_save = openfile->current;
current_y_save = openfile->current_y;
do_para_end(FALSE);
par_len = openfile->current->lineno - current_save->lineno;
+ /* If we end up past the beginning of the line, it means that we're
+ * at the end of the last line of the file, and the line isn't
+ * blank, in which case the last line of the file is part of the
+ * paragraph. */
if (openfile->current_x > 0)
par_len++;
openfile->current = current_save;
/* The first indentation that doesn't match the initial
* indentation of the paragraph we justify. This is put at
* the beginning of every line broken off the first
- * justified line of the paragraph. (Note that this works
+ * justified line of the paragraph. Note that this works
* because a paragraph can only contain two indentations at
* most: the initial one, and a different one starting on a
* line after the first. See the comment at begpar() for
- * more about when a line is part of a paragraph.) */
+ * more about when a line is part of a paragraph. */
/* Find the first line of the paragraph to be justified. That
* is the start of this paragraph if we're in one, or the start