]> git.eshelyaron.com Git - emacs.git/commitdiff
shr cleanup and background color fix
authorLars Magne Ingebrigtsen <larsi@gnus.org>
Tue, 10 Feb 2015 07:09:56 +0000 (18:09 +1100)
committerLars Magne Ingebrigtsen <larsi@gnus.org>
Tue, 10 Feb 2015 07:09:56 +0000 (18:09 +1100)
(shr-table-widths): Off-by-one error in width computation.
(shr-expand-newlines): Remove dead code.
(shr-insert-table): Extend background colors to the end of the column.

lisp/ChangeLog
lisp/net/shr.el

index 035cdd9e809993787841d8ba074279a08c521515..5737113a73716028b9ee5dc40e67c1e0a9ddb412 100644 (file)
@@ -35,6 +35,9 @@
        (shr-tag-h1): Don't use variable-pitch fonts on fontless rendering.
        (shr-tag-tt): New function.
        (shr-tag-hr): Compute the right length when using fonts.
+       (shr-table-widths): Off-by-one error in width computation.
+       (shr-expand-newlines): Remove dead code.
+       (shr-insert-table): Extend background colors to the end of the column.
 
 2015-02-10  Fabián Ezequiel Gallina  <fgallina@gnu.org>
 
index aa4c2227def93fdf3cb98ad1b66b9c606075ba31..f40fd34cb8e18dea6c72ac8efbfcf985622a2699 100644 (file)
@@ -1017,44 +1017,6 @@ ones, in case fg and bg are nil."
                                  t)))
       new-colors)))
 
-(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-buffer-width))
-         column)
-      (goto-char (point-min))
-      (while (not (eobp))
-       (end-of-line)
-       (when (and (< (setq column (current-column)) width)
-                  (< (setq column (shr-previous-newline-padding-width column))
-                     width))
-         (let ((overlay (make-overlay (point) (1+ (point)))))
-           (overlay-put overlay 'before-string
-                        (concat
-                         (mapconcat
-                          (lambda (overlay)
-                            (let ((string (plist-get
-                                           (overlay-properties overlay)
-                                           'before-string)))
-                              (if (not string)
-                                  ""
-                                (overlay-put overlay 'before-string "")
-                                string)))
-                          (overlays-at (point))
-                          "")
-                         (propertize (make-string (- width column) ? )
-                                     'face (list :background color))))))
-       (forward-line 1)))))
-
 (defun shr-previous-newline-padding-width (width)
   (let ((overlays (overlays-at (point)))
        (previous-width 0))
@@ -1677,11 +1639,15 @@ The preference is a float determined from `shr-prefer-media-type'."
              (dolist (line lines)
                (end-of-line)
                (let ((start (point)))
-                 (insert line
-                         (propertize " "
-                                     'display `(space :align-to (,pixel-align))
-                                     'shr-table-indent shr-table-id)
-                         shr-table-vertical-line)
+                 (insert
+                  line
+                  (propertize " "
+                              'display `(space :align-to (,pixel-align))
+                              'face (and (> (length line) 0)
+                                         (get-text-property
+                                          (1- (length line)) 'face line))
+                              'shr-table-indent shr-table-id)
+                  shr-table-vertical-line)
                  (shr-colorize-region
                   start (1- (point)) (nth 5 column) (nth 6 column)))
                (forward-line 1))
@@ -1758,7 +1724,7 @@ The preference is a float determined from `shr-prefer-media-type'."
          (setq i (1+ i)))))
     (let ((extra (- (apply '+ (append suggested-widths nil))
                    (apply '+ (append widths nil))
-                   (* shr-table-separator-pixel-width (length widths))))
+                   (* shr-table-separator-pixel-width (1+ (length widths)))))
          (expanded-columns 0))
       ;; We have extra, unused space, so divide this space amongst the
       ;; columns.