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:50:00 +0100 Message-ID: References: <838rgrtar9.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000fafff105f5360e99" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27498"; 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:51:05 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 1pUT2v-0006zq-DS for ged-emacs-devel@m.gmane-mx.org; Tue, 21 Feb 2023 14:51:05 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pUT2B-00027s-7R; Tue, 21 Feb 2023 08:50:19 -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 1pUT28-00027T-Np for emacs-devel@gnu.org; Tue, 21 Feb 2023 08:50:16 -0500 Original-Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pUT26-0002zH-FO; Tue, 21 Feb 2023 08:50:16 -0500 Original-Received: by mail-wm1-x335.google.com with SMTP id p18-20020a05600c359200b003dc57ea0dfeso3617527wmq.0; Tue, 21 Feb 2023 05:50:13 -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=MkdsImVsyEuQLvnhCeJy7SaaCnVmGS9q5CpDB1XQs7U=; b=YSEAm6TRghUSmXRH4U2ineztE85jOvpmcBEUG866rslY94D1GXjybAyhSREoVbznPH E6JAzifeXElbWOsU9YEP4fSg8C6IaaQsW9qDdwZFS5bfBcwqVwZgXEJWSKa/b/VRLQHa 2Bh4KpRm7qAyGYrop1mwcL/gQTkRLysJ45vEpzMKeesenO8IArNOjQWtkzBUSvdeYj2m VSKFRSdTW2/YJJ4GkcFiiQbl5pIHqZw4S9m+gZEiVnk2pjuz+s8kaEG4ZQsTJFzEOQ6Y KV5Yszx9cs8kaV71kP0/V3/bT3GDGVucDGh3VM65PP8KHrlCrCy4vEI88ekuB0DmEVkl ucFA== 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=MkdsImVsyEuQLvnhCeJy7SaaCnVmGS9q5CpDB1XQs7U=; b=kGcqnDepJs16NfcAbFxQQJTOSoIQjnhvdblezrQANX+4Bdsb8142eNEj7tjDD3B33E XO4G1D6hRXwfP/Omt67a21mGFDYvP4J6NciOI4egSY+APmaOGK1Ar8mq+hDc/6lpgpa5 bU50QpjAtqTQSsDZj3Miq7pc8g0wOcr/HeiMjcEENzJXPvWzTM7FG4wI9TPkKJMMPI2a TIbdCkhLfofaXl7c/slJmZmY6fGKNI9UG77cLrfKBT7qIFSZG+2opCdzANiJD8zrUhRP /JGkpQFj2d9eDquo4feS+d/SQAd1zYUI9lyq729o+1FbuBnDDH0oicvXHxz3Ypy2KCF+ DoTw== X-Gm-Message-State: AO0yUKXFAlZ+B6jQgojLn473ko0aehFMG+Rr8EKUYlgrvYJSAeZHkl/A fcG2tTz0HWtiUu7w/Dl4pd6ym5s0+JfxAJwIv0cXSm0CUEF5Tw== X-Google-Smtp-Source: AK7set8Od36pAxJzrVOGhcE4SjPVgB7KdUVoAOG2RXyaZa/T5gN1xlRldCAdB2OX7JSsPt/BXkZTnJu82bPPwFktmpE= X-Received: by 2002:a05:600c:46c6:b0:3e2:1244:d399 with SMTP id q6-20020a05600c46c600b003e21244d399mr864660wmo.64.1676987411921; Tue, 21 Feb 2023 05:50:11 -0800 (PST) In-Reply-To: Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=dalanicolai@gmail.com; helo=mail-wm1-x335.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:303645 Archived-At: --000000000000fafff105f5360e99 Content-Type: text/plain; charset="UTF-8" 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. >> > --000000000000fafff105f5360e99 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Let me, additionally, very briefly explain what the c= ode is doing, and
what I am expecting (as an attempt to make it immediat= ely clear what I
mean).

So the code is first simply creating (for= my dir) 108 overlays.=C2=A0 Then
in 'scrap-dir-images' are made= to display the images from the
directory. Immediately, after the
= 9;(seq-do-indexed (lambda (im n) (overlay-put ... 'display ...)'the function print the value of '(overlays-in (window-start) (window-e= nd))',
which return 108. However, I expect it to print 2, as the ove= rlays should
have the size of the images now (and I see only two images = simultaneously on
screen). Indeed when doing 'M-: (overlays-in (wind= ow-start) (window-end))'
immediately after creating the 'image g= allery', it returns 2.

On Tue, 21 Feb 2023 at 14:39, dalanicol= ai <dalanicolai@gmail.com&g= t; 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
m= any and that they are small (which is not a very reasonable
assumption, = but this is just my personal 'test' function).

Indeed, the e= xample does not call sit-for, because it should show that
the printed nu= mber 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 i= s what 'scrap-dir-images' prints.=C2=A0 However, the images
are = normal 'foto' size, so that I only see two images on screen, andindeed doing 'M-: (overlays-in (window-start) (window-end))' manua= lly
now prints 2.=C2=A0 If I had added the '(sit-for)' in the ex= ample
code, then I would have 'fixed' the problem, and 'scra= p-dir-images'
would have printed 2 immediately because the display p= roperty
('expansion of the overlays') got enough time to take ef= fect.

I hope this clears things up, but of course I would be happy t= o 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.=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.
--000000000000fafff105f5360e99--