From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: gjadi@omecha.info (=?utf-8?Q?Gr=C3=A9goire?= Jadi) Newsgroups: gmane.emacs.devel Subject: [PATCH] Search for image from the beginning of the fetched buffer Date: Sat, 22 Jul 2017 12:09:28 +0200 Message-ID: <87r2x8u6jr.fsf@omecha.info> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1500719161 29283 195.159.176.226 (22 Jul 2017 10:26:01 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 22 Jul 2017 10:26:01 +0000 (UTC) To: Emacs Devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Jul 22 12:25:57 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dYrbf-00078x-0G for ged-emacs-devel@m.gmane.org; Sat, 22 Jul 2017 12:25:55 +0200 Original-Received: from localhost ([::1]:46514 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dYrbh-0000DH-Hz for ged-emacs-devel@m.gmane.org; Sat, 22 Jul 2017 06:25:57 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44258) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dYrLt-0005ln-OX for emacs-devel@gnu.org; Sat, 22 Jul 2017 06:09:38 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dYrLo-0004BS-QZ for emacs-devel@gnu.org; Sat, 22 Jul 2017 06:09:37 -0400 Original-Received: from a.omecha.info ([89.234.176.136]:50120 helo=omecha.info) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dYrLo-0004Az-Ju for emacs-devel@gnu.org; Sat, 22 Jul 2017 06:09:32 -0400 Original-Received: from puffy.omecha.info (unknown [192.168.99.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by omecha.info (Postfix) with ESMTPSA id 36E03243 for ; Sat, 22 Jul 2017 12:09:29 +0200 (CEST) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 89.234.176.136 X-Mailman-Approved-At: Sat, 22 Jul 2017 06:25:47 -0400 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:216934 Archived-At: Hi, Some background : When browsing files locally (file://) images are never rendered right the first time by eww/shr. I have to use redisplay (`eww-redisplay') to display the images. In the *Message* buffer, I've the following error : > ImageMagick error: no decode delegate for this image format `' @ error/blob.c/BlobToImage/353 After a bit of lurking, I found out that the image where correctly restored from the cache, because it starts to parse at position 1. However, the position in the buffer in `shr-image-fetched' is something else >1. I haven't figured out why the position isn't right (I suspect something in `url-file'). The fix I've found so far is to force position 1 in `shr-image-fetched'. I've also disabled multibyte because `shr-get-image-data' does it, but it might be unnecessary. Patch below. Best, PS: I've FSF copyright assignment number #793656 * lisp/net/shr.el (shr-image-fetched): Disable multibyte and go back to the beginning of the buffer before trying to parse the image fetched. --- lisp/net/shr.el | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lisp/net/shr.el b/lisp/net/shr.el index 4d4e8a809e..b4dd60cf48 100644 --- a/lisp/net/shr.el +++ b/lisp/net/shr.el @@ -945,6 +945,8 @@ shr-image-fetched (when (and (buffer-name buffer) (not (plist-get status :error))) (url-store-in-cache image-buffer) + (goto-char (point-min)) + (mm-disable-multibyte) (when (or (search-forward "\n\n" nil t) (search-forward "\r\n\r\n" nil t)) (let ((data (shr-parse-image-data))) -- 2.13.1