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: Two questions about overlays Date: Tue, 21 Feb 2023 13:46:56 +0100 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="0000000000006aa1e905f5352d70" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22191"; mail-complaints-to="usenet@ciao.gmane.io" To: Emacs Devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Feb 21 13:48:04 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 1pUS3v-0005cD-Mn for ged-emacs-devel@m.gmane-mx.org; Tue, 21 Feb 2023 13:48:03 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pUS3G-0004Ml-ON; Tue, 21 Feb 2023 07:47:22 -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 1pUS3B-0004Lx-LJ for emacs-devel@gnu.org; Tue, 21 Feb 2023 07:47:20 -0500 Original-Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pUS33-0007dj-RD for emacs-devel@gnu.org; Tue, 21 Feb 2023 07:47:12 -0500 Original-Received: by mail-wr1-x430.google.com with SMTP id l25so3894440wrb.3 for ; Tue, 21 Feb 2023 04:47:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=FXp0qa3qaIRMizMzCmbir+EnkQDdbS37+e3xCCtHoPE=; b=lJtM2oScnhdkeaP6kn4CqdvXyLcY5x5OXloKf3/tXQhEk+RfPHeS21lkbhK8AJ95FX sWkDpiqEqPo9+wjZeNOB9DUsTigg/3/oOeXMO0g+QSfy1+7a3UR56HGuGyCYVK6QOpar PAh5C+RxiQVdlKydlqFRLYnzPsy/LvWsCAHsesrW2yj54x2J4yuH6HlrOPnMq6QsKjSi 1a+AC9KKHv5QZDPps1083whJIeScPhMBOEgRpS9CByilkekn//gLy3W9vSYN6vUqfZuG hsfKQIE/L2yW8WYcpTr7pqfa8PAzZHlmfYDT16RACQiDbGb6vgt4J4afnnzg5tl0+IM6 n2vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=FXp0qa3qaIRMizMzCmbir+EnkQDdbS37+e3xCCtHoPE=; b=PRU9JtTTwzDMDmsMLPxeFNssNssRAOdyfdkLzBG6Nnr19r+UUnB9a8Z4TanBqUnxOk 6jabReVVdPK9TAjD7C6LW8gFO01BjoeziDlMFhYyyozjPxetiYBK7P+UHnA0LbUiSebn XOT/9hwsRIQKlB7uHuIFUDMgVWfw4DUkIrK7cR6dhZ0R4vrJsFGWaBhopHmY8IZnXPfK gl10Ak9O5mDFPFZpsYULHAFmaPm1FrO3MCBvSM4KJwU+786fG7FcXDY9yW6dn6fnwN5v wphAH6w2tBGKnK2N7+RqN8bUNtryiSL05Urh2eFR7zHx7WKRUDC3gTxrg4ctcjjD5ktj dnOw== X-Gm-Message-State: AO0yUKXV1gIVdQSj96LbhpXxf1GMcBNnTyZBloG/XQpD3N7DtSjMj2ho 634pp2VU6JhBAWiVUzYbyxlCeJTnFm8lLlOF8ry9a1ucbDHvRg== X-Google-Smtp-Source: AK7set+w9gZHhL+FOTKD1Yfz1cHpdBFAUI8PMUjoikHR1yRCN7WIwKjx3eRondFIkNb1H024+g099ki18chnrouwsto= X-Received: by 2002:adf:ec47:0:b0:2c3:e2bd:3de5 with SMTP id w7-20020adfec47000000b002c3e2bd3de5mr26666wrn.365.1676983627569; Tue, 21 Feb 2023 04:47:07 -0800 (PST) Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=dalanicolai@gmail.com; helo=mail-wr1-x430.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:303641 Archived-At: --0000000000006aa1e905f5352d70 Content-Type: multipart/alternative; boundary="0000000000006aa1e705f5352d6e" --0000000000006aa1e705f5352d6e Content-Type: text/plain; charset="UTF-8" I have two short questions about overlays. To clarify, let me start with a short motivation. I have been working on some alternative 'display engine' (I hope I am using a somewhat correct term here). Of course, I would prefer to make functions reusable if possible (currently, image-dired, doc-view, pdf-tools, and dvju all 'implemented their own' display engines). A demonstration can be found in the animated gif for the 'universal document reader' here (I would prefer to reuse/contribute to doc-view/tools, but it turns out to be much easier to start from scratch and, if possible, port things over. That simultaneously cleans up that code). The 'essence' of that document reader is a very simple 'overlay grid', which I like to provide as a 'reusable function' (the idea is very simple and an example is provided in the following file . To try it, you can simply load the code and show images from a directory by doing M-x scrap-dir-images. I am not trying to replace image-dired. The function is just an easy way to implement an example. Also the name scrap comes from 'scrapbook', but I guess I could simply call it overlay-grid. Let me know if you have some idea about the naming). I have been using the overlay grid already in image-roll , but later I 'discovered' a much simpler way to implement the logic for 'dynamically updating' of visible overlays (i.e. pages, for 'normal page sizes' we can not display all images of a document at simultaneously), by simply using the 'overlays-in' function in a 'clever' (or actually quite straightforward) way (instead of reimplementing that same functionality in lisp). 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))'. 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? I hope that some experts here could clear things up in a few words (as usually is the case :) Thanks! --0000000000006aa1e705f5352d6e Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I have two short questions about overlays. To clarify, let= me start
with a short motivation.

