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: Two questions about overlays Date: Tue, 21 Feb 2023 15:16:29 +0100 Message-ID: References: <838rgrtar9.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000b094e405f5366deb" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7872"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Feb 21 15:17:53 2023 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 1pUTSq-0001tP-LI for ged-emacs-devel@m.gmane-mx.org; Tue, 21 Feb 2023 15:17:52 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pUTRn-0006go-LI; Tue, 21 Feb 2023 09:16:47 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pUTRm-0006g5-2N for emacs-devel@gnu.org; Tue, 21 Feb 2023 09:16:46 -0500 Original-Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pUTRj-0007vd-BH; Tue, 21 Feb 2023 09:16:45 -0500 Original-Received: by mail-wm1-x32f.google.com with SMTP id p18-20020a05600c359200b003dc57ea0dfeso3690729wmq.0; Tue, 21 Feb 2023 06:16:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=WWyZcAJfKD9HoEEApPASipEJ3t1VJNAUXd4ZY9BpoHY=; b=cj66mxJ8OIDAsKQv4Fl47K3tFKbemZyJxCY+TSZi8YMrkdp7osNaUiIuBi+R/H7qPM Bw8X4nApp0247abJJaPU9hNMIuWpz+Rwc6Tm87PWP4FftddeSLdpFxehYHTO8dML/YDR SZ3KmhhEptdXcfA8WvFeem7nU99Z/devV1GULiX7nQhWEv0Pzf2Vbq9k4rssRg9hMdcT cGe3+PTwrhMRaXOOn7m4QEC5M52aXmG505p0ETsnSaUiIT2bJrOtztxBpqqcoh0BECUT /RxWpmo4Li1Y1GvrgLZMlYMmwIVFSE5MgXteYW6Y1hfUQA9tYw3QAea4eu1OiuqypBpH 3spw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=WWyZcAJfKD9HoEEApPASipEJ3t1VJNAUXd4ZY9BpoHY=; b=V2gp2r9pmqVyRIK9VWXZubbwAqOJO0MyTBCy88B6AzKIuo1+p+aPsnWrCQ7h8Lmhpl McRvrQlBHMHoCDy7YoQlgDJfTwFB8+ot9W6bxZKnIYveTpPHXspJErai0Lzs9K3xqAkH 6BVEG99JiEk9pKZC4q/79WgPRd65Gkj05ETF7rRN+xyXNy7RKRaMznjiytPv7L9CgbGY qatDtUPC2LIELsbNzZWnnUG0SI3QARHVArj3uKRDQjhHBngB4ahI+YuDkW3Bm8+O3UuF dT+zCpKezb9ByEsdy1BGpylAWDdiPOAB8rG5rdW5Q8zJHNhxHlITG+UzmM/gRD7tW6v9 Qi6w== X-Gm-Message-State: AO0yUKVeRsXNC/86sgHJgfv1D0DXDDRczb5f14i6E6cm8hpAddYRYd15 ts2h1nkh+9vQggF3ygRP7mFzEOkUiwIJvSlAP825yjw7fQTxMA== X-Google-Smtp-Source: AK7set/9eWt2nSlocCCyjx2lbQwD4Js2psOjnBpQ4RwDZld2WJfDFkrxAHMjEgRtDSeJ7V4HVJcl05hGtS+NXdXSyfg= X-Received: by 2002:a05:600c:46c6:b0:3e2:1244:d399 with SMTP id q6-20020a05600c46c600b003e21244d399mr873624wmo.64.1676989000880; Tue, 21 Feb 2023 06:16:40 -0800 (PST) In-Reply-To: Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=dalanicolai@gmail.com; helo=mail-wm1-x32f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:303647 Archived-At: --000000000000b094e405f5366deb Content-Type: text/plain; charset="UTF-8" > > In this example code, I am simply displaying all images at once, > because I am assuming that the images in the directory are not too > many and that they are small (which is not a very reasonable > assumption, but this is just my personal 'test' function). This is exactly why I want to display the images dynamically. Because for a large directory with large images, displaying all images at once would quickly use up all memory. So, what I am doing for example in doc-scroll (the 'engine' for doc-tools , in that file you can find the 'sit-for'), is to first assign all overlays the size of the images by using the 'space' display property (which uses only very minimal memory). Then, using, `(overlays-in (window-start) (window-end))`, I can determine which images should be displayed. When scrolling, I am again using this function to determine which images to update (which to display and which to undisplay). In this way, I can list a huge amount of large images without running out of memory. On Tue, 21 Feb 2023 at 14:57, dalanicolai wrote: > B.t.w. I am using Emacs 29 (and 30), and the overlay-recenter is still > there. > Maybe it would be handy to remove it then? > > On Tue, 21 Feb 2023 at 14:50, dalanicolai wrote: > >> Let me, additionally, very briefly explain what the code is doing, and >> what I am expecting (as an attempt to make it immediately clear what I >> mean). >> >> So the code is first simply creating (for my dir) 108 overlays. Then >> in 'scrap-dir-images' are made to display the images from the >> directory. Immediately, after the >> '(seq-do-indexed (lambda (im n) (overlay-put ... 'display ...)' >> the function print the value of '(overlays-in (window-start) >> (window-end))', >> which return 108. However, I expect it to print 2, as the overlays should >> have the size of the images now (and I see only two images simultaneously >> on >> screen). Indeed when doing 'M-: (overlays-in (window-start) (window-end))' >> immediately after creating the 'image gallery', it returns 2. >> >> On Tue, 21 Feb 2023 at 14:39, dalanicolai wrote: >> >>> In this example code, I am simply displaying all images at once, >>> because I am assuming that the images in the directory are not too >>> many and that they are small (which is not a very reasonable >>> assumption, but this is just my personal 'test' function). >>> >>> Indeed, the example does not call sit-for, because it should show that >>> the printed number of overlays, is the number of all images in the >>> directory (instead of only the number of images currently on the >>> screen, i.e. within '(overlays-in (window-start) (window-end))' ). >>> >>> For example, I have a directory with 108 images, when I run 'M-x >>> scrap-dir-images' it print 108, although it should print the number of >>> images on screen i.e. by '(overlays-in (window-start) (window-end))', >>> which value is what 'scrap-dir-images' prints. However, the images >>> are normal 'foto' size, so that I only see two images on screen, and >>> indeed doing 'M-: (overlays-in (window-start) (window-end))' manually >>> now prints 2. If I had added the '(sit-for)' in the example >>> code, then I would have 'fixed' the problem, and 'scrap-dir-images' >>> would have printed 2 immediately because the display property >>> ('expansion of the overlays') got enough time to take effect. >>> >>> I hope this clears things up, but of course I would be happy to try >>> another explanation (e.g. sending by adding an animated gif). >>> >>> But this function is a no-op in Emacs 29 and later, since the overlays >>>> were reimplemented in a way that makes it unnecessary to "center" the >>>> list of overlays. So you can forget about that and ignore this >>>> function. >>>> >>> >>> Thanks, that is indeed handy to know. >>> >>> On Tue, 21 Feb 2023 at 14:21, Eli Zaretskii wrote: >>> >>>> > From: dalanicolai >>>> > Date: Tue, 21 Feb 2023 13:46:56 +0100 >>>> > >>>> > So now here are the questions: >>>> > >>>> > - when displaying multiple pages in columns, I would like to use the >>>> > overlays-in function to determine which overlays should display >>>> > images. So I am creating a full 'book roll' by giving the overlays a >>>> > size via the 'space' display property, after which I use overlays-in >>>> > to determine which overlays are actually visible. However, after it >>>> > takes some time for the 'space' display property to take effect, so I >>>> > am manuall adding a 'sit-for' with some reasonable delay >>>> > time. However, I would like to ask if there is someone has an idea for >>>> > a 'better' mechanism to wait until/detect if the 'overlay expansion' >>>> > has finished. >>>> > >>>> > If the explanation is not clear then please load the following file >>>> > and do 'M-x scrap-dir-images' on a directory that contains enough >>>> > images to not fit all on a single screen. It will print the number of >>>> > overlays found via 'overlays-in' directly after 'displaying the >>>> > images' (here by assigning the image as display property instead of >>>> > space). You will find it prints all overlays in the buffer (instead of >>>> > only the ones on screen). To find what I expect it to print now >>>> > (again) do 'M-: (overlays-in (window-start) (window-end))'. >>>> >>>> I did all that, and I still don't understand the question. In >>>> particular, your code doesn't call sit-for, so I'm unsure what exactly >>>> is the problem you are asking about here. >>>> >>>> > My second question is about the function 'overlay-recenter' I don't >>>> > really understand its docstring. What kind of 'overlay lookup' would >>>> > go faster? What is 'overlay-lookup' anyway? >>>> >>>> Looking up overlays that are relevant to a particular buffer position. >>>> >>>> But this function is a no-op in Emacs 29 and later, since the overlays >>>> were reimplemented in a way that makes it unnecessary to "center" the >>>> list of overlays. So you can forget about that and ignore this >>>> function. >>>> >>> --000000000000b094e405f5366deb Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
In this example code, I am simply displaying all images at once,=
because I am assuming that the images in the directory are not too
m= any and that they are small (which is not a very reasonable
assumption, = but this is just my personal 'test' function).
This is exactly why I want to display the images dynamically. B= ecause
for a large directory with large images, displaying all images at= once
would quickly use up all memory. So, what I am doing for example i= n
doc-scroll (the 'engine' for doc-tools, in that file you can find the
= 'sit-for'), is to first assign all overlays the size of the images = by
using the 'space' display property (which uses only very mini= mal
memory). Then, using, `(overlays-in (window-start) (window-end))`, I=
can determine which images should be displayed. When scrolling, I amagain using this function to determine which images to update (which
to= display and which to undisplay). In this way, I can list a huge
amount = of large images without running out of memory.



