From: Lars Magne Ingebrigtsen Date: Tue, 10 Feb 2015 07:09:56 +0000 (+1100) Subject: shr cleanup and background color fix X-Git-Tag: emacs-25.0.90~2008^2~36 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=d5111d525f134d0a1f15c61d16d59b20d824f552;p=emacs.git shr cleanup and background color fix (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. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 035cdd9e809..5737113a737 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -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 diff --git a/lisp/net/shr.el b/lisp/net/shr.el index aa4c2227def..f40fd34cb8e 100644 --- a/lisp/net/shr.el +++ b/lisp/net/shr.el @@ -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.