I have been working on some al= ternative 'display engine' (I hope I am
using a somewhat correct= term here).=C2=A0 Of course, I would prefer to
make functions reusable = if possible (currently, image-dired, doc-view,
pdf-tools, and dvju all &= #39;implemented their own' display engines). A
demonstration can be = found in the animated gif for the 'universal
document reader' here (I would prefer= to reuse/contribute to
doc-view/tools, but it turns out to be much easi= er to start from
scratch and, if possible, port things over. That simult= aneously cleans
up that code).

The 'essence' of that docu= ment reader is a very simple 'overlay grid',
which I like to pro= vide as a 'reusable function' (the idea is very
simple and an ex= ample is provided in the following file . To try it,
you can simply load= the code and show images from a directory by doing
M-x scrap-dir-images= . I am not trying to replace image-dired. The
function is just an easy w= ay to implement an example. Also the name
scrap comes from 'scrapboo= k', but I guess I could simply call it
overlay-grid. Let me know if = you have some idea about the naming).

I have been using the overlay = grid already in i= mage-roll, but later I
'discovered' a much simpler way to im= plement the logic for
'dynamically updating' of visible overlays= (i.e. pages, for 'normal
page sizes' we can not display all ima= ges of a document at
simultaneously), by simply using the 'overlays-= in' function in a
'clever' (or actually quite straightforwar= d) way (instead of
reimplementing that same functionality in lisp).
<= br>So now here are the questions:

- when displaying multiple pages i= n columns, I would like to use the
overlays-in function to determine whi= ch overlays should display
images.=C2=A0 So I am creating a full 'bo= ok roll' by giving the overlays a
size via the '= space' display property, after which I use overlays-in
to determ= ine which overlays are actually visible. However, after it
takes some ti= me for the 'space' display property to take effect, so I
am manu= all 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&#= 39; mechanism to wait until/detect if the 'overlay expansion'
ha= s finished.

If the explanation is not clear then please load the fol= lowing file
and do 'M-x scrap-dir-images' on a directory that co= ntains enough
images to not fit all on a single screen. It will print th= e number of
overlays found via 'overlays-in' directly after '= ;displaying the
images' (here by assigning the image as display prop= erty instead of
space). You will find it prints all overlays in the buff= er (instead of
only the ones on screen). To find what I expect it to pri= nt now
(again) do 'M-: (overlays-in (window-start) (window-end))'= ;.

My second question is about the function 'overlay-recenter= 9; I don't
really understand its docstring. What kind of 'overla= y lookup' would
go faster? What is 'overlay-lookup' anyway?<= br>
I hope that some experts here could clear things up in a few words (= as
usually is the case :)

