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 22:32:51 +0100 Message-ID: References: <86lf0tq5zy.fsf@mail.linkov.net> <87ilvxinbn.fsf@logand.com> <86pmq5lf2o.fsf@mail.linkov.net> <86o84m2ky5.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0000000000002fe8f905d518d90c" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16288"; 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 22:34:07 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 1n6JLi-0003zh-3W for ged-emacs-devel@m.gmane-mx.org; Sat, 08 Jan 2022 22:34:06 +0100 Original-Received: from localhost ([::1]:39916 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n6JLf-0004KL-V2 for ged-emacs-devel@m.gmane-mx.org; Sat, 08 Jan 2022 16:34:03 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:60970) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6JKm-0003P4-W6 for emacs-devel@gnu.org; Sat, 08 Jan 2022 16:33:09 -0500 Original-Received: from [2607:f8b0:4864:20::931] (port=44864 helo=mail-ua1-x931.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n6JKk-0007Ql-Uf for emacs-devel@gnu.org; Sat, 08 Jan 2022 16:33:08 -0500 Original-Received: by mail-ua1-x931.google.com with SMTP id l15so5267080uai.11 for ; Sat, 08 Jan 2022 13:33:03 -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=hvFRmpkc0WuS7kFUgT3t/ANAm5Zmq/OhQcwI+8vepFQ=; b=H1JiwM5kcLClfepv8YptzGQiSZI+vnngHC6gMVRmm87BxHHhfPLkhWifHY7LkvDvVw Y2uBni85KInUx9jQ7GRjPzrfAYl0qbsszzKHJIf8PFPvpF9eMV54LyVsjV49sdDJWmHY cCzuX5dR1TTYVdc0kgCySjKGPOQDdTHBbSxJMfSfsL2DFNjQECrryAJkvCioJ4hbBT0j vPW90udfyGrfIEsFRiLfZDPlDMXRJ7Dhzh9V7tIjA6XVbc28Bl6lDjofSMNtF2JQ+62C O6jXKAjHYxLvx0ZkLE2r6jFfPUIiN6kUEZyUej5XdQWzrATKUOEaLesjlU8nBaDE85py SCXQ== 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=hvFRmpkc0WuS7kFUgT3t/ANAm5Zmq/OhQcwI+8vepFQ=; b=dlh6QWiOLX57OM2PJYDTCefUVc+8Hx8oDuqTDqV5AVnsSddDhN+HJgeWfyKHz0W+9F keIURtebnUlWZONPXOV5Vdq4QgL3x9yK+H+5iforg0bnFAi9L5AJkm5sjMRRwTj6V12v Fe3ON61gu5k7CmTCiYL0rZeV/f+Ok3qE+4inZicfhwtE0kHQKelOgV2a9i7BiAX2qVdB kRsS6lbXvktzsLeSOC6J5TSXXzUFkQ+jbYlYq9FMof7kULd2g9QRj4DSzznamDJQIMjL gPXZJrckXCLQaI3DYvaXCyjXnfpc1l/ZoFabLnpLe87Wa1D3T9QEc25RvstEa5/TC+Ia Q5pg== X-Gm-Message-State: AOAM5321T6rwx6WUA+TVqtGuZQnAShm1AFU/Fb7J2ItObtfNfLzOwq+N C26dZrGjM+Cpj6y2Xt9ErPPpOXu34/+5syLqlHzKVs9Y/X0= X-Google-Smtp-Source: ABdhPJzXtWy2xXCLdDS3S4p1+8DquRudlMKl8BvghIHqUvIrHZHr+0xJet2yrHY95YaNmsd1gpeAXS2Ft63oJ/3JLis= X-Received: by 2002:a67:ff81:: with SMTP id v1mr686338vsq.2.1641677583279; Sat, 08 Jan 2022 13:33:03 -0800 (PST) In-Reply-To: <86o84m2ky5.fsf@mail.linkov.net> X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::931 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::931; envelope-from=dalanicolai@gmail.com; helo=mail-ua1-x931.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:284491 Archived-At: --0000000000002fe8f905d518d90c Content-Type: text/plain; charset="UTF-8" Okay, so I have got a working Proof of Concept / core functionality. You can very easily test it by loading the bookroll.el file from here , then do `M-x br-test` and scroll using `j`/`k`. I will now focus on trying to implement it into pdf-tools, which is probably a little more work as its code is quite complex/opaque. @Juri ``` Maybe then after a real image will be scrolled out of view, it could be replaced with a placeholder again to free memory. > Then, the scrolling can be implemented, by changing the display properties (from empty > svg to real image, and back) ``` Haha, that is exactly what I meant with exactly that (the following) sentence. Anyway, thanks for the nice response! On Sat, 8 Jan 2022 at 19:33, Juri Linkov wrote: > > 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. > > It would be nice to include pdf-tools in Emacs, but I don't know > if the new maintainer has an intention to submit it for inclusion. > > > 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 > > I agree, a real continuous scroll mode would be more preferable. > > > - 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 > > While two-images approach could provide better optimization for memory, > it has severe limitations, e.g. the vertical scroll bar can't be used > to scroll all images at once. > > > but as I will describe now, I think it will be better to create a > > 'bookroll' package for it. > > This is a promising direction. > > > 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 > > Why not? 'image-roll' could be useful for the image gallery packages > like image-dired.el and thumbs.el. > > > 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). > > Good news, so loading a 1000-page document won't take much memory. > Only scrolling will load real images. Maybe then after a real image > will be scrolled out of view, it could be replaced with a placeholder again > to free 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. > > Thanks, feel free to post updates about your progress > or when stuck on some problems. > --0000000000002fe8f905d518d90c Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Okay, so I have got a working Proof of Concept / core= functionality.
You can very easily test it by loading the bookro= ll.el file from here= ,
then do `M-x br-test` and scroll using `j`/`k`. I will now = focus on trying to implement
it into pdf-tools, which is probably= a little more work as its code is quite complex/opaque.

