[gnus git] branch master updated: =1= (shr-expand-newlines): Make nested boxes work.

Lars Magne Ingebrigtsen <[email protected]>
Newsgroups gmane.emacs.gnus.cvs
Message-ID <[email protected]>
       via  8b0ec1247278502d5ce3962fec0480e35b374987 (commit)
      from  ff1ccae1ed1087b5978d6c8cf89da860e5e3900d (commit)


- Log -----------------------------------------------------------------
commit 8b0ec1247278502d5ce3962fec0480e35b374987
Author: Lars Magne Ingebrigtsen <[email protected]>
Date:   Mon Jan 24 16:32:37 2011 -0800

    (shr-expand-newlines): Make nested boxes work.

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 3778616..279099d 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,7 @@
+2011-01-25  Lars Ingebrigtsen  <[email protected]>
+
+	* shr.el (shr-expand-newlines): Make nested boxes work.
+
 2011-01-24  Lars Ingebrigtsen  <[email protected]>
 
 	* shr.el (shr-expand-newlines): Proof of concept implemantation of boxy
diff --git a/lisp/shr.el b/lisp/shr.el
index e2c51bb..d871af7 100644
--- a/lisp/shr.el
+++ b/lisp/shr.el
@@ -648,6 +648,15 @@ ones, in case fg and bg are nil."
 
 (defun shr-expand-newlines (start end color)
   (save-restriction
+    ;; Skip past all white space at the start and ends.
+    (goto-char start)
+    (skip-chars-forward " \t\n")
+    (beginning-of-line)
+    (setq start (point))
+    (goto-char end)
+    (skip-chars-backward " \t\n")
+    (forward-line 1)
+    (setq end (point))
     (narrow-to-region start end)
     (let ((width (shr-natural-width))
 	  column)
@@ -655,13 +664,36 @@ ones, in case fg and bg are nil."
       (while (not (eobp))
 	(end-of-line)
 	(when (and (< (setq current-column (current-column)) width)
-		   (not (overlays-at (point))))
+		   (< (setq current-column (shr-previous-newline-padding-width
+					    current-column))
+		      width))
 	  (let ((overlay (make-overlay (point) (1+ (point)))))
 	    (overlay-put overlay 'before-string
+			 (concat
+			  (mapconcat
+			   (lambda (overlay)
+			     (let ((string (getf (overlay-properties overlay) 'before-string)))
+			       (if (not string)
+				   ""
+				 (overlay-put overlay 'before-string "")
+				 string)))
+			   (overlays-at (point))
+			   "")
 			 (propertize (make-string (- width current-column) ? )
-				     'face (list :background color)))))
+				      'face (list :background color))))))
 	(forward-line 1)))))
 
+(defun shr-previous-newline-padding-width (width)
+  (let ((overlays (overlays-at (point)))
+	(previous-width 0))
+    (if (null overlays)
+	width
+      (dolist (overlay overlays)
+	(setq previous-width
+	      (+ previous-width
+		 (length (getf (overlay-properties overlay) 'before-string)))))
+      (+ width previous-width))))
+
 (defun shr-put-color-1 (start end type color)
   (let* ((old-props (get-text-property start 'face))
 	 (do-put (not (memq type old-props)))

-----------------------------------------------------------------------
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we listed those
revisions in full, above.

Summary of changes:
 lisp/ChangeLog |    4 ++++
 lisp/shr.el    |   38 +++++++++++++++++++++++++++++++++++---
 2 files changed, 39 insertions(+), 3 deletions(-)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnus Project".

The branch, master has been updated


hooks/post-receive
-- 
Gnus Project
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.