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 14:57:04 +0100 Message-ID: References: <838rgrtar9.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000046e64205f536285d" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24513"; 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 14:58:06 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 1pUT9i-0006FI-2I for ged-emacs-devel@m.gmane-mx.org; Tue, 21 Feb 2023 14:58:06 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pUT93-0005wZ-11; Tue, 21 Feb 2023 08:57:25 -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 1pUT91-0005wC-HU for emacs-devel@gnu.org; Tue, 21 Feb 2023 08:57:23 -0500 Original-Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pUT8x-0004MA-1G; Tue, 21 Feb 2023 08:57:22 -0500 Original-Received: by mail-wr1-x434.google.com with SMTP id bo30so3966479wrb.0; Tue, 21 Feb 2023 05:57:17 -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=VEo66sPpzMmu7Selmfr7pw4C60Lw3FM3Ff8MOtbFgyg=; b=h0FiQwI0bdoMt47/E+J9Rql60C9FrKz5YNAmFPbmF8nGsx642xCVWp078gWeK+g4HR KqR5FfmPQMFWNiC2VG2PEUGSV8VSlHBL3wq3u8CK1V6riB9undYM0CAwbgpf8cPQPfpW OTByL8NImNPafFxK15zTH8ngsZv3Va74gXTLTWN0IDOa+J7E/yIpg7tes4Cyaj/W3q/H C8h73WJflceWQBxVplR7rVsSOWSNom8szyY7lHh2mUtJAO/WCFIlElW1JcWkdbFYVy8i wcVak2xp5nX9ynOCUraWfFrTyfSoSGFncTxoKnRhhnO0m/MO+DiXW33qjjxUnEFNBMaf 4wOw== 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=VEo66sPpzMmu7Selmfr7pw4C60Lw3FM3Ff8MOtbFgyg=; b=lrZOYlfH6wBqttHtmmrgcSw4SLBOSv+Jim34iTqs2rMs9o0Oaiw6R8sPr516v308I3 i6JEWfsCeRunz/qSFZ9RDASsF8507a7fjXFpfopq1KC/9VG/c738n7VpCCL/karsGjHO ys664G03DDBp7oSocIjF+4dAzk7JOKrpZ7eide75BPfARAx9XMInEskHaniHjgoipAak SAtl5RPQ1KGVy86CHZC5zdpyk1Qvt7oOeTxBa+xZObvgMasgqlc/9Qt4C4DuAT1FfE4O VnngkHq/Mmr8n7ad4WzXzfgFNzJYurwEXAne+y0Gh9mnd+DAubPBWYpYQwzz53BcRhet lAlw== X-Gm-Message-State: AO0yUKV9iRRsqrTksK2mqRbUOWs4mgdE+DoRQwEQAC4wPzTZa8AcMiYJ tbyZ8K9/RUI4NkeFFzKlPdMzwbt2LhAG+iLd7PqqE4Lu6G0= X-Google-Smtp-Source: AK7set/EPSbkOjMld3w9KsrwVO6TP9t1ELJE4vt/4GB5idCPKwWMDF7YiiIJyUVtDm1Lvp5QWYcvFsAuNXqGOejp2Mg= X-Received: by 2002:adf:ec47:0:b0:2c3:e2bd:3de5 with SMTP id w7-20020adfec47000000b002c3e2bd3de5mr30721wrn.365.1676987836326; Tue, 21 Feb 2023 05:57:16 -0800 (PST) In-Reply-To: Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=dalanicolai@gmail.com; helo=mail-wr1-x434.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:303646 Archived-At: --00000000000046e64205f536285d Content-Type: text/plain; charset="UTF-8" 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. >>> >> --00000000000046e64205f536285d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
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 the= n?

On Tue, 21 Feb 2023 at 14:50, dalanicolai <dalanicolai@gmail.com> 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.=C2=A0 T= hen
in 'scrap-dir-images' are made to display the images from th= e
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 <dalanicolai@gmail.com> wrote:
I= n 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 over= lays, 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.=C2=A0 However, the images
are normal '= foto' size, so that I only see two images on screen, and
indeed doin= g 'M-: (overlays-in (window-start) (window-end))' manually
now p= rints 2.=C2=A0 If I had added the '(sit-for)' in the example
cod= e, 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).
<= br>
But this fu= nction 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.
--00000000000046e64205f536285d--