@Juri
```
Maybe then after a real image
will be scrolled out of view, it could be replaced with a placeholder again=
to free memory.

> Then, the scrolling can be implemented, by changing the display proper= ties (from empty
> svg to real image, and back)
```

Haha, that is exactly what I meant with exactly that (th= e following) sentence.
Anyway= , thanks for the nice response!


On Sat, 8 Jan 2022 at 1= 9:33, Juri Linkov <juri@linkov.net> wrote:
>= ; 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 p= art of
> Emacs. It is a very high quality package, that already lazily loads th= e images,
> and provides many sophisticated features.

It would be nice to include pdf-tools in Emacs, but I don't know
if the new maintainer has an intention to submit it for inclusion.

> 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

I agree, a real continuous scroll mode would be more preferable.

> - I have created a, very rude but already nicely working, 'real= 9; continuous
>=C2=A0 =C2=A0scroll proof of concept, for which, if you are interested,= you can find the
>=C2=A0 =C2=A0code in this commit. It currently uses a trick where it on= ly uses two images
>=C2=A0 =C2=A0at the time

While two-images approach could provide better optimization for memory,
it has severe limitations, e.g. the vertical scroll bar can't be used to scroll all images at once.

>=C2=A0 =C2=A0but as I will describe now, I think it will be better to c= reate a
>=C2=A0 =C2=A0'bookroll' package for it.

This is a promising direction.

> 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 scr= olling is
> generally not what you want for viewing/scrolling images

Why not?=C2=A0 'image-roll' could be useful for the image gallery p= ackages
like image-dired.el and thumbs.el.

> So my current idea for how to implement it, is by
> immediately creating overlays for all pages in a single buffer and fil= l them
> with 'empty' svg-images of the correct size (after testing thi= s with a thousand
> 'placeholders', it seems that the 'empty' images use a= lmost no memory).

Good news, so loading a 1000-page document won't take much memory.
Only scrolling will load real images.=C2=A0 Maybe then after a real image will be scrolled out of view, it could be replaced with a placeholder again=
to free memory.

> Then, the scrolling can be implemented, by changing the display proper= ties (from empty
> svg to real image, and back) and jumping to the correct positions usin= g
> `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.

Thanks, feel free to post updates about your progress
or when stuck on some problems.
--0000000000002fe8f905d518d90c--