Function: eww-render
eww-render is a byte-compiled function defined in eww.el.gz.
Signature
(eww-render STATUS URL &optional POINT BUFFER ENCODE)
Source Code
;; Defined in /usr/src/emacs/lisp/net/eww.el.gz
(defun eww-render (status url &optional point buffer encode)
(let* ((headers (eww-parse-headers))
(content-type
(mail-header-parse-content-type
(if (zerop (length (cdr (assoc "content-type" headers))))
"text/plain"
(cdr (assoc "content-type" headers)))))
(charset (intern
(downcase
(or (cdr (assq 'charset (cdr content-type)))
(eww-detect-charset (eww-html-p (car content-type)))
"utf-8"))))
(data-buffer (current-buffer))
(shr-target-id (url-target (url-generic-parse-url url)))
last-coding-system-used)
(let ((redirect (plist-get status :redirect)))
(when redirect
(setq url redirect)))
(with-current-buffer buffer
;; Save the https peer status.
(plist-put eww-data :peer (plist-get status :peer))
;; Make buffer listings more informative.
(setq list-buffers-directory url)
;; Let the URL library have a handle to the current URL for
;; referer purposes.
(setq url-current-lastloc (url-generic-parse-url url)))
(unwind-protect
(progn
(cond
((and eww-use-external-browser-for-content-type
(string-match-p eww-use-external-browser-for-content-type
(car content-type)))
(erase-buffer)
(insert "<title>Unsupported content type</title>")
(insert (format "<h1>Content-type %s is unsupported</h1>"
(car content-type)))
(insert (format "<a href=%S>Direct link to the document</a>"
url))
(goto-char (point-min))
(eww-display-html charset url nil point buffer encode))
((eww-html-p (car content-type))
(eww-display-html charset url nil point buffer encode))
((equal (car content-type) "application/pdf")
(eww-display-pdf))
((string-match-p "\\`image/" (car content-type))
(eww-display-image buffer))
(t
(eww-display-raw buffer (or encode charset 'utf-8))))
(with-current-buffer buffer
(plist-put eww-data :url url)
(eww--after-page-change)
(setq eww-history-position 0)
(and last-coding-system-used
(set-buffer-file-coding-system last-coding-system-used))
(run-hooks 'eww-after-render-hook)
;; Enable undo again so that undo works in text input
;; boxes.
(setq buffer-undo-list nil)))
(kill-buffer data-buffer))))