<= /div>
On Tu= e, 21 Feb 2023 at 14:57, dalanicolai <dalanicolai@gmail.com> wrote:
B.t.w. = I am using Emacs 29 (and 30), and the overlay-recenter is still there.
Maybe it would be handy to remove it then?

On Tue, 21 Feb 20= 23 at 14:50, dalanicolai <dalanicolai@gmail.com> wrote:
Let me, additionall= y, very briefly explain what the code is doing, and
what I am expecting = (as an attempt to make it immediately clear what I
mean).

So the = code is first simply creating (for my dir) 108 overlays.=C2=A0 Then
in &= #39;scrap-dir-images' are made to display the images from the
direct= ory. Immediately, after the
'(seq-do-indexed (lambda (im n) (overlay= -put ... 'display ...)'
the function print the value of '(ov= erlays-in (window-start) (window-end))',
which return 108. However, = I expect it to print 2, as the overlays should
have the size of the imag= es now (and I see only two images simultaneously on
screen). Indeed when= doing 'M-: (overlays-in (window-start) (window-end))'
immediate= ly after creating the 'image gallery', it returns 2.

On Tu= e, 21 Feb 2023 at 14:39, dalanicolai <dalanicolai@gmail.com> wrote:
In this exam= ple code, I am simply displaying all images at once,
because I am assumi= ng that the images in the directory are not too
many and that they are s= mall (which is not a very reasonable
assumption, but this is just my per= sonal 'test' function).

