From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: dalanicolai Newsgroups: gmane.emacs.devel Subject: Re: Multi image PDF continuous mode Date: Sat, 8 Jan 2022 08:24:20 +0100 Message-ID: References: <86lf0tq5zy.fsf@mail.linkov.net> <87ilvxinbn.fsf@logand.com> <86pmq5lf2o.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000a7d68a05d50cfe32" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16060"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Tomas Hlavaty , Emacs Devel To: Juri Linkov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Jan 08 08:53:47 2022 Return-path: Envelope-to: ged-emacs-devel@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 1n66Xr-00043b-1x for ged-emacs-devel@m.gmane-mx.org; Sat, 08 Jan 2022 08:53:47 +0100 Original-Received: from localhost ([::1]:52692 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n66Xp-0006e6-UK for ged-emacs-devel@m.gmane-mx.org; Sat, 08 Jan 2022 02:53:45 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:33958) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n665b-0006H9-UO for emacs-devel@gnu.org; Sat, 08 Jan 2022 02:24:37 -0500 Original-Received: from [2607:f8b0:4864:20::932] (port=35638 helo=mail-ua1-x932.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n665Z-0001Lg-Ih for emacs-devel@gnu.org; Sat, 08 Jan 2022 02:24:35 -0500 Original-Received: by mail-ua1-x932.google.com with SMTP id o20so14279475uat.2 for ; Fri, 07 Jan 2022 23:24:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=HVwIkormTiOTrjetfOWLHOcdYn4xMZ9mU7OrByj8/B8=; b=WlmdM6J/bKlsmujk2VWz9kLBXo2rUrdGrvjW47ojcvdEc7gVbpVf+gxxCqZ1PtcCA7 GF4MbW5uADQaPGPuqxcdd4fPGn0nOzcWSMfuH2ydch+qqOeSQAy+jU2qSHulN4jv42xd ZKuwmOAKRw7Wr8BDs3zMQHGJCej9tkC2kS5N4W/Ssk+WaSDbqKoJBv0nGQ+mstZFjWyE C+RIG7eRAdqH+YM8/RJQP1UgbNPisVibWaLWyyDCk2uj1wlOYGNIUsb3VusDi1cCkQhv W5zhHhTf+jEGY+BUGBJRJjO4Em8EqtIhhpxmNZ93r/ZV7l/kd6M9uFWNvafqMcAmdKYJ 55dQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=HVwIkormTiOTrjetfOWLHOcdYn4xMZ9mU7OrByj8/B8=; b=o/WxWkfChWhX5ohvt1zklVNhL2N/VBX9wRTCGknjC5P37fheFkrV2lzyojgGQCgQUw +GjypLk+7kzPHaF/ghQvEOBArtf1sxymkODKxmipr+nI1+bS8xCrHdGPc0I8doFRrZSL qrgfsZfAQQ3IEUrSd6HRAV/Tm6sl6/4Gh4iXDamY+pkxEaG0vcGp2ZDAFqyh6vXt0/N/ d8qpJA6VcZoxISLmraD1Ndr+90X+XvqEkUbZAqW0TKSUW3E0ZRDQpHJ8lWfWVtg9zYMq OXpULYONYjiHHxVe//sEG5MAnLiUX/bS0A5IjSSk9eurCzqNm51k1uHmUXnvvDLFFTWL Ja/Q== X-Gm-Message-State: AOAM530AJzE59JvyeVCYonPywAKgAG0yi7QYJROrs1qgZjNwqRXbJW7j HYP4i3EfkNn0/JlaLmWLmN8lpM4vyrVAGKTNX1U= X-Google-Smtp-Source: ABdhPJwX7aitPwO2SOC4yYXCnlWDDPxQQfD7RwW9WXYZnw8MAWaPeASaz5QRvP7gSo6ojzBdmlzbB33yW+dO+3ovSpo= X-Received: by 2002:a67:e055:: with SMTP id n21mr21599400vsl.85.1641626672287; Fri, 07 Jan 2022 23:24:32 -0800 (PST) In-Reply-To: X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::932 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::932; envelope-from=dalanicolai@gmail.com; helo=mail-ua1-x932.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:284447 Archived-At: --000000000000a7d68a05d50cfe32 Content-Type: text/plain; charset="UTF-8" I forgot to attach the link to the (initial) bookroll code. https://github.com/dalanicolai/bookroll.el On Sat, 8 Jan 2022 at 08:18, dalanicolai wrote: > So the idea is that the bookroll can be used for doc-view (and possibly > djvu.el) also. > The code for the new server is also 'crude' code, but it works fine here > (I am no > professional programmer, so I appreciate any feedback about anything). > > On Sat, 8 Jan 2022 at 08:11, dalanicolai wrote: > >> After reading this thread, and especially after reading this message >> >> by Eli (if >> the links don't work, I have attached them also at the end), I have again >> looked >> into this. I would like to share my perspective on this, but before I do >> that, >> let me first ask you if you have any idea about why pdf-tools is not part >> of >> Emacs. It is a very high quality package, that already lazily loads the >> images, >> and provides many sophisticated features. >> >> >> You might already be familiar with my 2-buffer continuous scroll hack >> for it >> (which can be easily ported to doc-view mode, but 'developing' a 'real' >> continuous scroll mode solution makes much more sense, and, if possible, >> to me >> it would make even more sense to try to get pdf-tools into Emacs). >> >> Some related interesting announcements are that: >> >> - I have written an alternative server for pdf-tools, which uses the >> pymupdf >> library. You can read more about it in the PR >> . A nice thing about its >> design >> is that it uses the python interpreter/REPL directly as a server (it >> reads >> messages and prints to standard output). It already extends/complements >> the >> features of the original epdfinfo server by supporting line/arrow >> annotations >> and supporting the EPUB format very nicely. Additionally, it enables >> other non >> C programmers to extend its features (e.g. support for freetext >> annotations >> should be only little work). >> >> - I have created a, very rude but already nicely working, 'real' >> continuous >> scroll proof of concept, for which, if you are interested, you can find >> the >> code in this commit >> . >> It currently uses a trick where it only uses two images >> at the time, but as I will describe now, I think it will be better to >> create a >> 'bookroll' package for it. >> >> >> The 'continuous' rendering is only part of implementing continuous scroll >> into >> pdf-tools because it would also be nice if it could be made compatible >> with all >> pdf-tools its features. After investigating how to achieve that, I have >> come to >> the conclusion that we need a 'bookroll' alternative to 'image-mode', >> because >> the main obstacle is that pdf-tools now uses image-mode functions, that >> are >> written only for a single overlay per buffer. >> >> I think the bookroll should not be so difficult to implement (I first >> started to >> think about a general 'image-roll', but I think continuous scrolling is >> generally not what you want for viewing/scrolling images, so it can be >> just a >> dedicated bookroll). So my current idea for how to implement it, is by >> immediately creating overlays for all pages in a single buffer and fill >> them >> with 'empty' svg-images of the correct size (after testing this with a >> thousand >> 'placeholders', it seems that the 'empty' images use almost no memory). >> Then, >> the scrolling can be implemented, by changing the display properties >> (from empty >> svg to real image, and back) and jumping to the correct positions using >> `set-window-vscroll`. I have started on writing bookroll.el, of course >> your >> joined efforts or feedback would be very much appreciated. Otherwise, >> this short >> message serves just to inform you about these activities. >> >> Finally, it would be great if you could share your 'knowledge' about why >> pdf-tools is not in Emacs. Its main developer has stepped down from the >> project, >> and 'vedang' has taken the roll of new maintainer. Anyway, I guess we >> could best >> ask the former and current maintainers as soon as possible about thier >> 'opinions' and for signing the necessary papers. >> >> https://lists.gnu.org/archive/html/emacs-devel/2018-04/msg00087.html >> https://github.com/dalanicolai/pdf-continuous-scroll-mode.el >> https://pymupdf.readthedocs.io/en/latest/ >> https://github.com/vedang/pdf-tools/pull/61 >> >> https://github.com/dalanicolai/pdf-tools/commit/b76a6337c39f114aa668e9f1985bfdfd87bd857d >> >> >> >> On Thu, 9 Dec 2021 at 21:06, Juri Linkov wrote: >> >>> >> After doc-view generates a gallery of PDF images, image-dired could be >>> >> invoked on the output directory of PNG images, and indeed in this case >>> >> the window layout of image-dired looks like what most PDF viewers do: >>> >> on the left side there is a narrow window with thumbnails of PDF >>> >> pages, and on the right side a larger window with PDF pages. >>> > >>> > Scaleable document viewer should generate the images lazily. >>> >>> Indeed, for long documents we will need more optimization: >>> not to load all images at once, but only after going to the next page. >>> At the beginning each page could have a placeholder, either just >>> newlines or an empty image. Then navigating to a page, >>> it will attach the image file with the display property. >>> Also only visited pages should update their images when >>> the user zooms or changes other parameters, etc. >>> >>> --000000000000a7d68a05d50cfe32 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I forgot to attach the link to the (initial) bookroll code.


On Sat, 8 Jan 2022 at 08:1= 8, dalanicolai <dalanicolai@gma= il.com> wrote:
So the idea is that the bookroll can be used fo= r doc-view (and possibly djvu.el) also.
The code for the new serv= er is also 'crude' code, but it works fine here (I am no
= professional programmer, so I appreciate any feedback about anything).
<= /div>

On Sat, 8 Jan 2022 at 08:11, dalanicolai <dalanicolai@gmail.com> wrote:
<= /div>
Aft= er reading this thread, and especially after reading this message by Eli (if
the links don't work, I have attached = them also at the end), I have again looked
into this. I would like to sh= are my perspective on this, but before I do that,
let me first ask you i= f you have any idea about why pdf-tools is not part of
Emacs. It is a ve= ry high quality package, that already lazily loads the images,
and provi= des many sophisticated features.


You might already be familiar w= ith my 2-buffer continuous scroll hack for it
(which= can be easily ported to doc-view mode, but 'developing' a 'rea= l'
continuous scroll mode solution makes much more sense, and, = if possible, to me
it would make even more sense to try to g= et pdf-tools into Emacs).

Some related interesting announcemen= ts are that:

- I have written an alternative server for pdf-tools, w= hich uses the pymupdf
=C2=A0 library. You can read more about it in th= e PR. A nice thing about its design
=C2=A0 is that it uses the python= interpreter/REPL directly as a server (it reads
=C2=A0 messages and pri= nts to standard output). It already extends/complements the
=C2=A0 featu= res of the original epdfinfo server by supporting line/arrow annotations=C2=A0 and supporting the EPUB format very nicely. Additionally, it enable= s other non
=C2=A0 C programmers to extend its features (e.g. support fo= r freetext annotations
=C2=A0 should be only little work).

- I ha= ve created a, very rude but already nicely working, 'real' continuo= us
=C2=A0 scroll proof of concept, for which, if you are interested, you= can find the
=C2=A0 code in this commit. It currently uses a trick where it only uses two images=C2=A0 at the time, but as I will describe now, I think it will be better= to create a
=C2=A0 'bookroll' package for it.


The &#= 39;continuous' rendering is only part of implementing continuous scroll= into
pdf-tools because it would also be nice if it could be made compat= ible with all
pdf-tools its features. After investigating how to achieve= that, I have come to
the conclusion that we need a 'bookroll' a= lternative to 'image-mode', because
the main obstacle is that pd= f-tools now uses image-mode functions, that are
written only for a singl= e overlay per buffer.

I think the bookroll should not be so difficul= t to implement (I first started to
think about a general 'image-roll= ', but I think continuous scrolling is
generally not what you want f= or viewing/scrolling images, so it can be just a
dedicated bookroll). So= my current idea for how to implement it, is by
immediately creating ove= rlays for all pages in a single buffer and fill them
with 'empty'= ; svg-images of the correct size (after testing this with a thousand
= 9;placeholders', it seems that the 'empty' images use almost no= memory). Then,
the scrolling can be implemented, by changing the displa= y properties (from empty
svg to real image, and back) and jumping to the= correct positions using
`set-window-vscroll`. I have started on writing= bookroll.el, of course your
joined efforts or feedback would be very mu= ch appreciated. Otherwise, this short
message serves just to inform you = about these activities.

Finally, it would be great if you could shar= e your 'knowledge' about why
pdf-tools is not in Emacs. Its main= developer has stepped down from the project,
and 'vedang' has t= aken the roll of new maintainer. Anyway, I guess we could best
ask the f= ormer and current maintainers as soon as possible about thier
'= opinions' and for signing the necessary papers.

https://lists.gnu.org/archive/html/emacs-devel/20= 18-04/msg00087.html
https://github.com/dalanicolai/p= df-continuous-scroll-mode.el
https://pymupdf.readthedocs.io/en/latest/<= /a>
https://github.com/vedang/pdf-tools/pull/61
https://github.com/dalanicolai/pdf-tools/commit/b= 76a6337c39f114aa668e9f1985bfdfd87bd857d



On Thu, 9 Dec = 2021 at 21:06, Juri Linkov <juri@linkov.net> wrote:
>> After doc-view generates a gallery of PDF = images, image-dired could be
>> invoked on the output directory of PNG images, and indeed in this = case
>> the window layout of image-dired looks like what most PDF viewers = do:
>> on the left side there is a narrow window with thumbnails of PDF >> pages, and on the right side a larger window with PDF pages.
>
> Scaleable document viewer should generate the images lazily.

Indeed, for long documents we will need more optimization:
not to load all images at once, but only after going to the next page.
At the beginning each page could have a placeholder, either just
newlines or an empty image.=C2=A0 Then navigating to a page,
it will attach the image file with the display property.
Also only visited pages should update their images when
the user zooms or changes other parameters, etc.

--000000000000a7d68a05d50cfe32--