From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id mAyVILaW5mYDtQAA62LTzQ:P1 (envelope-from ) for ; Sun, 15 Sep 2024 08:11:34 +0000 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id mAyVILaW5mYDtQAA62LTzQ (envelope-from ) for ; Sun, 15 Sep 2024 10:11:34 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=Ovo9VX+C; 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"; dmarc=pass (policy=none) header.from=posteo.net ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1726387894; 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=QxzOzXPV62Ecq/h2auqVBA5CuITTRDa10VDqw4U84Bg=; b=jGHbUdDztI58r30z6ILn4eqcS1UckyYE4RnPjDom2rsdlGOIeJFP5WKojZyiFhkoS4OZgh P9GXYeS6lfH2YwKNe37WF1wACTXMNH7kbDPo+x9cnYJd+EoORH769wjY0JKNl9tabZAiG9 zIC0RMDyuarzVpksYziXxlLHjky4hMUHpKbeu/iuNvRxmISiCtdgD2Wnwnz3eL9yILxKa9 A7v0FwCVCZfTHjsyCSQIeEuwwG9VcT9fl2szIUHgHbNNUGatbWqPRKEUzQyu3FK6g66spA jbebUCRno1VbbvXSJU8wmI8/zdC5XL5/NPDfRE5vrDTjZkNBJEd0ETh2vIUqtQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=Ovo9VX+C; 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"; dmarc=pass (policy=none) header.from=posteo.net ARC-Seal: i=1; s=key1; d=yhetil.org; t=1726387894; a=rsa-sha256; cv=none; b=l8gsQgd7H7SRgdzxQGFAPy8kteITZiOFT5GcUaGdlg18jBUCYP9aFh3nvAYbbvBUI0J9Qs pV5FKZrAP5Ktfy9ANe5qKf1s4iZ6OpqmkADHtT4rxUNMWU0Yyt6/oDFXFFrCX/CaGm3nYT CgkEm0eX5IoeIwpEjNLT4zm3pTmy4yYcJRxyIewEJsI8QvVP4//RaCrjcCISalFOOklGdN /pOYtN9O1RzDvt4jclj1zrbg6w3SmDrgNyuOwWANPXKoeMngCe502Enp2M+B6DlTLRSksa y1H2VnVVMNvqjzMKNInuthOnxemTh5MgTxtVjOpY7kHSjUesKPfLQOxL7TvkVQ== 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 6224592B1 for ; Sun, 15 Sep 2024 10:11:34 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1spkLA-0007Nz-Ux; Sun, 15 Sep 2024 04:10:40 -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 1spkL7-0007FU-Jr for emacs-orgmode@gnu.org; Sun, 15 Sep 2024 04:10:37 -0400 Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1spkL4-0008LQ-BB for emacs-orgmode@gnu.org; Sun, 15 Sep 2024 04:10:37 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id D13AB240103 for ; Sun, 15 Sep 2024 10:10:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1726387831; bh=77M/OY1We25aYRSYn7MPaelyvwXnxkQIdn0zRybuaeU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: From; b=Ovo9VX+C7PLlwac67HS231CnPR2T7kYjaB5oaOC4CpQ5CeFr79ZkbekmDeUWqNmdI F2C65A1q2bMYG0LTDoe08dEFu+MQvSk0ZqJOksDYcGWlpZnIH9O0KATSX5wRdwKoGn r9UZ59DmmPsgTHcL+DKDYj1fl3aRtPITLUQaVJTIeMqWJeOa9fm/oi7zuh/rk+GHOw 9J3yXcunIWn9QTLJUVvF+MAo0/KiSgcNsazwmhqcCddqhvLrCrDb9jGd7eJN31wE5M auJLEhSyhgUlDMQRYfl9UyY83Cb4v6lkC/vB2fTumWwSPchONW5z6et7PyLjcAV2gl ygaKzfiFngOYw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4X611z2LHmz6tvr; Sun, 15 Sep 2024 10:10:31 +0200 (CEST) From: Ihor Radchenko To: Karthik Chikmagalur Cc: stardiviner , Org mode Subject: Re: [PATCH v3] Inline image display as part of a new org-link-preview system In-Reply-To: <87r09rxpjg.fsf@gmail.com> References: <6461a84b.a70a0220.b6d36.5d00@mx.google.com> <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> <87r09rxpjg.fsf@gmail.com> Date: Sun, 15 Sep 2024 08:12:05 +0000 Message-ID: <87h6ah72ui.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=185.67.36.66; envelope-from=yantar92@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: -5.31 X-Spam-Score: -5.31 X-Migadu-Queue-Id: 6224592B1 X-Migadu-Scanner: mx10.migadu.com X-TUID: NOoeE1LQtRBP Karthik Chikmagalur writes: >> Image cache is cleared _only_ with REFRESH argument. >> I think that makes sense, right? > > Yes. But `org-link-preview-region' is always called with the REFRESH > argument set to `t' though. Sure. What's a problem with that? In theory, we might not need to clear image cache as long as we call `image-flush' in `org-link-preview-clear'. >>> Just unmodified old code. I've require'd image in ol now, let me know >>> if I should do it differently. >> >> Let's not require it on top level. Maybe better do it within the preview >> function. > > Moved (require 'image) to inside the `org-link-preview-file'. I know it > doesn't affect performance in any reasonable way, but I'm usually > hesitant to do this in functions that run inside loops. There are pros and cons. Ideally, we should have these previews in a separate library, so that loading Org mode does not need to require so much staff. Loading time is not great already. My hesitance about top-level require is that ol.el is loaded by default and that the preview functionality may or may not be used by the users. So, loading image.el ought to be optional. > ... > + ;; Run preview asynchronously in batches: > + ;; preview-queue is a list of preview-batch, which is a list of preview-spec > + (when (car preview-queue) > + (dolist (preview-batch (nreverse preview-queue)) > + (run-with-idle-timer > + org-link-preview-delay nil It means that you are scheduling every single preview batch to fire at the same time. I think that the timers here should run sequentially - (1) fire the first batch without delay; (2) wait org-link-preview-delay and fire the next batch; (3) ... > + (lambda (previews) > + ;; (message "queue: %d" preview-queue-size) > + (cl-decf preview-queue-size) > + (dolist (preview-spec (nreverse previews)) ;spec is (preview-func overlay path link) > + (when-let* ((ov (cadr preview-spec)) > + (buf (overlay-buffer ov))) ov or its buffer may not exit at the time the timer is fired. Because, for example, the buffer is killed, or because user edited the underlying link before it got displayed. -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at