Indeed, the example does not call si= t-for, because it should show that
the printed number of overlays, is th= e number of all images in the
directory (instead of only the number of i= mages currently on the
screen, i.e. within '(overlays-in (window-sta= rt) (window-end))' ).

For example, I have a directory with 108 i= mages, when I run 'M-x
scrap-dir-images' it print 108, although = it should print the number of
images on screen i.e. by '(overlays-in= (window-start) (window-end))',
which value is what 'scrap-dir-i= mages' prints.=C2=A0 However, the images
are normal 'foto' s= ize, so that I only see two images on screen, and
indeed doing 'M-: = (overlays-in (window-start) (window-end))' manually
now prints 2.=C2= =A0 If I had added the '(sit-for)' in the example
code, then I w= ould have 'fixed' the problem, and 'scrap-dir-images'
wo= uld have printed 2 immediately because the display property
('expans= ion of the overlays') got enough time to take effect.

I hope thi= s clears things up, but of course I would be happy to try
another e= xplanation (e.g. sending by adding an animated gif).

But this function is a= no-op in Emacs 29 and later, since the overlays
were reimplemented in a way that makes it unnecessary to "center"= the
list of overlays.=C2=A0 So you can forget about that and ignore this
function.

Thanks, that is indeed hand= y to know.

On Tue, 21 Feb 2023 at 14:21, Eli Zaretskii <eliz@gnu.org> wrote:
<= /div>
> From: dalanicol= ai <dalanicol= ai@gmail.com>
> Date: Tue, 21 Feb 2023 13:46:56 +0100
>
> So now here are the questions:
>
> - when displaying multiple pages in columns, I would like to use the > overlays-in function to determine which overlays should display
> images.=C2=A0 So I am creating a full 'book roll' by giving th= e overlays a
> size via the 'space' display property, after which I use overl= ays-in
> to determine which overlays are actually visible. However, after it > takes some time for the 'space' display property to take effec= t, so I
> am manuall adding a 'sit-for' with some reasonable delay
> time. However, I would like to ask if there is someone has an idea for=
> a 'better' mechanism to wait until/detect if the 'overlay = expansion'
> has finished.
>
> If the explanation is not clear then please load the following file > and do 'M-x scrap-dir-images' on a directory that contains eno= ugh
> images to not fit all on a single screen. It will print the number of<= br> > overlays found via 'overlays-in' directly after 'displayin= g the
> images' (here by assigning the image as display property instead o= f
> space). You will find it prints all overlays in the buffer (instead of=
> only the ones on screen). To find what I expect it to print now
> (again) do 'M-: (overlays-in (window-start) (window-end))'.
I did all that, and I still don't understand the question.=C2=A0 In
particular, your code doesn't call sit-for, so I'm unsure what exac= tly
is the problem you are asking about here.

> My second question is about the function 'overlay-recenter' I = don't
> really understand its docstring. What kind of 'overlay lookup'= would
> go faster? What is 'overlay-lookup' anyway?

Looking up overlays that are relevant to a particular buffer position.

But this function is a no-op in Emacs 29 and later, since the overlays
were reimplemented in a way that makes it unnecessary to "center"= the
list of overlays.=C2=A0 So you can forget about that and ignore this
function.
--000000000000b094e405f5366deb--