From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tassilo Horn Newsgroups: gmane.emacs.bugs Subject: bug#13887: 24.3; doc-view will render blurry images when image-magick is available Date: Thu, 14 Mar 2013 08:24:17 +0100 Message-ID: <87ip4ue95q.fsf@thinkpad.tsdh.de> References: <87txonw6ev.fsf@thinkpad.tsdh.de> <87sj46493q.fsf@thinkpad.tsdh.de> <877gle1etb.fsf@thinkpad.tsdh.de> <838v5tx4av.fsf@gnu.org> <87txohx0g0.fsf@thinkpad.tsdh.de> <831ubllqr0.fsf@gnu.org> <87zjy9vg0r.fsf@thinkpad.tsdh.de> <83y5dtk606.fsf@gnu.org> <83li9sk1bh.fsf@gnu.org> <83hakgjpbi.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1363245904 13918 80.91.229.3 (14 Mar 2013 07:25:04 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 14 Mar 2013 07:25:04 +0000 (UTC) Cc: 13887@debbugs.gnu.org To: E Sabof Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Mar 14 08:25:25 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UG2XU-0002z3-V1 for geb-bug-gnu-emacs@m.gmane.org; Thu, 14 Mar 2013 08:25:25 +0100 Original-Received: from localhost ([::1]:37673 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UG2X8-0000FJ-E6 for geb-bug-gnu-emacs@m.gmane.org; Thu, 14 Mar 2013 03:25:02 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:38191) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UG2X0-0000F2-9D for bug-gnu-emacs@gnu.org; Thu, 14 Mar 2013 03:24:59 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UG2Wz-0002lE-9i for bug-gnu-emacs@gnu.org; Thu, 14 Mar 2013 03:24:54 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:48514) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UG2Wz-0002lA-6A for bug-gnu-emacs@gnu.org; Thu, 14 Mar 2013 03:24:53 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1UG2Y6-0008CQ-EQ for bug-gnu-emacs@gnu.org; Thu, 14 Mar 2013 03:26:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Tassilo Horn Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 14 Mar 2013 07:26:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 13887 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 13887-submit@debbugs.gnu.org id=B13887.136324593331477 (code B ref 13887); Thu, 14 Mar 2013 07:26:02 +0000 Original-Received: (at 13887) by debbugs.gnu.org; 14 Mar 2013 07:25:33 +0000 Original-Received: from localhost ([127.0.0.1]:52623 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UG2Xc-0008Bd-M6 for submit@debbugs.gnu.org; Thu, 14 Mar 2013 03:25:33 -0400 Original-Received: from deliver.uni-koblenz.de ([141.26.64.15]:51506) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UG2XZ-0008BU-3k for 13887@debbugs.gnu.org; Thu, 14 Mar 2013 03:25:30 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by deliver.uni-koblenz.de (Postfix) with ESMTP id 3EA1A1A85A1; Thu, 14 Mar 2013 08:24:18 +0100 (CET) X-Virus-Scanned: amavisd-new at uni-koblenz.de Original-Received: from deliver.uni-koblenz.de ([127.0.0.1]) by localhost (deliver.uni-koblenz.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2IfBSSnmyi9T; Thu, 14 Mar 2013 08:24:17 +0100 (CET) X-CHKRCPT: Envelopesender noch tsdh@gnu.org Original-Received: from thinkpad.tsdh.de (tsdh.uni-koblenz.de [141.26.67.142]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by deliver.uni-koblenz.de (Postfix) with ESMTPSA id C22AA1A85A0; Thu, 14 Mar 2013 08:24:17 +0100 (CET) In-Reply-To: (E. Sabof's message of "Thu, 14 Mar 2013 03:28:27 +0000") User-Agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.3.50 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:72451 Archived-At: E Sabof writes: > The first time (doc-view-insert-image) is called, the doc-view buffer > isn't selected, and (doc-view-current-overlay) returns the t overlay. > > The "fake" overlay gets "resurrected" when (doc-view-insert-image) > calls (move-overlay) on it. Thanks Evgeni, I think that brought me on track. Could you please test-drive this patch (which also contains the centering stuff) and check if the issue is fixed by it? It seems it is for me, but I only did some very brief testing. --8<---------------cut here---------------start------------->8--- === modified file 'lisp/doc-view.el' --- lisp/doc-view.el 2013-02-28 04:02:36 +0000 +++ lisp/doc-view.el 2013-03-14 07:21:18 +0000 @@ -1250,17 +1250,33 @@ (when doc-view-pending-cache-flush (clear-image-cache) (setq doc-view-pending-cache-flush nil)) - (let ((ol (doc-view-current-overlay)) - (image (if (and file (file-readable-p file)) + (let ((ol (doc-view-current-overlay))) + ;; ol might be a deleted (see `doc-view-new-window-function'), in + ;; which case we don't want to modify it. + (when (overlay-buffer ol) + (let* ((image (if (and file (file-readable-p file)) (if (not (and doc-view-scale-internally (fboundp 'imagemagick-types))) (apply 'create-image file doc-view--image-type nil args) (unless (member :width args) (setq args `(,@args :width ,doc-view-image-width))) (apply 'create-image file 'imagemagick nil args)))) - (slice (doc-view-current-slice))) + (slice (doc-view-current-slice)) + (img-width (and image (car (image-size image)))) + (displayed-img-width (if (and image slice) + (* (/ (float (nth 2 slice)) + (car (image-size image 'pixels))) + img-width) + img-width)) + (window-width (window-width (selected-window)))) (setf (doc-view-current-image) image) (move-overlay ol (point-min) (point-max)) + ;; In case the window is wider than the image, center the image + ;; horizontally. + (overlay-put ol 'before-string + (when (and image (> window-width displayed-img-width)) + (propertize " " 'display + `(space :align-to (+ center (-0.5 . ,displayed-img-width)))))) (overlay-put ol 'display (cond (image @@ -1287,7 +1303,7 @@ (vscroll (image-mode-window-get 'vscroll win))) ;; Reset scroll settings, in case they were changed. (if hscroll (set-window-hscroll win hscroll)) - (if vscroll (set-window-vscroll win vscroll))))))) + (if vscroll (set-window-vscroll win vscroll))))))))) (defun doc-view-sort (a b) "Return non-nil if A should be sorted before B. --8<---------------cut here---------------end--------------->8--- Bye, Tassilo