From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#44338: 27.1; EWW can't download and view pdf Date: Thu, 05 Nov 2020 21:20:01 +0200 Message-ID: <83eel7a9we.fsf@gnu.org> References: <878sbmo6i0.fsf@tcd.ie> <83tuu5b1oh.fsf@gnu.org> <837dqzc42r.fsf@gnu.org> <83sg9najmh.fsf@gnu.org> <83h7q3adsh.fsf@gnu.org> <87lfff39rc.fsf@tcd.ie> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24101"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 44338@debbugs.gnu.org, nicholasharrison222@gmail.com To: "Basil L. Contovounesios" Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Nov 05 20:21:17 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kakou-0006AZ-Vj for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 05 Nov 2020 20:21:16 +0100 Original-Received: from localhost ([::1]:49426 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kakou-0006z7-2l for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 05 Nov 2020 14:21:16 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56278) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kakog-0006vo-E3 for bug-gnu-emacs@gnu.org; Thu, 05 Nov 2020 14:21:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:42621) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kakog-0007eT-34 for bug-gnu-emacs@gnu.org; Thu, 05 Nov 2020 14:21:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kakof-0003qX-Ub for bug-gnu-emacs@gnu.org; Thu, 05 Nov 2020 14:21:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 05 Nov 2020 19:21:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 44338 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 44338-submit@debbugs.gnu.org id=B44338.160460401814708 (code B ref 44338); Thu, 05 Nov 2020 19:21:01 +0000 Original-Received: (at 44338) by debbugs.gnu.org; 5 Nov 2020 19:20:18 +0000 Original-Received: from localhost ([127.0.0.1]:54167 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kakny-0003p8-9D for submit@debbugs.gnu.org; Thu, 05 Nov 2020 14:20:18 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:55974) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kaknx-0003ox-7t for 44338@debbugs.gnu.org; Thu, 05 Nov 2020 14:20:17 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:35538) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaknq-0007LJ-DK; Thu, 05 Nov 2020 14:20:11 -0500 Original-Received: from [176.228.60.248] (port=3395 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kaknl-0004bt-KI; Thu, 05 Nov 2020 14:20:07 -0500 In-Reply-To: <87lfff39rc.fsf@tcd.ie> (contovob@tcd.ie) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:192750 Archived-At: > From: "Basil L. Contovounesios" > Cc: Nicholas Harrison , 44338@debbugs.gnu.org > Date: Thu, 05 Nov 2020 19:04:55 +0000 > > > Great, then the change Basil already made locally will also solve the > > last part of the problem. > > The change is no longer local, which prompted some off-list comments > from Stefan that confused me. > > mailcap-view-mime already binds coding-system-for-write to 'binary > before writing to a file and spawning a subshell, so why does the > coding-system-for-write matter in its caller eww-display-pdf? I don't think this part of mailcap-view-mime matters in this case: (defun mailcap-view-mime (type) "View the data in the current buffer that has MIME type TYPE. `mailcap--computed-mime-data' determines the method to use." (let ((method (mailcap-mime-info type))) (if (stringp method) (let ((file (make-temp-file "emacs-mailcap" nil (cadr (split-string type "/"))))) (unwind-protect (let ((coding-system-for-write 'binary)) (write-region (point-min) (point-max) file nil 'silent) (delete-region (point-min) (point-max)) (shell-command (format method file))) (when (file-exists-p file) (delete-file file)))) (funcall method)))) As you see, mailcap-view-mime only binds coding-system-for-write if mailcap-mime-info returns a string, which should then be a shell command. But in our case, mailcap-mime-info returns doc-view-mode, a symbol of a function, and in that case mailcap-mime-info just calls the function. That said, I don't think I understand well enough what exactly happened in the problematic case, because I didn't succeed in getting a backtrace which matched the problem description. So the above is based on some looking into a crystal ball, and thus might be wrong. > In other words, can we remove the binding altogether from > eww-display-pdf and make the *eww pdf* buffer unibyte, as Stefan > suggested? If we want to remove the binding from eww-display-pdf, it should go to doc-view-mode, because only it knows what it needs. mailcap-view-mime is right not to do anything when it calls the function, since it cannot know what that function will or will not do. Please also note that doc-view-mode expects to be called on a unibyte buffer with 'no-conversion' as its buffer-file-coding-system, because we have ("\\.pdf\\'" . no-conversion) in auto-coding-alist. So an alternative solution would be for eww to arrange for the buffer to be unibyte; then no binding of coding-system-for-write will be needed. > Could something funny happen / be happening during insertion from one > buffer into the other in eww-display-pdf? In principle, maybe, but I don't see what could happen in the case in point, given the circumstances.