Commit 2a14f364 authored by David Byers's avatar David Byers
Browse files

Fixed bugs in paragraph filling.

Detailed changes:
> 2006-06-27  David Byers  <davby@ida.liu.se>
>
> 	* lyskom-rest.el (lyskom-fill-next-paragraph): Fixed off-by-one
> 	error causing the last character on the last line to (sometimes)
> 	be put on a line of its own in XEmacs.
> 	(lyskom-maybe-fill-region): Fixed off-by-one error causing lines
> 	just under fill-column long to be wrapped.
>
> 2006-05-14  David Byers  <davby@ida.liu.se>
>
> 	* utilities.el (lyskom-text-comments): Added parameter
> 	skip-footnotes.
>
> 2006-04-26  David Byers  <davby@ida.liu.se>
>
> 	* lyskom-rest.el (lyskom-fill-next-paragraph): Eliminated the
> 	inner catch, as this seemed to cost more time than adding a
> 	clause to each conditional in the loop.
> 	(lyskom-fill-message-line-length): Make this a subst.
>
parent 3043ba96
2006-06-27 David Byers <davby@ida.liu.se>
* lyskom-rest.el (lyskom-fill-next-paragraph): Fixed off-by-one
error causing the last character on the last line to (sometimes)
be put on a line of its own in XEmacs.
(lyskom-maybe-fill-region): Fixed off-by-one error causing lines
just under fill-column long to be wrapped.
2006-05-14 David Byers <davby@ida.liu.se>
* utilities.el (lyskom-text-comments): Added parameter
skip-footnotes.
2006-04-26 David Byers <davby@ida.liu.se>
* lyskom-rest.el (lyskom-fill-next-paragraph): Eliminated the
inner catch, as this seemed to cost more time than adding a
clause to each conditional in the loop.
(lyskom-fill-message-line-length): Make this a subst.
2006-05-03 Pontus Freyhult <pont@soua.net>
* option-edit.el, vars.el.in, swedish-strings.el,english-strings.el,
......
......@@ -2448,18 +2448,23 @@ in lyskom-messages."
(defmacro lyskom-fill-message-next-line ()
`(throw 'lyskom-fill-message-next-line t))
`(setq next-line t))
(defmacro lyskom-fill-message-return ()
`(throw 'lyskom-fill-message-return t))
(defsubst lyskom-fill-message-line-length ()
(- (save-excursion (end-of-line)
(skip-chars-backward " \t")
(current-column)) (current-column)))
(defmacro lyskom-maybe-fill-region (start end &optional justify nosqueeze to-eop)
"Fill the region from START to END if the prerequisites for doing
so are met. This macro checks on the internal state of
lyskom-fill-next-paragraph to see if the text scanned should be filled
or not."
`(unless (or (<= ,end ,start)
(< paragraph-width fill-column)
(<= paragraph-width fill-column)
quoted-paragraph
special-characters
(eq all-colon-lines t)
......@@ -2534,6 +2539,7 @@ or not."
(paragraph-length 0)
(paragraph-width 0)
(eol-point 0)
(next-line nil)
;; Variables used for geometric texts
(geometric-text t)
......@@ -2570,14 +2576,19 @@ or not."
;;
(while (not (eobp))
(setq next-line nil)
;;
;; Code can throw to here to prevent further processing
;; of a line of input. This is used when a line has been
;; completely categorized.
;;
;; FIXME: Paragraph-width is only used when starting to fill a paragraph, so we should
;; FIXME: compute it only at that point.
;;
;; FIXME: If we can move the special patterns check, we can lose eol-point as well, and
;; FIXME: only compute it when it's needed to calculate paragraph-width.
(catch 'lyskom-fill-message-next-line
(setq next-char (char-after (point)))
(setq eol-point (save-excursion (end-of-line) (point)))
(setq paragraph-width (max paragraph-width (- eol-point (point))))
......@@ -2601,6 +2612,12 @@ or not."
;; the entire paragraph from being filled. This should catch
;; source code and many preformatted things.
;;
;; FIXME: It is probably possible to do this once when starting
;; FIXME: to fill the text. Alternately, we could scan forward
;; FIXME: for a para break as soon as we spot this.
;; FIXME:
;; FIXME: I suspect that indented paragraphs may trigger this
;; FIXME: rule.
(when (save-excursion
(re-search-forward lyskom-fill-disqualifying-regexp eol-point t))
......@@ -2620,7 +2637,8 @@ or not."
;; set a flag.
;;
(when (looking-at "^\\s-*\\([-*+#]\\|[§#]?\\s-*[0-9]+[.):]?\\)\\s-*")
(when (and (not next-line)
(looking-at "^\\s-*\\([-*+#]\\|[§#]?\\s-*[0-9]+[.):]?\\)\\s-*"))
(when (lyskom-maybe-fill-region start (1- (point)) nil t)
(lyskom-fill-message-return))
(setq bulleted-paragraph (match-string 0))
......@@ -2635,7 +2653,7 @@ or not."
;; - It can continue an all-colon line
;;
(when (looking-at "^\\(\\s-+\\)\\S-")
(when (and (not next-line) (looking-at "^\\(\\s-+\\)\\S-"))
(cond (bulleted-paragraph (lyskom-fill-message-next-line))
((equal (match-string 1) indented-paragraph)
(lyskom-fill-message-next-line))
......@@ -2650,7 +2668,7 @@ or not."
;; a paragraph with first-line indentation.
;;
(when (and indented-paragraph (looking-at "^\\S-"))
(when (and (not next-line) indented-paragraph (looking-at "^\\S-"))
(setq indented-paragraph nil))
......@@ -2663,7 +2681,8 @@ or not."
;; character.
;;
(when (and (not (looking-at "^\\s-"))
(when (and (not next-line)
(not (looking-at "^\\s-"))
(< (lyskom-char-to-int next-char)
(length lyskom-line-start-chars))
(not (aref lyskom-line-start-chars
......@@ -2678,7 +2697,9 @@ or not."
;; This rule detects mail-header-like stuff
;;
(if (and all-colon-lines (looking-at "^\\S-+\\s-*:"))
(if (and (not next-line)
all-colon-lines
(looking-at "^\\S-+\\s-*:"))
(setq all-colon-lines t)
(setq all-colon-lines nil))
......@@ -2689,7 +2710,7 @@ or not."
;; which is enforced in lyskom-maybe-fill-region
;;
(when geometric-text
(when (and (not next-line) geometric-text)
(setq current-line-length (lyskom-fill-message-line-length))
(cond ((and (null length-difference)
current-line-length
......@@ -2705,7 +2726,6 @@ or not."
) ;; catch lyskom-fill-message-next-line
(setq last-line-length current-line-length)
(end-of-line)
......@@ -2719,7 +2739,7 @@ or not."
) ;; while
(lyskom-maybe-fill-region start (1- (point)) nil t)
(lyskom-maybe-fill-region start (point) nil t)
) ;; catch lyskom-fill-message-return
......@@ -2741,12 +2761,6 @@ or not."
(beginning-of-line))))
(defun lyskom-fill-message-line-length ()
(- (save-excursion (end-of-line)
(skip-chars-backward " \t")
(current-column)) (current-column)))
;;; ============================================================
;;; Beeping and feeping
;;; Faces and colors
......
......@@ -1309,11 +1309,13 @@ car of each element is the recipient number and the cdr is the type."
result)))))
(nreverse result)))
(defun lyskom-text-comments (text-stat)
"Return the list of comments to TEXT-STAT"
(defun lyskom-text-comments (text-stat &optional skip-footnotes)
"Return the list of comments to TEXT-STAT.
If optional SKIP-FOOTNOTES is non-nil, do not return footnotes."
(let ((result nil))
(lyskom-traverse misc (text-stat->misc-info-list text-stat)
(cond ((eq (misc-info->type misc) 'FOOTN-IN)
(cond ((and (not skip-footnotes)
(eq (misc-info->type misc) 'FOOTN-IN))
(setq result (cons (misc-info->footn-in misc) result)))
((eq (misc-info->type misc) 'COMM-IN)
(setq result (cons (misc-info->comm-in misc) result)))))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment