From: Lars Magne Ingebrigtsen Date: Mon, 3 Nov 2014 19:39:08 +0000 (+0100) Subject: Make eww display PDFs inline X-Git-Tag: emacs-25.0.90~2635^2~583 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=39804c1adb5972939221d22c422c421dd2b7145c;p=emacs.git Make eww display PDFs inline * net/eww.el (eww-display-html): Clear `url-queue'. (eww-display-pdf): New function. (eww-render): Display PDFs with `doc-view'. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index ffea1b323ad..4de1fe0fded 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2014-11-03 Lars Magne Ingebrigtsen + + * net/eww.el (eww-display-html): Clear `url-queue'. + (eww-display-pdf): New function. + (eww-render): Display PDFs with `doc-view'. + 2014-11-03 Yoni Rabkin * net/eww.el (eww-list-bookmarks): Autoload. diff --git a/lisp/net/eww.el b/lisp/net/eww.el index f319d68e1fb..9a97f02747f 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el @@ -214,6 +214,8 @@ word(s) will be searched for via `eww-search-prefix'." (eww-browse-with-external-browser url)) ((equal (car content-type) "text/html") (eww-display-html charset url nil point)) + ((equal (car content-type) "application/pdf") + (eww-display-pdf)) ((string-match-p "\\`image/" (car content-type)) (eww-display-image) (eww-update-header-line-format)) @@ -256,6 +258,9 @@ word(s) will be searched for via `eww-search-prefix'." (defun eww-display-html (charset url &optional document point) (or (fboundp 'libxml-parse-html-region) (error "This function requires Emacs to be compiled with libxml2")) + ;; There should be a better way to abort loading images + ;; asynchronously. + (setq url-queue nil) (let ((document (or document (list @@ -393,6 +398,16 @@ word(s) will be searched for via `eww-search-prefix'." (shr-put-image data nil)) (goto-char (point-min)))) +(defun eww-display-pdf () + (let ((data (buffer-substring (point) (point-max)))) + (switch-to-buffer (get-buffer-create "*eww pdf*")) + (let ((coding-system-for-write 'raw-text) + (inhibit-read-only t)) + (erase-buffer) + (insert data) + (doc-view-mode))) + (goto-char (point-min))) + (defun eww-setup-buffer () (switch-to-buffer (get-buffer-create "*eww*")) (let ((inhibit-read-only t))