From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tassilo Horn Newsgroups: gmane.emacs.help Subject: Re: DocView: process ps->pdf changed status to killed. Date: Wed, 22 Oct 2014 15:36:53 +0200 Message-ID: <87siigkyyy.fsf@thinkpad-t440p.tsdh.org> References: <87bnpsi5wc.fsf@thinkpad-t440p.tsdh.org> <20141007.102533.2212875331518577085.devel@pollock-nageoire.net> <87oatouu2y.fsf@thinkpad-t440p.tsdh.org> <20141018.073246.1226955945483316970.devel@pollock-nageoire.net> <87mw8smpse.fsf@thinkpad-t440p.tsdh.org> <87fvehztfs.fsf@thinkpad-t440p.tsdh.org> <8738ahtetm.fsf@thinkpad-t440p.tsdh.org> <8761fcmyof.fsf@thinkpad-t440p.tsdh.org> <87y4s8lglc.fsf@thinkpad-t440p.tsdh.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1413985059 11808 80.91.229.3 (22 Oct 2014 13:37:39 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 22 Oct 2014 13:37:39 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Stefan Monnier Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Oct 22 15:37:33 2014 Return-path: Envelope-to: geh-help-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 1Xgw6W-00023p-Af for geh-help-gnu-emacs@m.gmane.org; Wed, 22 Oct 2014 15:37:32 +0200 Original-Received: from localhost ([::1]:57491 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xgw6V-000395-Sz for geh-help-gnu-emacs@m.gmane.org; Wed, 22 Oct 2014 09:37:31 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39139) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xgw61-0002w7-Nz for help-gnu-emacs@gnu.org; Wed, 22 Oct 2014 09:37:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xgw5v-0003hn-Rk for help-gnu-emacs@gnu.org; Wed, 22 Oct 2014 09:37:01 -0400 Original-Received: from deliver.uni-koblenz.de ([141.26.64.15]:56426) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xgw5v-0003hb-Hv for help-gnu-emacs@gnu.org; Wed, 22 Oct 2014 09:36:55 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by deliver.uni-koblenz.de (Postfix) with ESMTP id CD68D1A8469; Wed, 22 Oct 2014 15:36:54 +0200 (CEST) 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 aTsB9mlJvTUr; Wed, 22 Oct 2014 15:36:54 +0200 (CEST) X-CHKRCPT: Envelopesender noch tsdh@gnu.org Original-Received: from thinkpad-t440p.tsdh.org (dhcp211.uni-koblenz.de [141.26.71.211]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by deliver.uni-koblenz.de (Postfix) with ESMTPSA id 578271A846B; Wed, 22 Oct 2014 15:36:54 +0200 (CEST) In-Reply-To: (Stefan Monnier's message of "Wed, 22 Oct 2014 08:34:19 -0400") User-Agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/25.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 141.26.64.15 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:100547 Archived-At: Stefan Monnier writes: >> Ok, here's a patch which does that. `C-c C-t' or saying yes to the >> initial "Cannot render; wanna view the text instead?" query replaces >> the buffer contents with the text contents of the document and >> switches to text-mode + doc-view-minor-mode. The buffer is still >> read-only so that you can't modify it because it keeps the file >> association to the original file. > > I suggest to set a write-buffer hook to try and make extra sure we > don't end up overwriting the file. Ok, done. >> With `C-c C-c' you can toggle back to viewing the page images, with >> another `C-c C-c' you're back at the original document in its editing >> mode (fundamental-mode, ps-mode, or archive-mode for ODF files). > > For the case at hand, we can't view images, so the first C-c C-c should > switch right back to ps-mode. I wasn't sure if the "can't view images" or the "can view images but still wanna look at the plain text contents" is the more common case. But I guess you're right so I've changed it. >> + (let ((inhibit-read-only t)) >> + (set-buffer-multibyte t) > > I strongly recommend not do use set-buffer-multibyte on a non-empty > buffer (this is a general rule, but is especially true in our case since > we may have a mostly-binary file, in which case (set-buffer-multibyte t) > can have a lot of work to do (and suffered from an O(N^2) behavior not > that long ago, not sure if we fixed it)). > And since we throw away the buffer's content right after anyway, we may > as well `erase-buffer' ourselves first (and do it without preserving the > undo info). Ok, done. >> + ((eq major-mode 'text-mode) >> + ;; We're currently viewing the document's text contents, so switch >> + ;; back to doc-view-mode. >> + (setq buffer-read-only nil) >> + (insert-file-contents buffer-file-name nil nil nil t) > > buffer-file-name can be nil. So either we need to "stash" away the > contents of the buffer before we erased it (e.g. we could stash it > into an auxiliary buffer with buffer-swap-text), or simpler: use > doc-view--buffer-file-name. Oh, yes. So now I re-establish that after switching to text-mode so that it can be used here. > Other than that, I think it looks good. Great, I've committed it to the trunk (r118178). Bye, Tassilo