emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r101832: Merge changes made in Gnus t


From: Katsumi Yamaoka
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r101832: Merge changes made in Gnus trunk.
Date: Thu, 07 Oct 2010 11:46:01 +0000
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 101832
author: Gnus developers
committer: Katsumi Yamaoka <address@hidden>
branch nick: trunk
timestamp: Thu 2010-10-07 11:46:01 +0000
message:
  Merge changes made in Gnus trunk.
  
  nnimap.el (nnimap-request-rename-group): Add this method.
  shr.el: Keep track of the natural width of TD elements, so we know which ones 
to expand.
  shr.el: Expand TD elements to fill available space.
modified:
  lisp/gnus/ChangeLog
  lisp/gnus/nnimap.el
  lisp/gnus/shr.el
=== modified file 'lisp/gnus/ChangeLog'
--- a/lisp/gnus/ChangeLog       2010-10-07 06:47:37 +0000
+++ b/lisp/gnus/ChangeLog       2010-10-07 11:46:01 +0000
@@ -1,3 +1,12 @@
+2010-10-07  Lars Magne Ingebrigtsen  <address@hidden>
+
+       * shr.el (shr-table-widths): Expand TD elements to fill available
+       space.
+
+2010-10-07  Julien Danjou  <address@hidden>
+
+       * nnimap.el (nnimap-request-rename-group): Add this method.
+
 2010-10-07  Katsumi Yamaoka  <address@hidden>
 
        * gnus-html.el (gnus-html-schedule-image-fetching): Remove function

=== modified file 'lisp/gnus/nnimap.el'
--- a/lisp/gnus/nnimap.el       2010-10-06 12:38:45 +0000
+++ b/lisp/gnus/nnimap.el       2010-10-07 11:46:01 +0000
@@ -652,6 +652,11 @@
     (with-current-buffer (nnimap-buffer)
       (car (nnimap-command "DELETE %S" (utf7-encode group t))))))
 
+(deffoo nnimap-request-rename-group (group new-name &optional server)
+  (when (nnimap-possibly-change-group nil server)
+    (with-current-buffer (nnimap-buffer)
+      (car (nnimap-command "RENAME %S %S" (utf7-encode group t) (utf7-encode 
new-name t))))))
+
 (deffoo nnimap-request-expunge-group (group &optional server)
   (when (nnimap-possibly-change-group group server)
     (with-current-buffer (nnimap-buffer)

=== modified file 'lisp/gnus/shr.el'
--- a/lisp/gnus/shr.el  2010-10-06 13:21:07 +0000
+++ b/lisp/gnus/shr.el  2010-10-07 11:46:01 +0000
@@ -184,7 +184,8 @@
           ((and (or (not first)
                     (eq shr-state 'space))
                 (> (+ column (length elem) 1) shr-width))
-           (insert "\n"))
+           (insert "\n")
+           (put-text-property (1- (point)) (point) 'shr-break t))
           ((not first)
            (insert " "))))
        (setq first nil)
@@ -459,7 +460,7 @@
         ;; be smaller (if there's little text) or bigger (if there's
         ;; unbreakable text).
         (sketch (shr-make-table cont suggested-widths))
-        (sketch-widths (shr-table-widths sketch (length suggested-widths))))
+        (sketch-widths (shr-table-widths sketch suggested-widths)))
     ;; Then render the table again with these new "hard" widths.
     (shr-insert-table (shr-make-table cont sketch-widths t) sketch-widths))
   ;; Finally, insert all the images after the table.  The Emacs buffer
@@ -490,7 +491,7 @@
        (insert "|\n"))
       (dolist (column row)
        (goto-char start)
-       (let ((lines (split-string (nth 2 column) "\n"))
+       (let ((lines (nth 2 column))
              (overlay-lines (nth 3 column))
              overlay overlay-line)
          (dolist (line lines)
@@ -520,14 +521,33 @@
     (insert (make-string (aref widths i) ?-) ?+))
   (insert "\n"))
 
-(defun shr-table-widths (table length)
-  (let ((widths (make-vector length 0)))
+(defun shr-table-widths (table suggested-widths)
+  (let* ((length (length suggested-widths))
+        (widths (make-vector length 0))
+        (natural-widths (make-vector length 0)))
     (dolist (row table)
       (let ((i 0))
        (dolist (column row)
          (aset widths i (max (aref widths i)
                              (car column)))
-         (incf i))))
+         (aset natural-widths i (max (aref natural-widths i)
+                                     (cadr column)))
+         (setq i (1+ i)))))
+    (let ((extra (- (reduce '+ suggested-widths)
+                   (reduce '+ widths)))
+         (expanded-columns 0))
+      (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))))))))
     widths))
 
 (defun shr-make-table (cont widths &optional fill)
@@ -575,11 +595,26 @@
            (when (> (- width (current-column)) 0)
              (insert (make-string (- width (current-column)) ? )))
            (forward-line 1))))
-      (list max
-           (count-lines (point-min) (point-max))
-           (buffer-string)
-           (and fill
-                (shr-collect-overlays))))))
+      (if fill
+         (list max
+               (count-lines (point-min) (point-max))
+               (split-string (buffer-string) "\n")
+               (shr-collect-overlays))
+       (list max
+             (shr-natural-width))))))
+
+(defun shr-natural-width ()
+  (goto-char (point-min))
+  (let ((current 0)
+       (max 0))
+    (while (not (eobp))
+      (end-of-line)
+      (setq current (+ current (current-column)))
+      (unless (get-text-property (point) 'shr-break)
+       (setq max (max max current)
+             current 0))
+      (forward-line 1))
+    max))
 
 (defun shr-collect-overlays ()
   (save-excursion
@@ -608,12 +643,12 @@
   (let ((total-percentage 0)
        (widths (make-vector (length columns) 0)))
     (dotimes (i (length columns))
-      (incf total-percentage (aref columns i)))
+      (setq total-percentage (+ total-percentage (aref columns i))))
     (setq total-percentage (/ 1.0 total-percentage))
     (dotimes (i (length columns))
       (aset widths i (max (truncate (* (aref columns i)
                                       total-percentage
-                                      shr-width))
+                                      (- shr-width (1+ (length columns)))))
                          10)))
     widths))
 


reply via email to

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