bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#8364: 24.0.9999; PATCH: Fit to width/height/page for doc-view.el


From: Tassilo Horn
Subject: bug#8364: 24.0.9999; PATCH: Fit to width/height/page for doc-view.el
Date: Wed, 30 Mar 2011 12:20:37 +0200
User-agent: Gnus/5.110016 (No Gnus v0.16) Emacs/24.0.9999 (gnu/linux)

Hi Nakatani,

thanks a lot for fiddeling with the issue.  I've found the bug in your
code.  Here's a working function:

--8<---------------cut here---------------start------------->8---
(defun doc-view-fit-slice-width-to-window ()
  (interactive)
  (let ((slice (doc-view-current-slice)))
    (if (null slice)
        (doc-view-fit-width-to-window)
      ;; If slice is set
      (let* ((slice-width (nth 2 slice))
             (win-width (- (nth 2 (window-inside-pixel-edges))
                           (nth 0 (window-inside-pixel-edges))))
             (scale-factor (/ (float win-width) (float slice-width)))
             (new-slice (mapcar (lambda (x) (ceiling (* scale-factor x))) 
slice)))
        (set (make-local-variable 'doc-view-resolution)
             (ceiling (* scale-factor doc-view-resolution)))
        (doc-view-enlarge scale-factor)
        (setf (doc-view-current-slice) new-slice)
        (doc-view-goto-page (doc-view-current-page))))))
--8<---------------cut here---------------end--------------->8---

The problematic issue was that the `new-slice' calculated by the
`mapcar' contained floating point numbers, which are not allowed for
slice specs.  I found out by using `edebug-defun' on
`doc-view-insert-image'.

One minor thing: I would prefer if your three original functions would
respect the current slice if there is one, instead of adding a fourth
function for that purpose.  Could you please make it that way?

Thanks again, you really did very impressive work!

And I'm especially pleased that my assumption of calculating the right
scales of both image and slices out of the plain images without
resorting to external tools turned out being right. ;-)

Bye,
Tassilo





reply via email to

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