From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.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 aOqDJMtm1Gb0SgAAqHPOHw:P1 (envelope-from ) for ; Sun, 01 Sep 2024 13:06:19 +0000 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id aOqDJMtm1Gb0SgAAqHPOHw (envelope-from ) for ; Sun, 01 Sep 2024 15:06:19 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=XkpmNtcq; dmarc=pass (policy=none) header.from=posteo.net; 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=1725195979; 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=dVyiotfJYLpHa9lhqZoPPBtXR1yVfpF2aGXK194tQSs=; b=KjgcFnF/Zf/70OOvLJwJ08qAkh72c1U7h3yzlv4hiDHqM0NXtFOVvHnqkg3pBQHPkD3Czr b2yn24dq9EHywjE0JDm/yoSN3itmzTvxOAI4NQw1rv3gmUfHrEjZIzq8QBmA3+6pdu5E8F 8+sFGxZ/vGo+Wjb9zwZ7VF1hK+B490PdUSBmf7yIm5Faqqz4Xqh5meQKWXoRNpG/v1FIcz qYYSrsRJSkqe0GjO4tfaVCZXFEqXIezp+/4C4TWlqa2ocYP1bRbZu6IT5E0bKxUDM2DpvX vmxZ00cAivUCQlchs+ZxYdbBKaOOjDMKgFYPzdNQ8iVfiLGqyOteM/mHVSHzmg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1725195979; a=rsa-sha256; cv=none; b=F77Hz7643OkKcuTbLHA7PP1fpM4KFrMTKwepEqzXzSOo7yjg15fWIxbEDysfkQX/323ckS AERPVgDfXdinevVUsJL/h2jBJTNie7UtrIbwEpFicvVZanfyCoc1PGNppji8FQ46Mthz4R Ip3v+rslRrZzG6wPFYXHazZaT5O6Wgzsws0xhgqAVMumtgwTIFXW4ti3Pze/0gt7hIeDLA gS+0dU67Lx+oeoNimoKmZcuQ3Q8lLw7oLRuPogHc1/fLkUYAQMkurH49HQLUdjDUHSyBy2 hK6yQfdDu+4kFGdtYZ/V2vijqvp4vW/wPHNNgd0mB8tF7aKX4Y2QkfrOPBpMfA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=XkpmNtcq; dmarc=pass (policy=none) header.from=posteo.net; 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 1818F76ACF for ; Sun, 01 Sep 2024 15:06:19 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1skkGj-0005hb-75; Sun, 01 Sep 2024 09:05:25 -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 1skkGh-0005h6-0Y for emacs-orgmode@gnu.org; Sun, 01 Sep 2024 09:05:23 -0400 Received: from mout01.posteo.de ([185.67.36.65]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1skkGe-0000j5-FP for emacs-orgmode@gnu.org; Sun, 01 Sep 2024 09:05:22 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id F097A240027 for ; Sun, 1 Sep 2024 15:05:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1725195915; bh=DIApw08m2bKiZsnlVpJbeFTPVbvEo3iokZgJocNm9mE=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: From; b=XkpmNtcqH7Yb2EA0tIxN2naG/Fn8/OEU95Q2N76bhy+Qik2PNzqq/MsIH6iFKPPeI HHGrr3TDpes5Ys/OEciMQuTfHBv3Wsi1F2M18a14zDceUP7z3aIQkAOr4yXuMOpetd rZ+iZvftJOPR4h4IUX5biq9q7+PtyfyrUqu8k9NWu5nSi8362Dgzzy8RCDz4uTPNqj t+3q65bLXwYoDyUM+9hRPjYnuoLzjH+XO/pwpROsiImNyLCR08OS5GYAY6LiMwOpYc HHaAc7dA/abJqvMBfEXZliDZgxPOwHavT76QM8iaBgFDdEET2Gamvbqt33+P8a8wXb pQ2jg5ydLJQJQ== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4WxXDV0743z6txn; Sun, 1 Sep 2024 15:05:13 +0200 (CEST) From: Ihor Radchenko To: Karthik Chikmagalur Cc: stardiviner , Org mode Subject: Re: [PATCH v2] Inline image display as part of a new org-link-preview system In-Reply-To: <87h6b09v4o.fsf@gmail.com> References: <6461a84b.a70a0220.b6d36.5d00@mx.google.com> <64c905d7.170a0220.f434a.fddb@mx.google.com> <87o7jpoqfl.fsf@localhost> <64cc9b8a.170a0220.dfa99.2e18@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> Date: Sun, 01 Sep 2024 13:06:38 +0000 Message-ID: <878qwb8qw1.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=185.67.36.65; envelope-from=yantar92@posteo.net; helo=mout01.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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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.70 X-Spam-Score: -6.70 X-Migadu-Queue-Id: 1818F76ACF X-Migadu-Scanner: mx11.migadu.com X-TUID: wA4g8G9gKmiI Karthik Chikmagalur writes: > First, here's an updated description of the proposed API: > > 1. You can register a previewer with each type of Org link in the > following way: > > (org-link-set-parameters "file" :preview #'org-link-preview-file) > (org-link-set-parameters "https" :preview #'my/org-link-preview-web) > > 2. This previewer is called by Org with three parameters: an overlay, > the link path being previewed and the link element: > > (funcall #'org-link-preview-file ov path link) > > - To preview the link, the previewer must update the overlay ov as > needed, for example by placing an image as its `display' property. > It should not modify the buffer contents. > - The previewer must return a non-nil value to indicate preview > success. If the preview fails, it should return nil. > > That's it. Sounds reasonable. > Subject: [PATCH] org-link: Move inline image display to org-link The patch does a lot more than merely "moving" things around. Please, name it accordingly. Maybe something like New customizable preview API for arbitrary link types > --- a/lisp/ol.el > +++ b/lisp/ol.el > @@ -82,6 +82,13 @@ (declare-function org-src-source-buffer "org-src" ()) > (declare-function org-src-source-type "org-src" ()) > (declare-function org-time-stamp-format "org" (&optional long inactive)) > (declare-function outline-next-heading "outline" ()) > +(declare-function image-flush "image" (spec &optional frame)) > +(declare-function org-entry-end-position "org" ()) > +(declare-function org-element-contents-begin "org-element" (node)) > +(declare-function org-attach-expand "org-attach" (file)) > +(declare-function org-display-inline-image--width "org" (link)) > +(declare-function org-image--align "org" (link)) > +(declare-function org--create-inline-image "org" (file width)) Some of these declares are now redundant. > +`:preview' > + > + Function to run to generate an in-buffer preview for the link. It > + must accept three arguments: > + - an overlay placed from the start to the end of the link. > + - the link path, as a string. > + - the link element > + This function must return a non-nil value to indicate success. I am wondering whether asynchronicity should be implemented on high level rather than inside individual link preview functions. We may, for example, first create the necessary overlays and indicate that they are "processing..." first, and then call the actual preview functions asynchronously. If we leave asynchronous handling to individual previews, they will have no way to handle queuing large number of link previews, and we may arrive at the common situation with network processes when they schedule and finish around the same time, hanging Emacs while it is handling a bunch of process sentinels. > + ;; C-u argument: clear image at point or in entry > + ((equal arg '(4)) > + (if (get-char-property (point) 'org-image-overlay) > + ;; clear link preview at point > + (when-let ((context (org-element-context)) > + ((org-element-type-p context 'link))) It will be more reliable to clear across overlay boundaries rather than assuming that the overlay covers exactly one link. > +BEG and END define the considered part. They default to the > +buffer boundaries with possible narrowing." > + (interactive "P") > + (when (display-graphic-p) Do we need it here? You check graphics both here and later in the preview function. We may probably drop the check herein. > + (let* ((width (org-display-inline-image--width link)) > + (align (org-image--align link)) > + (image (org--create-inline-image file width))) I am wondering why you left these functions in org.el. Why not moving them here? > + (when image ; Add image to overlay > ... > + (overlay-put ov 'org-image-overlay t) This is redundant, isn't it? > + (when (boundp 'image-map) What if not bound? Why not simply (require 'image)? ... and ORG-NEWS entry. You also need to fixup the manual where it talks about image previews. -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at