changeset 86119:5b6715f2ee11

(doc-view-ghostscript-options): Remove resolution arg. (doc-view-resolution): New custom var. (doc-view-pdf/ps->png): Use it. (doc-view-shrink-factor): New var. (doc-view-enlarge, doc-view-shrink): New commands. (doc-view-mode-map): Use them.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Thu, 15 Nov 2007 19:56:44 +0000
parents 6192870b47dd
children ebee80eef208
files lisp/ChangeLog lisp/doc-view.el
diffstat 2 files changed, 35 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Thu Nov 15 16:59:38 2007 +0000
+++ b/lisp/ChangeLog	Thu Nov 15 19:56:44 2007 +0000
@@ -1,3 +1,12 @@
+2007-11-15  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* doc-view.el (doc-view-ghostscript-options): Remove resolution arg.
+	(doc-view-resolution): New custom var.
+	(doc-view-pdf/ps->png): Use it.
+	(doc-view-shrink-factor): New var.
+	(doc-view-enlarge, doc-view-shrink): New commands.
+	(doc-view-mode-map): Use them.
+
 2007-11-15  Juanma Barranquero  <lekktu@gmail.com>
 
 	* ediff-wind.el (ediff-window-setup-function):
--- a/lisp/doc-view.el	Thu Nov 15 16:59:38 2007 +0000
+++ b/lisp/doc-view.el	Thu Nov 15 19:56:44 2007 +0000
@@ -102,7 +102,8 @@
 ;; - better menu.
 ;; - don't use `find-file'.
 ;; - Bind slicing to a drag event.
-;; - zoom (the whole document and/or just the region around the cursor).
+;; - doc-view-fit-doc-to-window and doc-view-fit-window-to-doc.
+;; - zoom a the region around the cursor (like xdvi).
 ;; - get rid of the silly arrow in the fringe.
 ;; - improve anti-aliasing (pdf-utils gets it better).
 
@@ -154,11 +155,16 @@
   '("-dSAFER" ;; Avoid security problems when rendering files from untrusted
 	      ;; sources.
     "-dNOPAUSE" "-sDEVICE=png16m" "-dTextAlphaBits=4"
-    "-dBATCH" "-dGraphicsAlphaBits=4" "-dQUIET" "-r100")
+    "-dBATCH" "-dGraphicsAlphaBits=4" "-dQUIET")
   "A list of options to give to ghostscript."
   :type '(repeat string)
   :group 'doc-view)
 
+(defcustom doc-view-resolution 100
+  "Dots per inch resolution used to render the documents.
+Higher values result in larger images."
+  :type 'number)
+
 (defcustom doc-view-dvipdfm-program (executable-find "dvipdfm")
   "Program to convert DVI files to PDF.
 
@@ -253,6 +259,9 @@
     (define-key map (kbd "M-<")       'doc-view-first-page)
     (define-key map (kbd "M->")       'doc-view-last-page)
     (define-key map [remap goto-line] 'doc-view-goto-page)
+    ;; Zoom in/out.
+    (define-key map "+"               'doc-view-enlarge)
+    (define-key map "-"               'doc-view-shrink)
     ;; Killing/burying the buffer (and the process)
     (define-key map (kbd "q")         'bury-buffer)
     (define-key map (kbd "k")         'doc-view-kill-proc-and-buffer)
@@ -448,6 +457,20 @@
 
 ;;;; Conversion Functions
 
+(defvar doc-view-shrink-factor 1.125)
+
+(defun doc-view-enlarge (factor)
+  "Enlarge the document."
+  (interactive (list doc-view-shrink-factor))
+  (set (make-local-variable 'doc-view-resolution)
+       (* factor doc-view-resolution))
+  (doc-view-reconvert-doc))
+
+(defun doc-view-shrink (factor)
+  "Shrink the document."
+  (interactive (list doc-view-shrink-factor))
+  (doc-view-enlarge (/ 1.0 factor)))
+
 (defun doc-view-reconvert-doc ()
   "Reconvert the current document.
 Should be invoked when the cached images aren't up-to-date."
@@ -503,6 +526,7 @@
 	       (append (list "pdf/ps->png" doc-view-conversion-buffer
 			     doc-view-ghostscript-program)
 		       doc-view-ghostscript-options
+                       (list (format "-r%d" (round doc-view-resolution)))
 		       (list (concat "-sOutputFile=" png))
 		       (list pdf-ps)))
 	mode-line-process (list (format ":%s" doc-view-current-converter-process)))