diff options
| author | Gnus developers | 2010-10-07 11:46:01 +0000 |
|---|---|---|
| committer | Katsumi Yamaoka | 2010-10-07 11:46:01 +0000 |
| commit | a7dcc87b1b2ce2c4d8c4d26a95cbdb3df1b67a20 (patch) | |
| tree | ac84596aa1e9ebec399c021664f3d0fb3b8413f4 | |
| parent | b0e0b216e540ffcde8a0ec8f0c572bb90c464eb9 (diff) | |
| download | emacs-a7dcc87b1b2ce2c4d8c4d26a95cbdb3df1b67a20.tar.gz emacs-a7dcc87b1b2ce2c4d8c4d26a95cbdb3df1b67a20.zip | |
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.
| -rw-r--r-- | lisp/gnus/ChangeLog | 9 | ||||
| -rw-r--r-- | lisp/gnus/nnimap.el | 5 | ||||
| -rw-r--r-- | lisp/gnus/shr.el | 61 |
3 files changed, 62 insertions, 13 deletions
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog index 65658909153..bb3d1ccacb6 100644 --- a/lisp/gnus/ChangeLog +++ b/lisp/gnus/ChangeLog | |||
| @@ -1,3 +1,12 @@ | |||
| 1 | 2010-10-07 Lars Magne Ingebrigtsen <larsi@gnus.org> | ||
| 2 | |||
| 3 | * shr.el (shr-table-widths): Expand TD elements to fill available | ||
| 4 | space. | ||
| 5 | |||
| 6 | 2010-10-07 Julien Danjou <julien@danjou.info> | ||
| 7 | |||
| 8 | * nnimap.el (nnimap-request-rename-group): Add this method. | ||
| 9 | |||
| 1 | 2010-10-07 Katsumi Yamaoka <yamaoka@jpl.org> | 10 | 2010-10-07 Katsumi Yamaoka <yamaoka@jpl.org> |
| 2 | 11 | ||
| 3 | * gnus-html.el (gnus-html-schedule-image-fetching): Remove function | 12 | * gnus-html.el (gnus-html-schedule-image-fetching): Remove function |
diff --git a/lisp/gnus/nnimap.el b/lisp/gnus/nnimap.el index 7d935e4ecd1..2fa9d7cb143 100644 --- a/lisp/gnus/nnimap.el +++ b/lisp/gnus/nnimap.el | |||
| @@ -652,6 +652,11 @@ textual parts.") | |||
| 652 | (with-current-buffer (nnimap-buffer) | 652 | (with-current-buffer (nnimap-buffer) |
| 653 | (car (nnimap-command "DELETE %S" (utf7-encode group t)))))) | 653 | (car (nnimap-command "DELETE %S" (utf7-encode group t)))))) |
| 654 | 654 | ||
| 655 | (deffoo nnimap-request-rename-group (group new-name &optional server) | ||
| 656 | (when (nnimap-possibly-change-group nil server) | ||
| 657 | (with-current-buffer (nnimap-buffer) | ||
| 658 | (car (nnimap-command "RENAME %S %S" (utf7-encode group t) (utf7-encode new-name t)))))) | ||
| 659 | |||
| 655 | (deffoo nnimap-request-expunge-group (group &optional server) | 660 | (deffoo nnimap-request-expunge-group (group &optional server) |
| 656 | (when (nnimap-possibly-change-group group server) | 661 | (when (nnimap-possibly-change-group group server) |
| 657 | (with-current-buffer (nnimap-buffer) | 662 | (with-current-buffer (nnimap-buffer) |
diff --git a/lisp/gnus/shr.el b/lisp/gnus/shr.el index 1c496ced543..ffbb4302924 100644 --- a/lisp/gnus/shr.el +++ b/lisp/gnus/shr.el | |||
| @@ -184,7 +184,8 @@ redirects somewhere else." | |||
| 184 | ((and (or (not first) | 184 | ((and (or (not first) |
| 185 | (eq shr-state 'space)) | 185 | (eq shr-state 'space)) |
| 186 | (> (+ column (length elem) 1) shr-width)) | 186 | (> (+ column (length elem) 1) shr-width)) |
| 187 | (insert "\n")) | 187 | (insert "\n") |
| 188 | (put-text-property (1- (point)) (point) 'shr-break t)) | ||
| 188 | ((not first) | 189 | ((not first) |
| 189 | (insert " ")))) | 190 | (insert " ")))) |
| 190 | (setq first nil) | 191 | (setq first nil) |
| @@ -459,7 +460,7 @@ Return a string with image data." | |||
| 459 | ;; be smaller (if there's little text) or bigger (if there's | 460 | ;; be smaller (if there's little text) or bigger (if there's |
| 460 | ;; unbreakable text). | 461 | ;; unbreakable text). |
| 461 | (sketch (shr-make-table cont suggested-widths)) | 462 | (sketch (shr-make-table cont suggested-widths)) |
| 462 | (sketch-widths (shr-table-widths sketch (length suggested-widths)))) | 463 | (sketch-widths (shr-table-widths sketch suggested-widths))) |
| 463 | ;; Then render the table again with these new "hard" widths. | 464 | ;; Then render the table again with these new "hard" widths. |
| 464 | (shr-insert-table (shr-make-table cont sketch-widths t) sketch-widths)) | 465 | (shr-insert-table (shr-make-table cont sketch-widths t) sketch-widths)) |
| 465 | ;; Finally, insert all the images after the table. The Emacs buffer | 466 | ;; Finally, insert all the images after the table. The Emacs buffer |
| @@ -490,7 +491,7 @@ Return a string with image data." | |||
| 490 | (insert "|\n")) | 491 | (insert "|\n")) |
| 491 | (dolist (column row) | 492 | (dolist (column row) |
| 492 | (goto-char start) | 493 | (goto-char start) |
| 493 | (let ((lines (split-string (nth 2 column) "\n")) | 494 | (let ((lines (nth 2 column)) |
| 494 | (overlay-lines (nth 3 column)) | 495 | (overlay-lines (nth 3 column)) |
| 495 | overlay overlay-line) | 496 | overlay overlay-line) |
| 496 | (dolist (line lines) | 497 | (dolist (line lines) |
| @@ -520,14 +521,33 @@ Return a string with image data." | |||
| 520 | (insert (make-string (aref widths i) ?-) ?+)) | 521 | (insert (make-string (aref widths i) ?-) ?+)) |
| 521 | (insert "\n")) | 522 | (insert "\n")) |
| 522 | 523 | ||
| 523 | (defun shr-table-widths (table length) | 524 | (defun shr-table-widths (table suggested-widths) |
| 524 | (let ((widths (make-vector length 0))) | 525 | (let* ((length (length suggested-widths)) |
| 526 | (widths (make-vector length 0)) | ||
| 527 | (natural-widths (make-vector length 0))) | ||
| 525 | (dolist (row table) | 528 | (dolist (row table) |
| 526 | (let ((i 0)) | 529 | (let ((i 0)) |
| 527 | (dolist (column row) | 530 | (dolist (column row) |
| 528 | (aset widths i (max (aref widths i) | 531 | (aset widths i (max (aref widths i) |
| 529 | (car column))) | 532 | (car column))) |
| 530 | (incf i)))) | 533 | (aset natural-widths i (max (aref natural-widths i) |
| 534 | (cadr column))) | ||
| 535 | (setq i (1+ i))))) | ||
| 536 | (let ((extra (- (reduce '+ suggested-widths) | ||
| 537 | (reduce '+ widths))) | ||
| 538 | (expanded-columns 0)) | ||
| 539 | (when (> extra 0) | ||
| 540 | (dotimes (i length) | ||
| 541 | ;; If the natural width is wider than the rendered width, we | ||
| 542 | ;; want to allow the column to expand. | ||
| 543 | (when (> (aref natural-widths i) (aref widths i)) | ||
| 544 | (setq expanded-columns (1+ expanded-columns)))) | ||
| 545 | (dotimes (i length) | ||
| 546 | (when (> (aref natural-widths i) (aref widths i)) | ||
| 547 | (aset widths i (min | ||
| 548 | (1+ (aref natural-widths i)) | ||
| 549 | (+ (/ extra expanded-columns) | ||
| 550 | (aref widths i)))))))) | ||
| 531 | widths)) | 551 | widths)) |
| 532 | 552 | ||
| 533 | (defun shr-make-table (cont widths &optional fill) | 553 | (defun shr-make-table (cont widths &optional fill) |
| @@ -575,11 +595,26 @@ Return a string with image data." | |||
| 575 | (when (> (- width (current-column)) 0) | 595 | (when (> (- width (current-column)) 0) |
| 576 | (insert (make-string (- width (current-column)) ? ))) | 596 | (insert (make-string (- width (current-column)) ? ))) |
| 577 | (forward-line 1)))) | 597 | (forward-line 1)))) |
| 578 | (list max | 598 | (if fill |
| 579 | (count-lines (point-min) (point-max)) | 599 | (list max |
| 580 | (buffer-string) | 600 | (count-lines (point-min) (point-max)) |
| 581 | (and fill | 601 | (split-string (buffer-string) "\n") |
| 582 | (shr-collect-overlays)))))) | 602 | (shr-collect-overlays)) |
| 603 | (list max | ||
| 604 | (shr-natural-width)))))) | ||
| 605 | |||
| 606 | (defun shr-natural-width () | ||
| 607 | (goto-char (point-min)) | ||
| 608 | (let ((current 0) | ||
| 609 | (max 0)) | ||
| 610 | (while (not (eobp)) | ||
| 611 | (end-of-line) | ||
| 612 | (setq current (+ current (current-column))) | ||
| 613 | (unless (get-text-property (point) 'shr-break) | ||
| 614 | (setq max (max max current) | ||
| 615 | current 0)) | ||
| 616 | (forward-line 1)) | ||
| 617 | max)) | ||
| 583 | 618 | ||
| 584 | (defun shr-collect-overlays () | 619 | (defun shr-collect-overlays () |
| 585 | (save-excursion | 620 | (save-excursion |
| @@ -608,12 +643,12 @@ Return a string with image data." | |||
| 608 | (let ((total-percentage 0) | 643 | (let ((total-percentage 0) |
| 609 | (widths (make-vector (length columns) 0))) | 644 | (widths (make-vector (length columns) 0))) |
| 610 | (dotimes (i (length columns)) | 645 | (dotimes (i (length columns)) |
| 611 | (incf total-percentage (aref columns i))) | 646 | (setq total-percentage (+ total-percentage (aref columns i)))) |
| 612 | (setq total-percentage (/ 1.0 total-percentage)) | 647 | (setq total-percentage (/ 1.0 total-percentage)) |
| 613 | (dotimes (i (length columns)) | 648 | (dotimes (i (length columns)) |
| 614 | (aset widths i (max (truncate (* (aref columns i) | 649 | (aset widths i (max (truncate (* (aref columns i) |
| 615 | total-percentage | 650 | total-percentage |
| 616 | shr-width)) | 651 | (- shr-width (1+ (length columns))))) |
| 617 | 10))) | 652 | 10))) |
| 618 | widths)) | 653 | widths)) |
| 619 | 654 | ||