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 sB1eM5SqZGdjwAAAqHPOHw:P1 (envelope-from ) for ; Thu, 19 Dec 2024 23:21:57 +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 sB1eM5SqZGdjwAAAqHPOHw (envelope-from ) for ; Fri, 20 Dec 2024 00:21:56 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=thaodan.de header.s=mail header.b=stfb2gJw; 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=quarantine) header.from=thaodan.de ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1734650516; 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:autocrypt:autocrypt; bh=dJXLjwERVDDh4vZ6NjMF6Zhm4r4tHFNumlml1CsBezY=; b=bmel/KLPDz7RKSNKzEqpDQL3lqeYJ6mjcrJpO7EHKJravH/Sov6HWqebYfDf2E9o9bwCSG DmIKS22BIgDfTpwleaP3KpxHQ8srGAYNH6ZNQ8mUMKFVDvDdOzFs5PjclwhQZwoPV/z2YC bjx315cr4AfWFKaDejNYI5wP4UntEF7370eV/aVPAB/Z0ctFnGSUXJl/2p8wOSs+B55NcB KwURZLwAWdmL29EHldTBP3j1RNtxIkQtzBo1B+quBYulbAChqV04bU6HReWrHxDxHeBOxu TJD+jstDS4lqq0FCa/8n9H3RflLl19I+UyK1eUuru2bAuV2f1QlMoJniECubHA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1734650516; a=rsa-sha256; cv=none; b=ZmAfPY9Oh8cWfsDmFCwua2KjL6JanZsz0N7zKLAdViqLrP4e1+zHob+7w+7HFagAudHwad bjtiQthD/Qx9hzWr/hfe56vB7lWGDg0koXX0J6OWecPKHzvYI6c8B1riYQe4y/cfpLFBny BKDJStY1i3AzDrHcapgqj+4s7xRT0C/NveGdKgg9wcprNBMdSZdP57Dy5RbW7wwL3ohgyi iotQRRsj6bFqKE27XK9OiBk7E16aXJHfsg7R78jsZ47hfZM8av5xjduZnfg120LG1cgVLg lRdgGhtEp2F+7e774jgVoP0LAPlpyKhJr5QIVO0X34tqThuvhoFoZy7S4vRQiw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=thaodan.de header.s=mail header.b=stfb2gJw; 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=quarantine) header.from=thaodan.de 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 66CD18EE36 for ; Fri, 20 Dec 2024 00:21:56 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tOPpD-0002r0-0w; Thu, 19 Dec 2024 18:20:59 -0500 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 1tOPpB-0002ql-3l for emacs-orgmode@gnu.org; Thu, 19 Dec 2024 18:20:57 -0500 Received: from thaodan.de ([185.216.177.71]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tOPp8-0001pQ-AB for emacs-orgmode@gnu.org; Thu, 19 Dec 2024 18:20:56 -0500 Received: from odin (dsl-trebng12-50dc7b-49.dhcp.inet.fi [80.220.123.49]) by thaodan.de (Postfix) with ESMTPSA id D3942D00099; Fri, 20 Dec 2024 01:20:47 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=thaodan.de; s=mail; t=1734650448; bh=hZ6AskpOsWc0YqWnSXCHc6KdQXd+vg+gFOOgRpMKLvA=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=stfb2gJwhVhyDsu1ZeKshK3fJ6hNVRXfHfK2akRgxc3uOguZ7AVbvCvZN5IFI+lmM bNRTGRMvgmc1vWaT4mb/bOBucnI2NZlgBAT0eVAmyHgzLWa1+OXvey20uHk2AWZvRZ qMSvUzeyuMmY1QoogWCNtAykPguR1YDaO68tovhvmm+h5KlTY2x3VH14bXOMPbixP/ p8xo5vFstqbHpRZge7efhWqjPD6h0oO1EVUKy0TgelNckiwHt6SMkqn77jGWewWA7m /ZqL8DNtcNHyD3V2Oma2rte3xUypvxM4dgc8WFrBt1uoGS2NKQ+OY87SPxglSPOQwJ m8unm7iZRpIOMbZyrH0bmFECHYqKTQVePC4gTkCw5jPI7S5R0CBrBU11U34RgKr/F6 GvsBP59kHwcknG89+MED+fEfN6cOGeFma1lUnClOLHQq/T1rJWr/yDgs0K2hI8FA03 TsmOwPgiFmRO3UFpG0PlH3a8Q4yPeGM2nSL8jajbzz7DSWY9woi/DTEoXRJrpJ8nzS vh7mA2ZCxqJ9qLO9mKfyQkxvLn/7Y5xtQgcI1+fzQ6wu2jShE+hG894D/AYItn5gwP C6N5PlyXT/pIhhz1mdNxaHui0+ILumec9EL9BB1hUz+HlC555YDYD5rwyAn5a7qWF5 3glvMW9Kj23l2CkxMvg0YxuA= From: =?utf-8?Q?Bj=C3=B6rn?= Bidar To: Ihor Radchenko Cc: Karthik Chikmagalur , emacs-orgmode@gnu.org Subject: Re: Link preview generation with new link preview property In-Reply-To: <874j328aym.fsf@localhost> (Ihor Radchenko's message of "Tue, 17 Dec 2024 17:40:17 +0000") References: <6755f138.0c0a0220.40388.51fbSMTPIN_ADDED_BROKEN@mx.google.com> <874j382kue.fsf@gmail.com> <87pllug2y4.fsf@localhost> <87ldwfnff4.fsf@gmail.com> <874j328aym.fsf@localhost> Autocrypt: addr=bjorn.bidar@thaodan.de; prefer-encrypt=nopreference; keydata= mDMEZNfpPhYJKwYBBAHaRw8BAQdACBEmr+0xwIIHZfIDlZmm7sa+lHHSb0g9FZrN6qE6ru60JUJq w7ZybiBCaWRhciA8Ympvcm4uYmlkYXJAdGhhb2Rhbi5kZT6IlgQTFgoAPgIbAwULCQgHAgIiAgYV CgkICwIEFgIDAQIeBwIXgBYhBFHxdut1RzAepymoq1wbdKFlHF9oBQJk1/YmAhkBAAoJEFwbdKFl HF9oB9cBAJoIIGQKXm4cpap+Flxc/EGnYl0123lcEyzuduqvlDT0AQC3OlFKm/OiqJ8IMTrzJRZ8 phFssTkSrrFXnM2jm5PYDoiTBBMWCgA7FiEEUfF263VHMB6nKairXBt0oWUcX2gFAmTX6T4CGwMF CwkIBwICIgIGFQoJCAsCBBYCAwECHgcCF4AACgkQXBt0oWUcX2hbCQEAtru7kvM8hi8zo6z9ux2h K+B5xViKuo7Z8K3IXuK5ugwA+wUfKzomzdBPhfxDsqLcEziGRxoyx0Q3ld9aermBUccHtBxCasO2 cm4gQmlkYXIgPG1lQHRoYW9kYW4uZGU+iJMEExYKADsCGwMFCwkIBwICIgIGFQoJCAsCBBYCAwEC HgcCF4AWIQRR8XbrdUcwHqcpqKtcG3ShZRxfaAUCZNf2FQAKCRBcG3ShZRxfaCzSAP4hZ7cSp0YN XYpcjHdsySh2MuBhhoPeLGXs+2kSiqBiOwD/TP8AgPEg/R+SI9GI9on7fBJJ0mp2IT8kZ2rhDOjg gA6IkwQTFgoAOxYhBFHxdut1RzAepymoq1wbdKFlHF9oBQJk1+ntAhsDBQsJCAcCAiICBhUKCQgL AgQWAgMBAh4HAheAAAoJEFwbdKFlHF9oBgwA/iQHwe0VL4Df4GGTYlNjMSHFlIkBmN4UfYGLYj3E TrOUAQC51M+M3cjsL8WHdpBz6VAo6df9d+rVwhQ9vQuFHqevArg4BGTX6T4SCisGAQQBl1UBBQEB B0Cbohc3JEfn005/cm0AOGjSsW1ZxAkgaoVNjbpqk4MgNAMBCAeIeAQYFgoAIBYhBFHxdut1RzAe pymoq1wbdKFlHF9oBQJk1+k+AhsMAAoJEFwbdKFlHF9ooHABAKGmrGBic/Vys3BBrOQiRB3Z7izO HwhqTRpAqFZtXS2nAQDZhp/5aYw1TZjTzkm1KVt9QiYnjd/MvxRE9iaY6x4mDbgzBGTX6T4WCSsG AQQB2kcPAQEHQAgRJq/tMcCCB2XyA5WZpu7GvpRx0m9IPRWazeqhOq7uiO8EGBYKACAWIQRR8Xbr dUcwHqcpqKtcG3ShZRxfaAUCZNf71AIbIgCBCRBcG3ShZRxfaHYgBBkWCgAdFiEEUfF263VHMB6n KairXBt0oWUcX2gFAmTX+9QACgkQXBt0oWUcX2jeSwD6AtWn0cuo8IF35YRo4o3cDRJnUfJnbvJy GxyCDThR+zYBAKG6/jdwmZkBQZKslnDAbMMd2WfiZZT5JW3IWC4EaKMO7HkBAKYPGZ3UbfkRvfFK S+pQ9CgtNfkSJQBtT1Ob7Y6nsacgAQCpyXN7yppmhW/oBgivITPy9Lkg+V4NK9WZYZCU9Q7LBA== Date: Fri, 20 Dec 2024 01:20:46 +0200 Message-ID: <87msgrqmy9.fsf@> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=185.216.177.71; envelope-from=bjorn.bidar@thaodan.de; helo=thaodan.de X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 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, INVALID_MSGID=0.568, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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-Scanner: mx11.migadu.com X-Migadu-Spam-Score: -6.92 X-Spam-Score: -6.92 X-Migadu-Queue-Id: 66CD18EE36 X-TUID: gGuscUfzeYGV --=-=-= Content-Type: text/plain Ihor Radchenko writes: > Karthik Chikmagalur writes: > >> ... >> Considering this, it might be better to just split >> `org-link-preview-file' into two public functions, where the "inside" >> function accepts an image instead of a file. > > Agree. > Would you be interested to create a patch? Did you think of something like this? --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-org-link-Split-link-preview-into-two-functions.patch >From a3c682a7d730b0ae9492407d080ba8549a19e02d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Bidar?= Date: Fri, 20 Dec 2024 01:00:46 +0200 Subject: [PATCH] org-link: Split link preview into two functions * lisp/ol.el (org-link-preview-file, org-link-preview-image-data): Split up the actual preview part into a separate function. The new preview function can be called by :preview handler to display the image according to the correct alignment for the link to be previewed. --- lisp/ol.el | 45 ++++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/lisp/ol.el b/lisp/ol.el index 032610bad..dd6b07152 100644 --- a/lisp/ol.el +++ b/lisp/ol.el @@ -2177,27 +2177,34 @@ (defun org-link-preview-file (ov path link) ((string-match-p (image-file-name-regexp) file)) ((file-exists-p file))) (let* ((width (org-display-inline-image--width link)) - (align (org-image--align link)) - (image (org--create-inline-image file width))) - (when image ; Add image to overlay - ;; See bug#59902. We cannot rely - ;; on Emacs to update image if the file - ;; has changed. - (image-flush image) - (overlay-put ov 'display image) - (overlay-put ov 'face 'default) - (overlay-put ov 'keymap image-map) - (when align - (overlay-put - ov 'before-string - (propertize - " " 'face 'default - 'display - (pcase align - ("center" `(space :align-to (- center (0.5 . ,image)))) - ("right" `(space :align-to (- right ,image))))))) + (image-data (org--create-inline-image file width))) + (when image-data + (org-link-preview-image-data ov image-data link) t))))) +(defun org-link-preview-image-data (ov image-data link) + "Display image data IMAGE-DATA in overlay OV for link. + +This intended to be used by functions which provide the :preview link property +of links such as in `org-link-preview-file'" + (let ((align (org-image--align link))) + ;; See bug#59902. We cannot rely + ;; on Emacs to update image if the file + ;; has changed. + (image-flush image-data) + (overlay-put ov 'display image-data) + (overlay-put ov 'face 'default) + (overlay-put ov 'keymap image-map) + (when align + (overlay-put + ov 'before-string + (propertize + " " 'face 'default + 'display + (pcase align + ("center" `(space :align-to (- center (0.5 . ,image-data)))) + ("right" `(space :align-to (- right ,image-data))))))))) + ;;;; "help" link type (defun org-link--open-help (path _) "Open a \"help\" type link. -- 2.45.2 --=-=-=--