From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id oJ0QKoOoYWQldQEASxT56A (envelope-from ) for ; Mon, 15 May 2023 05:35:31 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id YNgBKoOoYWRpWwEAauVa8A (envelope-from ) for ; Mon, 15 May 2023 05:35:31 +0200 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 BC7383A63F for ; Mon, 15 May 2023 05:35:30 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pyOyw-00043i-Cn; Sun, 14 May 2023 23:34:42 -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 1pyOyu-00043W-KB for emacs-orgmode@gnu.org; Sun, 14 May 2023 23:34:40 -0400 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pyOys-0004Ta-RE for emacs-orgmode@gnu.org; Sun, 14 May 2023 23:34:40 -0400 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-643a1656b79so8617090b3a.3 for ; Sun, 14 May 2023 20:34:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684121676; x=1686713676; h=mime-version:reply-to:date:subject:to:from:user-agent:message-id :from:to:cc:subject:date:message-id:reply-to; bh=ANJsdGpzCvoLPLFZHwgVN1jGa2AiXMF8PZ2yeILudUE=; b=jHNwNu788unv4l1cYCnMJQzZ/+x7msw8VB640iJ4X4gK6RMV7lMBh4lXsBryVEcjCC gQuLcHlHv6l0pcaP1RtnCaFdMCIuKnnEsvnTZX+cTj/tL8yy5p9fXvuyjxk/PN3G5sse n5DDGQhJ7AgFSbql6AtwHkeujum45XWXQfCgQR/fn1dCpn3k5MuTmkLCk5B6/F/NddGH BvU62P8DIaK3mrKgFLcvgml46BlJaOpj6IU+1HRUJeTfOIEqp2uaGFgC7ZBVo2xLNtuY aXmNC+X1v6MoqKt7esZuhbvFzKfkeoj19gokSgf2/MOL3An9wAhTbZxYvLLDYDQvfFr5 1bww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684121677; x=1686713677; h=mime-version:reply-to:date:subject:to:from:user-agent:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ANJsdGpzCvoLPLFZHwgVN1jGa2AiXMF8PZ2yeILudUE=; b=R1ZeQMsGCmETCMAWLeRH6nhkpA7kyqXQuDokvkc9ev9zfhftZFCkuwW5DJaviJKT87 czrhfYJLnfYapuPsLKqLLVKSboOMeKS369A/fbh2CwnQvCJ9mdLTXOrNMGX9fH/F/ioj +o4pgbTpWW+fXjrmhLkpEu8Y5K55GLEfu/kx4yG4ADdSyzN/vEsXN+lY1vwgyCi1//+J pve/k9apSrqSlZqNZVW763U3W+SHbpxz2jbPaIdZAVGPO2eq+SZfSX81NlhcIRTia85H QzQULXl3xXPhIaGJLsAobK9wXUePtKmiYoGZW+F7dVEJePIPqUa2O9NJslQJmSdDejKj TwvQ== X-Gm-Message-State: AC+VfDx3/cbBobRzF81tJrbSxYdWRjPoG4+7gWDy6D9wcORMc7H0LQXb AWO3G/CMmk1wtS/vPhbmla0N2rs+ARPX X-Google-Smtp-Source: ACHHUZ6UNPfQ0aQVrACC7JIkv0Lo0p2Gf8IhMdnqhyUMuh0FwKCIMG5bu+Cxg7YwldtuSsdJRDHgzA== X-Received: by 2002:a05:6a00:190e:b0:646:2ec8:3360 with SMTP id y14-20020a056a00190e00b006462ec83360mr30574163pfi.23.1684121676486; Sun, 14 May 2023 20:34:36 -0700 (PDT) Received: from Mac-mini.local ([39.171.215.147]) by smtp.gmail.com with ESMTPSA id c7-20020aa78c07000000b00643864d03dfsm11099220pfd.171.2023.05.14.20.34.35 for (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 14 May 2023 20:34:35 -0700 (PDT) Message-ID: <6461a84b.a70a0220.b6d36.5d00@mx.google.com> X-Google-Original-Message-ID: Received: by Mac-mini.local (Postfix, from userid 501) id D138A8D8F189; Mon, 15 May 2023 11:34:29 +0800 (CST) User-agent: mu4e 1.10.3; emacs 30.0.50 From: "Christopher M. Miles" To: Org mode (mailing-list) Subject: [PATCH] add a function to only refresh inline images under current headline instead of global buffer Date: Mon, 15 May 2023 11:28:59 +0800 MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Received-SPF: pass client-ip=2607:f8b0:4864:20::42f; envelope-from=numbchild@gmail.com; helo=mail-pf1-x42f.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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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: , Reply-To: numbchild@gmail.com Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Seal: i=1; s=key1; d=yhetil.org; t=1684121731; a=rsa-sha256; cv=none; b=atKmfCoPm78JtpuKuqVNJAOr1i+Edqc9fgka6B0Sj4guqMjuhCtb8f/MolTZCoko0anaf7 5x9BVv5fvH7uWcEBKObnfPZFWY8/15M1+jCQ5nZaLvaisqud7i4T9F00B5yDqtBTcDdAov /UOQSkXf+h/oxsot73DMteTmq1+fmnez+04vWU6s/cy2GfSEQqXzyq1NzWSu6yn7bC5b75 Sq015kEo9IQS1ITcxbhurwuZRe8nliVZhG+McjtG2VrPKqB7M+HqzvO353LF62STvQOEvy sz4qFTUOEUo8RUb2bivcXC/+Egn4CTyBAqrol+Qm462tR6Qzl3xWu+hi8Z+b4g== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=jHNwNu78; 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=1684121731; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=ANJsdGpzCvoLPLFZHwgVN1jGa2AiXMF8PZ2yeILudUE=; b=XuJ0u7F8tC1n8LfLKoRObUWA1J3wkCdMf8yf9jYgaXPncLHO92nRBEazU2e5gULDMM/mpk hG/DDN5nv77ewZk23JZWPgGbU1XVLdu1jvoXw1gMeX4zOFGzX9kHQs/Cd0BICcSDGfH4lZ 8IVLsN/XUj2QiJZDIE4lP7MMiSFqDlQvoOMFHPheplACIQV3+R6EeMAcdDJdqRRZdBBtZh okVqR5HsiDyWn3qCV9Ug7DYixkXET9Z322j95wluwqU5LumDwwEnMSQ1D+Dcxcw+AiDZg9 IwGHB/9vKQUFxfBzqVFEHJ1v7isECZRKYd2U1IJ62ni3bchjMcACNdZC5wxmlw== X-Migadu-Spam-Score: -9.27 X-Spam-Score: -9.27 X-Migadu-Queue-Id: BC7383A63F X-Migadu-Scanner: scn0.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=jHNwNu78; 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" X-TUID: UvVu0rTncIRW --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable I found a lot of third-part Emacs packages refresh Org source block image r= esult using the API function like this: #+begin_src emacs-lisp ;; Automatically refresh inline images. (add-hook 'org-babel-after-execute-hook (defun ob-dall-e--refresh-inline-images () (when org-inline-image-overlays (org-redisplay-inline-images)))) #+end_src The `org-redisplay-inline-images' will refresh whole buffer inline images. When the buffer is a big Org file, and not all inline images are display already by default (still image file links under fold status). Invoking `org-redisplay-inline-images' will cause Emacs suspend a long time. So I suggest to add an variant local function of `org-redisplay-inline-images' which named `org-redisplay-inline-images-under-headline' that only redisplay inline images under current headline to solve the issue. Here is the diff code prototype, Ihor, can you review it? If it's ok, I will send patch update then. #+begin_src diff (defun org-redisplay-inline-images () =2D "Assure display of inline images and refresh them." + "Assure display of global all inline images in buffer and refresh them. + +NOTE: This function will refresh whole buffer inline images, if +you only want to refresh inline images under headline, suggest to +use `org-redisplay-inline-images-under-headline' in your hook or advice." (interactive) (org-toggle-inline-images) (unless org-inline-image-overlays (org-toggle-inline-images))) =20 +(defun org-redisplay-inline-images-under-headline () + "Assure display of images under current headline and refresh them. +This function is the suggested to be used in hook or advice." + (interactive) + (org-with-wide-buffer + (org-narrow-to-subtree) + ;; If has nested headlines, beg,end only from parent headline + ;; to first child headline which reference to upper + ;; let-binding `org-next-visible-heading'. + (org-display-inline-images + nil nil + (point-min) (progn (org-next-visible-heading 1) (point))))) + #+end_src =2D-=20 [ stardiviner ] I try to make every word tell the meaning that I want to express without mi= sunderstanding. Blog: https://stardiviner.github.io/ IRC(libera.chat, freenode): stardiviner, Matrix: stardiviner GPG: F09F650D7D674819892591401B5DF1C95AE89AC3 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEE8J9lDX1nSBmJJZFAG13xyVromsMFAmRhqEIACgkQG13xyVro msMxIAf+NWhY3GHm6OXJdqLdOaaokO/OE3bMZwNtFJipTr4xepjkZDCt6dHuV7ZF Ku5jHQLsruo/JP8sKVV22+8w5TQ/rQo/iVxUD3t2nJcDmIorGafrXwK5sS4qTENJ leby0H+TAJODXDTqJaTC1yowq5jG4SbXcf1kSUETTzokBSJIdgKlCQqA3AHG0EMS DJ4WcF75QaozFn5WAYYa+FeE5Ka7W33csvmsP+xXSzWwS5zjhRbxOGUiA70dajbj So52a2mcr/Tq5/yX7qNBz/Ogbi1txNeH/27tdp7s2qa3YA7HTXphOveYg3kvTYMX mDes/ijiDaV4G92YKeBeKs/HtcWCBg== =E//i -----END PGP SIGNATURE----- --=-=-=--