Thanks!
--0000000000006aa1e705f5352d6e-- --0000000000006aa1e905f5352d70 Content-Type: text/x-emacs-lisp; charset="US-ASCII"; name="scrap-mode.el" Content-Disposition: attachment; filename="scrap-mode.el" Content-Transfer-Encoding: base64 Content-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yAobWF4LWggMjAwKQoJKQogICAgKHNjcmFwLWNyZWF0ZS1v dmVybGF5cyAobGVuZ3RoIGltYWdlcykgMSkKICAgIChzZXEtZG8taW5kZXhlZCAobGFtYmRhIChp bSBuKQoJCSAgICAgIChvdmVybGF5LXB1dCAobnRoIG4gc2NyYXAtb3ZlcmxheXMpCgkJCQkgICAn ZGlzcGxheSAoY3JlYXRlLWltYWdlIChjb25jYXQgKGZpbGUtbmFtZS1hcy1kaXJlY3RvcnkgZGly KSBpbSkgbmlsIG5pbAoJCQkJCQkJICA6bWF4LXdpZHRoIG1heC13KSkpCgkJICAgIGltYWdlcykp CiAgKHByaW50IChsZW5ndGggKG92ZXJsYXlzLWluICh3aW5kb3ctc3RhcnQpICh3aW5kb3ctZW5k KSkpKSkKCgooZGVmdW4gc2NyYXAtY3JlYXRlLW92ZXJsYXlzIChudW1iZXIKICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgJm9wdGlvbmFsIGNvbHVtbnMgaHNwYWNlIHZzcGFjZQogICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAmcmVzdCBvdmVybGF5LXByb3BzKQogIChkb2xpc3QgKG0g c2NyYXAtaW5jb21wYXRpYmxlLW1vZGVzKQogICAgKGZ1bmNhbGwgbSAtMSkpCiAgKHRvZ2dsZS10 cnVuY2F0ZS1saW5lcyAxKSA7IGFsc28gZGlzYWJsZXMgdmlzdWFsLW1vZGUKICAoc2V0cSBzY3Jh cC1jb2x1bW5zIGNvbHVtbnMpCiAgKGxldCAob3ZlcmxheXMpCiAgICAoZG90aW1lcyAoaSBudW1i ZXIpCiAgICAgIChsZXQqICgobiAoMSsgaSkpCiAgICAgICAgICAgICAobyAobWFrZS1vdmVybGF5 CiAgICAgICAgICAgICAgICAgKHBvaW50KQogICAgICAgICAgICAgICAgIChwcm9nbiAoaW5zZXJ0 ICIgIikgKHBvaW50KSkKICAgICAgICAgICAgICAgICAodW5sZXNzICg9ICglIGNvbHVtbnMgMykg MCkKCQkgICAoaW5zZXJ0IChtYWtlLXN0cmluZyAob3IgaHNwYWNlIDEpIChzdHJpbmctdG8tY2hh ciAiICIpKSkpKSkpCiAgICAgICAgKHdoZW4gKGFuZCAoPSAoJSBuIChvciBjb2x1bW5zIDEpKSAw KQogICAgICAgICAgICAgICAgICAgKG5vdCAoPSBuIG51bWJlcikpKQogICAgICAgICAgKGluc2Vy dCAiXG4iKQogICAgICAgICAgKGluc2VydCAobWFrZS1zdHJpbmcgKG9yIHZzcGFjZSAxKSAoc3Ry aW5nLXRvLWNoYXIgIlxuIikpKSkKICAgICAgICAob3ZlcmxheS1wdXQgbyAnbiBuKQogICAgICAg IChkb3RpbWVzIChqICgvIChsZW5ndGggb3ZlcmxheS1wcm9wcykgMikpCiAgICAgICAgICAobGV0 ICgobSAoKiBqIDIpKSkKICAgICAgICAgICAgKG92ZXJsYXktcHV0IG8gKG50aCBtIG92ZXJsYXkt cHJvcHMpIChudGggKCsgbSAxKSBvdmVybGF5LXByb3BzKSkpKQogICAgICAgIChwdXNoIG8gb3Zl cmxheXMpKSkKICAgIChnb3RvLWNoYXIgKHBvaW50LW1pbikpCiAgICAoc2V0cSBzY3JhcC1vdmVy bGF5cyAobnJldmVyc2Ugb3ZlcmxheXMpKQogICAgKHNjcmFwLW1vZGUpKSkKCihkZWZ1biBzY3Jh cC1uZXh0IChuICZvcHRpb25hbCBwcmV2aW91cykKICAobGV0KiAoKGN1cnJlbnQgKDEtIChzY3Jh cC1nZXQtb3ZlcmxheS1uKSkpCiAgICAgICAgIChuZXh0IChudGggKCsgY3VycmVudCAoaWYgcHJl dmlvdXMgKC0gbikgbikpIHNjcmFwLW92ZXJsYXlzKSkpCiAgICAoZ290by1jaGFyIChvdmVybGF5 LXN0YXJ0IG5leHQpKQogICAgKG92ZXJsYXktcmVjZW50ZXIgKHBvaW50KSkpKQoKKGRlZnVuIHNj cmFwLXNjcm9sbC1uZXh0IChuKQogIChpbnRlcmFjdGl2ZSAicCIpCiAgKGZ1bmNhbGwgc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