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

Previous Next

Package: emacs;

Reported by: Tassilo Horn <tassilo <at> member.fsf.org>

Date: Mon, 28 Mar 2011 10:09:02 UTC

Severity: wishlist

Tags: patch

Found in version 24.0.9999

Done: Chong Yidong <cyd <at> stupidchicken.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Tassilo Horn <tassilo <at> member.fsf.org>
To: sho nakatani <lay.sakura <at> gmail.com>
Cc: 8364 <at> debbugs.gnu.org
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
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




This bug report was last modified 14 years and 44 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.