2013-06-17 Lars Magne Ingebrigtsen <larsi@gnus.org>
* shr.el (shr-colorize-region): Put the colours over the entire region.
+ (shr-inhibit-decoration): New variable.
+ (shr-add-font): Use it to inhibit text property decorations while doing
+ preliminary table renderings. This speeds up typical Wikipedia page
+ renderings by 15%.
* eww.el (eww-button): New face.
(eww-convert-widgets): Use it to make submit buttons more button-like.
(defvar shr-ignore-cache nil)
(defvar shr-external-rendering-functions nil)
(defvar shr-target-id nil)
+(defvar shr-inhibit-decoration nil)
(defvar shr-map
(let ((map (make-sparse-keymap)))
;; blank text at the start of the line, and the newline at the end, to
;; avoid ugliness.
(defun shr-add-font (start end type)
- (save-excursion
- (goto-char start)
- (while (< (point) end)
- (when (bolp)
- (skip-chars-forward " "))
- (add-face-text-property (point) (min (line-end-position) end) type t)
- (if (< (line-end-position) end)
- (forward-line 1)
- (goto-char end)))))
+ (unless shr-inhibit-decoration
+ (save-excursion
+ (goto-char start)
+ (while (< (point) end)
+ (when (bolp)
+ (skip-chars-forward " "))
+ (add-face-text-property (point) (min (line-end-position) end) type t)
+ (if (< (line-end-position) end)
+ (forward-line 1)
+ (goto-char end))))))
(defun shr-browse-url ()
"Browse the URL under point."
(shr-color-visible bg fg)))))))
(defun shr-colorize-region (start end fg &optional bg)
- (when (or fg bg)
+ (when (and (not shr-inhibit-decoration)
+ (or fg bg))
(let ((new-colors (shr-color-check fg bg)))
(when new-colors
(when fg
(start (point))
shr-start)
(shr-generic cont)
- (when url
+ (when (and url
+ (not shr-inhibit-decoration))
(shr-urlify (or shr-start start) (shr-expand-url url) title))))
(defun shr-tag-object (cont)
data)))
(defun shr-make-table-1 (cont widths &optional fill)
- (let ((trs nil))
+ (let ((trs nil)
+ (shr-inhibit-decoration (not fill)))
(dolist (row cont)
(when (eq (car row) 'tr)
(let ((tds nil)