Don't fold regions that have a ragged left edge.
authorLars Magne Ingebrigtsen <larsi@quimbies.gnus.org>
Sun, 31 Oct 2010 21:44:07 +0000 (22:44 +0100)
committerLars Magne Ingebrigtsen <larsi@quimbies.gnus.org>
Sun, 31 Oct 2010 21:44:07 +0000 (22:44 +0100)
lisp/ChangeLog
lisp/gnus-cite.el

index 02af2a0..90855eb 100644 (file)
@@ -1,6 +1,8 @@
 2010-10-31  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
        * gnus-cite.el (gnus-article-foldable-buffer): Refactor out.
 2010-10-31  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
        * gnus-cite.el (gnus-article-foldable-buffer): Refactor out.
+       (gnus-article-foldable-buffer): Don't fold regions that have a ragged
+       left edge.
 
        * gnus-sum.el (gnus-summary-show-article): Add `C-u C-u g' for showing
        the raw article, and change `C-u g' to show the article without doing
 
        * gnus-sum.el (gnus-summary-show-article): Add `C-u C-u g' for showing
        the raw article, and change `C-u g' to show the article without doing
index c8de7a6..2afda44 100644 (file)
@@ -558,13 +558,25 @@ longer than the frame width."
              gnus-cite-article nil)))))
 
 (defun gnus-article-foldable-buffer ()
              gnus-cite-article nil)))))
 
 (defun gnus-article-foldable-buffer ()
-  (goto-char (point-min))
-  (while (not (eobp))
-    (end-of-line)
-    (when (> (current-column) (frame-width))
-      (setq do-fill t))
-    (forward-line 1))
-  do-fill)
+  (let ((do-fill nil)
+       columns)
+    (goto-char (point-min))
+    (while (not (eobp))
+      (skip-chars-forward " \t")
+      (unless (eolp)
+       (let ((elem (assq (current-column) columns)))
+         (unless elem
+           (setq elem (cons (current-column) 0))
+           (push elem columns))
+         (setcdr elem (1+ (cdr elem)))))
+      (end-of-line)
+      (when (> (current-column) (frame-width))
+       (setq do-fill t))
+      (forward-line 1))
+    (and do-fill
+        ;; We know know that there are long lines here, but does this look
+        ;; like code?  Check for ragged edges on the left.
+        (< (length columns) 3))))
 
 (defun gnus-article-natural-long-line-p ()
   "Return true if the current line is long, and it's natural text."
 
 (defun gnus-article-natural-long-line-p ()
   "Return true if the current line is long, and it's natural text."