Subject: Re: bug#72241: 31.0.50; [PATCH] Use a dedicated buffer for `doc-view-open-text'

From: Tassilo Horn <[email-masked]>
Date: Tue, 23 Jul 2024 12:39:35 +0200

Manuel Giraud <[email-masked]> writes:

Hi,

>>> Can you tell in what way the behavior will change after this?  I'd
>>> like to think whether a NEWS entry is necessary and what to day there.
>>
>> Right now, when you open foo.pdf you see the images generated from
>> the PDF.  When you do C-c C-t, it'll replace the foo.pdf buffer
>> contents with the plain text contents of the PDF.  With another C-c
>> C-c, the contents are again replaced with the PDF and you see the
>> images again.
>
> FWIW, this is not the current behaviour that I see:
>
>       - C-c C-t replace the buffer contents with the text version
>       
>       - C-c C-c, DocView switches back to the "edit" view: the raw
>         content of a PDF for instance is displayed into the buffer.
>
>       - another C-c C-c, DocView switches to the "display" view where
>         you see the images again

That's right and my answer was aproximately correct.  The beef is that
for the "text version", you get a separate buffer with your patch.
"edit" and "display" are in the same buffer because the contents (raw
PDF, DVI, PostScript,...) are the same, just how they are presented to
the user differs.

> Maybe while here, we should clarify how DocView cycles through those 3
> view: display, edit and text.  Or maybe, there is no 3-states cycling
> and the "text contents" view is just considered a "side" view.  WDYT?

Here's a state machine describing the current behavior.

    display <-- C-c C-c --> edit
    \     ^
     \     \    
 C-c C-t  C-c C-c
       \     \
        `> text

So with C-c C-c you can toggle between "display" and "edit" which just
changes how the buffer contents are presented to the user (images or raw
text).

In the "display" state C-c C-t one gets a plain text version of the
contents, and that's in a separate foo.pdf/text buffer with Manuel's
patch.  In there, C-c C-c kills the foo.pdf/text buffer and returns to
the original foo.pdf buffer.

However, that now one can switch between foo.pdf and foo.pdf/text
independently, there is no guarantee that C-c C-c in the foo.pdf/text
buffer will return to foo.pdf in "display" state.  One could have
toggled to edit state there or even killed the foo.pdf buffer, so
there's nothing to return to.

So I'd say: right now it is a state machine with 3 states but with
Manuel's patch the current "text" state becomes an auxiliary view.

Bye,
  Tassilo