emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r118273: Make eww display PDFs inline


From: Lars Ingebrigtsen
Subject: [Emacs-diffs] trunk r118273: Make eww display PDFs inline
Date: Mon, 03 Nov 2014 19:39:11 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 118273
revision-id: address@hidden
parent: address@hidden
committer: Lars Magne Ingebrigtsen <address@hidden>
branch nick: trunk
timestamp: Mon 2014-11-03 20:39:08 +0100
message:
  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'.
modified:
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/net/eww.el                eww.el-20130610114603-80ap3gwnw4x4m5ix-1
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2014-11-03 13:22:43 +0000
+++ b/lisp/ChangeLog    2014-11-03 19:39:08 +0000
@@ -1,3 +1,9 @@
+2014-11-03  Lars Magne Ingebrigtsen  <address@hidden>
+
+       * 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 <address@hidden>
 
        * net/eww.el (eww-list-bookmarks): Autoload.

=== modified file 'lisp/net/eww.el'
--- a/lisp/net/eww.el   2014-11-03 13:22:43 +0000
+++ b/lisp/net/eww.el   2014-11-03 19:39:08 +0000
@@ -214,6 +214,8 @@
             (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 @@
 (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 @@
       (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))


reply via email to

[Prev in Thread] Current Thread [Next in Thread]