emacs-pretest-bug
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: fill-paragraph bug


From: Stefan Monnier
Subject: Re: fill-paragraph bug
Date: Fri, 07 Jul 2006 15:05:57 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

> Insert the following text in a LaTeX buffer, and call M-q:

> AAAAAAAAAAAAAA AAAAAAAAAAAAAAAAA AAAAAAAAAAAAAA 
> AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 
> AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 
> AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAA%AAAAAAAAAAAAAA 
> AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 
> AAAAAAAAAAAAAAAAA

> the result:

> Debugger entered--Lisp error: (error "fill-prefix too long for specified 
> width")

The first hunk of the patch below removes the error.
The subsequent ones fix the subsequent incorrect filling.


        Stefan


--- fill.el     01 May 2006 14:40:54 -0400      1.187
+++ fill.el     07 Jul 2006 15:02:01 -0400      
@@ -408,9 +408,10 @@
                          "\\)?[ \t]*")
                "[ \t]*")))
     (goto-char from)
-    (if (>= (+ (current-left-margin) (length prefix))
-           (current-fill-column))
-       (error "fill-prefix too long for specified width"))
+    ;; Why signal an error here?  The problem needs to be caught elsewhere.
+    ;; (if (>= (+ (current-left-margin) (length prefix))
+    ;;         (current-fill-column))
+    ;;     (error "fill-prefix too long for specified width"))
     (forward-line 1)
     (while (< (point) to)
       (if (looking-at fpre)
@@ -419,7 +420,7 @@
     (goto-char from)
     (if (looking-at fpre)
        (goto-char (match-end 0)))
-    (setq from (point))))
+    (point)))
 
 ;; The `fill-space' property carries the string with which a newline
 ;; should be replaced when unbreaking a line (in fill-delete-newlines).
@@ -627,8 +628,10 @@
   (let ((from-plus-indent (point))
        (oneleft nil))
 
-    (beginning-of-line)
-    (setq from (point))
+    ;; We used to round up to whole line, but that prevents us from
+    ;; correctly handling filling of mixed code-and-comment where we
+    ;; do want to fill the comment but not the code.
+    ;; (beginning-of-line) (setq from (point))
 
     ;; Delete all but one soft newline at end of region.
     ;; And leave TO before that one.
@@ -857,7 +860,8 @@
                         (or (comment-search-forward (line-end-position) t)
                             (point)))
                        (looking-at comment-re))
-                     1 2))))
+                     (progn (setq comstart (point)) 1)
+                   (progn (setq comstart (point)) 2)))))
           ;; Find the beginning of the first line past the region to fill.
           (save-excursion
             (while (progn (forward-line 1)
@@ -874,7 +878,7 @@
                    (concat paragraph-start "\\|[ \t]*\\(?:"
                            comment-start-skip "\\)\\(?:"
                            (default-value 'paragraph-start) "\\)"))
-                  ;; We used to reply on fill-prefix to break paragraph at
+                  ;; We used to rely on fill-prefix to break paragraph at
                   ;; comment-starter changes, but it did not work for the
                   ;; first line (mixed comment&code).
                   ;; We now use comment-re instead to "manually" make sure
@@ -903,7 +907,7 @@
          ;; Don't fill with narrowing.
          (or
           (fill-region-as-paragraph
-           beg end justify nil
+           (max comstart beg) end justify nil
            ;; Don't canonicalize spaces within the code just before
            ;; the comment.
            (save-excursion




reply via email to

[Prev in Thread] Current Thread [Next in Thread]