emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r110235: * doc-view.el (doc-view-curr


From: Tassilo Horn
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r110235: * doc-view.el (doc-view-current-cache-doc-pdf): New function.
Date: Fri, 28 Sep 2012 12:05:46 +0200
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 110235
committer: Tassilo Horn <address@hidden>
branch nick: trunk
timestamp: Fri 2012-09-28 12:05:46 +0200
message:
  * doc-view.el (doc-view-current-cache-doc-pdf): New function.
  (doc-view-doc->txt, doc-view-convert-current-doc): Use it.
  (doc-view-get-bounding-box): Make bounding box slicing work for
  ODF and DVI documents.
modified:
  lisp/ChangeLog
  lisp/doc-view.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2012-09-28 08:01:08 +0000
+++ b/lisp/ChangeLog    2012-09-28 10:05:46 +0000
@@ -1,3 +1,10 @@
+2012-09-28  Tassilo Horn  <address@hidden>
+
+       * doc-view.el (doc-view-current-cache-doc-pdf): New function.
+       (doc-view-doc->txt, doc-view-convert-current-doc): Use it.
+       (doc-view-get-bounding-box): Make bounding box slicing work for
+       ODF and DVI documents.
+
 2012-09-28  Glenn Morris  <address@hidden>
 
        * type-break.el (type-break-mode, type-break-interval)

=== modified file 'lisp/doc-view.el'
--- a/lisp/doc-view.el  2012-09-27 03:16:35 +0000
+++ b/lisp/doc-view.el  2012-09-28 10:05:46 +0000
@@ -904,6 +904,11 @@
                           (list "-raw" pdf txt)
                           callback))
 
+(defun doc-view-current-cache-doc-pdf ()
+  "Return the name of the doc.pdf in the current cache dir.
+  This file exists only if the current document isn't a PDF or PS file 
already."
+  (expand-file-name "doc.pdf" (doc-view-current-cache-dir)))
+
 (defun doc-view-doc->txt (txt callback)
   "Convert the current document to text and call CALLBACK when done."
   (make-directory (doc-view-current-cache-dir) t)
@@ -914,22 +919,17 @@
     (`ps
      ;; Doc is a PS, so convert it to PDF (which will be converted to
      ;; TXT thereafter).
-     (let ((pdf (expand-file-name "doc.pdf"
-                                 (doc-view-current-cache-dir))))
+     (let ((pdf (doc-view-current-cache-doc-pdf)))
        (doc-view-ps->pdf doc-view-buffer-file-name pdf
                          (lambda () (doc-view-pdf->txt pdf txt callback)))))
     (`dvi
      ;; Doc is a DVI.  This means that a doc.pdf already exists in its
      ;; cache subdirectory.
-     (doc-view-pdf->txt (expand-file-name "doc.pdf"
-                                          (doc-view-current-cache-dir))
-                        txt callback))
+     (doc-view-pdf->txt (doc-view-current-cache-doc-pdf) txt callback))
     (`odf
      ;; Doc is some ODF (or MS Office) doc.  This means that a doc.pdf
      ;; already exists in its cache subdirectory.
-     (doc-view-pdf->txt (expand-file-name "doc.pdf"
-                                          (doc-view-current-cache-dir))
-                        txt callback))
+     (doc-view-pdf->txt (doc-view-current-cache-doc-pdf) txt callback))
     (_ (error "DocView doesn't know what to do"))))
 
 (defun doc-view-ps->pdf (ps pdf callback)
@@ -969,13 +969,13 @@
       (`dvi
        ;; DVI files have to be converted to PDF before Ghostscript can process
        ;; it.
-       (let ((pdf (expand-file-name "doc.pdf" doc-view-current-cache-dir)))
+       (let ((pdf (doc-view-current-cache-doc-pdf)))
          (doc-view-dvi->pdf doc-view-buffer-file-name pdf
                             (lambda () (doc-view-pdf/ps->png pdf png-file)))))
       (`odf
        ;; ODF files have to be converted to PDF before Ghostscript can
        ;; process it.
-       (let ((pdf (expand-file-name "doc.pdf" doc-view-current-cache-dir))
+       (let ((pdf (doc-view-current-cache-doc-pdf))
              (opdf (expand-file-name (concat (file-name-base 
doc-view-buffer-file-name)
                                              ".pdf")
                                      doc-view-current-cache-dir))
@@ -1042,12 +1042,15 @@
 (defun doc-view-get-bounding-box ()
   "Get the BoundingBox information of the current page."
   (let* ((page (doc-view-current-page))
+        (doc (let ((cache-doc (doc-view-current-cache-doc-pdf)))
+               (if (file-exists-p cache-doc)
+                   cache-doc
+                 doc-view-buffer-file-name)))
         (o (shell-command-to-string
             (concat doc-view-ghostscript-program
                     " -dSAFER -dBATCH -dNOPAUSE -q -sDEVICE=bbox "
                     (format "-dFirstPage=%s -dLastPage=%s %s"
-                            page page
-                            doc-view-buffer-file-name)))))
+                            page page doc)))))
     (save-match-data
       (when (string-match (concat "%%BoundingBox: "
                                  "\\([[:digit:]]+\\) \\([[:digit:]]+\\) "


reply via email to

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