From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id C9FtNyRq3mZy6gAAe85BDQ:P1 (envelope-from ) for ; Mon, 09 Sep 2024 03:23:17 +0000 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id C9FtNyRq3mZy6gAAe85BDQ (envelope-from ) for ; Mon, 09 Sep 2024 05:23:17 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=h27csbZg; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1725852196; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=1ChlaRyaSZHFlXAn9Bf8C89YftQAMPD2wUbgo+NZtLk=; b=phrS6PVYfmYzqbv5SFOm3QRwLbYajKaonN9yx7XTGBRyczc+KLYivJpfuuykkIu+rd3tuH 2LVz3jwKXMOV5kpllxdvE2QDOyEWAy1a+u/eu4vZDziSuJaTdd9Oh3hBO/XR6q911r9pjI CMWW08rxQr5bLaiO7w/Rqh4ZIFjVsKEwGYS+CXm0MMUHKgOSEjwOZ956jLvJ7cebaMov5p tNVO7Tepd4VVMN2mAgeCYcwhXbzb8hScVIgH4MQwY07Z8fdm55kRABUlFY4yg5nmk/1pDK +GbaFP87tac6+L27VHE99F73PWCiBwYr4bk8jaR9zTfMno42gpzViovc9lHDtQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1725852196; a=rsa-sha256; cv=none; b=MpJBQt4NFw8hSF41cSCV7qdGWjIofgdT6Oq8FD9XX/iemofmP6XScIIGz8udTQvaKM35dv 7Bfrhm+GeVNNW9uxIB29QLT5+NI9aAyjVYtPuMH0JCS0By1fF3mO4CMYsnn0Ms0sLNAADM TbdTkhFNLZo8aSnG/oMyuQyppYItShfeLb1GresmwmrkjXYDCbdlB/d896VEFqW2Riz2s5 h8BNx6eMIfKOueoPrUdtSh1+VB27jTpgy8+XdY9fQb6pAWfDyqwq+MQ1PNYUYihGmnoR8v CiLLSFMLhK4vwHAXChVB7fV9kvtAR+GQ3mbsSb6ldNt5iFkleVdUEd+Pkc8/Hg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=h27csbZg; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 482B47A14F for ; Mon, 09 Sep 2024 05:23:15 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1snUyR-00053b-6y; Sun, 08 Sep 2024 23:21:55 -0400 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 1snUyP-00052i-Aa for emacs-orgmode@gnu.org; Sun, 08 Sep 2024 23:21:53 -0400 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1snUyN-0008MK-LW for emacs-orgmode@gnu.org; Sun, 08 Sep 2024 23:21:53 -0400 Received: by mail-pj1-x102a.google.com with SMTP id 98e67ed59e1d1-2d1daa2577bso2805529a91.2 for ; Sun, 08 Sep 2024 20:21:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725852109; x=1726456909; darn=gnu.org; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=1ChlaRyaSZHFlXAn9Bf8C89YftQAMPD2wUbgo+NZtLk=; b=h27csbZgYlptENva5VQFuW4nwEJsr/0JpRtMN+ywDCawkqNZmANeHmsSFxWMgzWoYK h7R/wxnGviZcZIleVNH9JQVw5YTgtAYPoyCOkkEb0OPTg7sWhirkzwgh4oHI5oT73MxR iw98s+05lM2VoDUhJlFSgo5G+kQbRXuXYrR/s9TCR2QqF/JXXUwvWvEKgU7voq16Y9hU JEOaFBmDG3BoCIxQd9SXqr64XfjYRlr0NwqFx3AOEQ1phoHYRzCWTLaeFJo0BepWA/ta nqAEOLuxWU7fJL5lqCFZUHWP3hQMahRSKm7Tfy/qRby0Y0XNhQiGatGxXXdr2yJTonsm 2V/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725852109; x=1726456909; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=1ChlaRyaSZHFlXAn9Bf8C89YftQAMPD2wUbgo+NZtLk=; b=GepHP3ri8mksyrYT9Ln9g2QUIJvH5qYcZlI5vVKkHEZ2Ye9urMTVXkPlz4CQ3IMVf1 VZ5L5sNhhVbck68ZesTGH3S7HKt5TASge+J814F/TT3LcP4BSOzQNKrKl7nY9K4Rm+nR kBdbG7W8ttTVZv/pwnWhmw5TaYy8NZMyvpQU1VfmUJczsKhxtXaEgD/vpkd7XUHGFjCa moc+CgrqJyG8KLYXDFPmpN/1zLHE9BtmC56msCUAVRtIvSFjhdxnHvpD1RIIKCkydl4a XAGnHcicg4D+nSzquAWZJsi+f2E8Vjqo7TL4CPiuZF/K6w2SZNNHrzRmbeXw4Aw6qJ4g NSiw== X-Forwarded-Encrypted: i=1; AJvYcCV/cO/Eww+FRQMjC3y4n7wPbiFx5LM6vAMx8py9tn7ypfmSrZLsvq+9dmlunpWiNI7VH9loAnPiWg9KMd7y@gnu.org X-Gm-Message-State: AOJu0YyujxW+XKfJGN7HCIFe+90+rFv6ypoKyjJ//nn0mliRaav/yfR3 lvOqj555/bITfojdTwZdMM0xBG9kpEC1HkqsNWaWaeNiqa9kgK8j X-Google-Smtp-Source: AGHT+IGXw9b//OTAqyC6zCkF9mThA9k3inoa88agSZokHqqIIrI+HnD1rMH/fdwGVGzPu6b/XwQqxw== X-Received: by 2002:a17:90a:8991:b0:2d8:7970:726 with SMTP id 98e67ed59e1d1-2dafcf19dfemr6318215a91.12.1725852108766; Sun, 08 Sep 2024 20:21:48 -0700 (PDT) Received: from localhost ([2600:8802:5726:2500:719e:314f:34a1:46f7]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2dadc110473sm5479982a91.35.2024.09.08.20.21.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Sep 2024 20:21:47 -0700 (PDT) From: Karthik Chikmagalur To: Ihor Radchenko Cc: stardiviner , Org mode Subject: Re: [PATCH v3] Inline image display as part of a new org-link-preview system In-Reply-To: <87o74ypp3b.fsf@localhost> References: <6461a84b.a70a0220.b6d36.5d00@mx.google.com> <87msz7kym0.fsf@localhost> <669882e5.050a0220.8ff6d.33c6@mx.google.com> <871q3logb9.fsf@localhost> <66a8b73b.170a0220.383476.996e@mx.google.com> <87o75yhwnu.fsf@localhost> <87v7zyyvm3.fsf@localhost> <87frr07xz8.fsf@gmail.com> <87cym38aj8.fsf@gmail.com> <87r0ajawgj.fsf@localhost> <87a5h77zb1.fsf@gmail.com> <87msl4wv8d.fsf@localhost> <875xrqg6cb.fsf@gmail.com> <874j70n559.fsf@localhost> <87msksabld.fsf@gmail.com> <87jzfwljkq.fsf@localhost> <87h6b09v4o.fsf@gmail.com> <878qwb8qw1.fsf@localhost> <878qw9ak6a.fsf@gmail.com> <87o74ypp3b.fsf@localhost> Date: Sun, 08 Sep 2024 20:21:46 -0700 Message-ID: <87cyldzf3p.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2607:f8b0:4864:20::102a; envelope-from=karthikchikmagalur@gmail.com; helo=mail-pj1-x102a.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, 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-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -6.81 X-Spam-Score: -6.81 X-Migadu-Queue-Id: 482B47A14F X-Migadu-Scanner: mx11.migadu.com X-TUID: XuYuJ5Tfx79n >> I'm not sure how to solve this problem. Here's what I'm picturing -- >> note that this doesn't actually avoid the process sentinel pile-up: >> >> The preview provider should return its callback function to Org so Org >> can run it at its convenience. >> >> Org runs (funcall #'preview-func ov path link) >> >> preview-func returns either >> 1. t, if preview is synchronous and successful, >> 2. nil, if preview is synchronous but failed, >> 3. A callback-func, if preview is asynchronous. In this case the >> preview-func starts the network request or async job. >> >> Org adds callback-func to the queue of callback-funcs for this run, and >> runs them spaced out on a timer or something. Preview success depends >> on whether the callback-func returns t or nil. >> >> Implementing something like this should be easy with org-async, included >> in the LaTeX preview patchset. >> >> But the process sentinels will run independent of Org's callback queue. >> The callbacks only place the resulting image (or other metadata) on the >> overlays. The bottleneck here is not the display engine, so this >> doesn't solve the problem. >> >> Can you give me some more details of what you have in mind? > > I mostly meant calling preview-func asynchronously, while idle, spaced > out, spending not longer than a fraction of second to call several > preview-funcs. > Spacing might then be controlled by the users. > > We might go further, and let the preview functions return a > process. Then, we may explicitly control running sentinels just for that > process via `accept-process-output'. But I am not sure if we need to go > that far. Do you mean something like this? (while (re-search-forward org-link-any-re end t) ;; Make overlay ov here ;; Find path, link and preview-func here (push (list ov preview-func path link) previews-remaining)) (dolist (preview-data-chunk (seq-partition previews-remaining 6)) (run-with-idle-timer 0.10 (lambda (preview-data) (pcase-dolist (`(,ov ,preview-func ,path ,link) preview-data) (when-let ((buf (overlay-buffer ov))) (with-current-buffer buf (if (funcall preview-func ov path link) (push ov org-link-preview-overlays) ;; Preview was unsuccessful, delete overlay (delete-overlay ov)))))) preview-data-chunk)) Where the chunk size (6) and the idle time (0.10 seconds) will be customizable. Karthik