[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: DocView: process ps->pdf changed status to killed.
From: |
Tassilo Horn |
Subject: |
Re: DocView: process ps->pdf changed status to killed. |
Date: |
Wed, 22 Oct 2014 15:36:53 +0200 |
User-agent: |
Gnus/5.130012 (Ma Gnus v0.12) Emacs/25.0.50 (gnu/linux) |
Stefan Monnier <monnier@iro.umontreal.ca> 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
- Re: DocView: process ps->pdf changed status to killed., (continued)
- Re: DocView: process ps->pdf changed status to killed., Stefan Monnier, 2014/10/19
- Re: DocView: process ps->pdf changed status to killed., Tassilo Horn, 2014/10/21
- Re: DocView: process ps->pdf changed status to killed., Stefan Monnier, 2014/10/21
- Re: DocView: process ps->pdf changed status to killed., Tassilo Horn, 2014/10/21
- Message not available
- Re: DocView: process ps->pdf changed status to killed., Stefan Monnier, 2014/10/21
- Re: DocView: process ps->pdf changed status to killed., Tassilo Horn, 2014/10/21
- Re: DocView: process ps->pdf changed status to killed., Stefan Monnier, 2014/10/21
- Re: DocView: process ps->pdf changed status to killed., Tassilo Horn, 2014/10/22
- Re: DocView: process ps->pdf changed status to killed., Tassilo Horn, 2014/10/22
- Re: DocView: process ps->pdf changed status to killed., Stefan Monnier, 2014/10/22
- Re: DocView: process ps->pdf changed status to killed.,
Tassilo Horn <=
- Re: DocView: process ps->pdf changed status to killed., Pierre Lorenzon, 2014/10/23
- Re: DocView: process ps->pdf changed status to killed., Tassilo Horn, 2014/10/23
- Re: DocView: process ps->pdf changed status to killed., Stefan Monnier, 2014/10/23
- Re: DocView: process ps->pdf changed status to killed., Tassilo Horn, 2014/10/23
- Re: DocView: process ps->pdf changed status to killed., Pierre Lorenzon, 2014/10/24
- Re: DocView: process ps->pdf changed status to killed., Tassilo Horn, 2014/10/24
- Re: DocView: process ps->pdf changed status to killed., Pierre Lorenzon, 2014/10/24
- Re: DocView: process ps->pdf changed status to killed., Pierre Lorenzon, 2014/10/24
- Re: DocView: process ps->pdf changed status to killed., Tassilo Horn, 2014/10/24