all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: help-gnu-emacs@gnu.org
Subject: Re: DocView: process ps->pdf changed status to killed.
Date: Wed, 22 Oct 2014 08:34:19 -0400	[thread overview]
Message-ID: <jwvbnp41eke.fsf-monnier+gmane.emacs.help@gnu.org> (raw)
In-Reply-To: 87y4s8lglc.fsf@thinkpad-t440p.tsdh.org

>>> - we change the .txt system so that it displays the text in the
>>> original buffer rather than in an auxiliary buffer (and hence we don't
>>> switch back to ps-mode).
>> That's an alternative I've also thought about.  I'll see if that's
>> feasible...
> 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.

> 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.

> +	  (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).

> +   ((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.

Other than that, I think it looks good.


        Stefan




  reply	other threads:[~2014-10-22 12:34 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-01 17:06 DocView: process ps->pdf changed status to killed Pierre Lorenzon
2014-10-02 10:25 ` Tassilo Horn
2014-10-02 12:36   ` Stefan Monnier
2014-10-03 15:17     ` Pierre Lorenzon
2014-10-04  8:46       ` Tassilo Horn
2014-10-03 14:48   ` Pierre Lorenzon
2014-10-03 15:09   ` Pierre Lorenzon
2014-10-03 18:34     ` Tassilo Horn
2014-10-04  3:35       ` Pierre Lorenzon
2014-10-04  3:46       ` Pierre Lorenzon
2014-10-04  3:54         ` Pierre Lorenzon
2014-10-04  8:41           ` Tassilo Horn
2014-10-07  8:25             ` Pierre Lorenzon
2014-10-07  9:07               ` Tassilo Horn
2014-10-18  5:32                 ` Pierre Lorenzon
2014-10-19  8:23                   ` Tassilo Horn
2014-10-19 19:55                     ` Stefan Monnier
2014-10-21  9:02                     ` Tassilo Horn
2014-10-21 14:28                       ` Stefan Monnier
2014-10-21 14:54                         ` Tassilo Horn
     [not found]                         ` <mailman.11640.1413903303.1147.help-gnu-emacs@gnu.org>
2014-10-21 15:36                           ` Stefan Monnier
2014-10-21 19:15                             ` Tassilo Horn
2014-10-21 20:19                               ` Stefan Monnier
2014-10-22  6:00                                 ` Tassilo Horn
2014-10-22  7:16                                   ` Tassilo Horn
2014-10-22 12:34                                     ` Stefan Monnier [this message]
2014-10-22 13:36                                       ` Tassilo Horn
2014-10-23  5:11                                       ` Pierre Lorenzon
2014-10-23  6:14                                         ` Tassilo Horn
2014-10-23 12:01                                           ` Stefan Monnier
2014-10-23 19:18                                             ` Tassilo Horn
2014-10-24  6:04                                           ` Pierre Lorenzon
2014-10-24  6:36                                             ` Tassilo Horn
2014-10-24  9:10                                               ` Pierre Lorenzon
2014-10-24  9:24                                                 ` Pierre Lorenzon
2014-10-24 10:26                                                   ` Tassilo Horn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvbnp41eke.fsf-monnier+gmane.emacs.help@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.