[gnus git] branch no-gnus updated: m0-1-84-g12f0d4b =1= shr nested table rendering fixups

Lars Magne Ingebrigtsen <[email protected]>
Newsgroups gmane.emacs.gnus.cvs
Message-ID <[email protected]>
       via  12f0d4b89c61c49e5aa8767d9db2b0839f9b27bf (commit)
      from  970a203fe353113143ae9b07a435810e9b189e09 (commit)


- Log -----------------------------------------------------------------
commit 12f0d4b89c61c49e5aa8767d9db2b0839f9b27bf
Author: Lars Magne Ingebrigtsen <[email protected]>
Date:   Wed Mar 14 18:27:00 2012 +0100

    shr nested table rendering fixups
    
    * shr.el (shr-table-widths): Divide the extra width more fairly over
    the TDs (bug#10973).
    (shr-render-td): Don't delete too much padding.

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 3f30576..e3ba10e 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,9 @@
 2012-03-14  Lars Magne Ingebrigtsen  <[email protected]>
 
+	* shr.el (shr-table-widths): Divide the extra width more fairly over
+	the TDs (bug#10973).
+	(shr-render-td): Don't delete too much padding.
+
 	* gnus-msg.el (gnus-bug): Don't delete the other windows.  We may be
 	using a `gnus-use-full-window' setup (bug#11013).
 
diff --git a/lisp/shr.el b/lisp/shr.el
index 41f1224..e98c930 100644
--- a/lisp/shr.el
+++ b/lisp/shr.el
@@ -1198,21 +1198,26 @@ ones, in case fg and bg are nil."
 	  (aset natural-widths i (max (aref natural-widths i)
 				      (cadr column)))
 	  (setq i (1+ i)))))
-    (let ((extra (- (apply '+ (append suggested-widths nil))
-		    (apply '+ (append widths nil))))
+    (let* ((total-suggested (apply '+ (append suggested-widths nil)))
+	   (total-actual (apply '+ (append widths nil)))
+	   (extra (- total-suggested
+		     total-actual
+		     ;; TD separators.
+		     (length widths)
+		     ;; Table separators + fence.
+		     3
+		     (* 2 shr-table-depth)))
 	  (expanded-columns 0))
+      ;; We have extra, unused space, so divide this space amongst the
+      ;; columns.
       (when (> extra 0)
-	(dotimes (i length)
 	  ;; If the natural width is wider than the rendered width, we
 	  ;; want to allow the column to expand.
-	  (when (> (aref natural-widths i) (aref widths i))
-	    (setq expanded-columns (1+ expanded-columns))))
 	(dotimes (i length)
-	  (when (> (aref natural-widths i) (aref widths i))
-	    (aset widths i (min
-			    (1+ (aref natural-widths i))
-			    (+ (/ extra expanded-columns)
-			       (aref widths i))))))))
+	  (when (> (aref natural-widths i) 0)
+	    (aset widths i (+ (truncate (* (/ extra (* 1.0 total-actual))
+					   (aref widths i)))
+			      (aref widths i)))))))
     widths))
 
 (defun shr-make-table (cont widths &optional fill)
@@ -1265,10 +1270,13 @@ ones, in case fg and bg are nil."
 	  (let ((shr-width width)
 		(shr-indentation 0))
 	    (shr-descend (cons 'td cont)))
+	  ;; Delete padding at the bottom of the TDs.
 	  (delete-region
 	   (point)
-	   (+ (point)
-	      (skip-chars-backward " \t\n")))
+	   (progn
+	     (skip-chars-backward " \t\n")
+	     (end-of-line)
+	     (point)))
 	  (push (list (cons width cont) (buffer-string)
 		      (shr-overlays-in-region (point-min) (point-max)))
 		shr-content-cache)))

-----------------------------------------------------------------------
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, 27 insertions(+), 15 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, no-gnus 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.