From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.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 MLr9CFo8YmSrKAEASxT56A (envelope-from ) for ; Mon, 15 May 2023 16:06:18 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id wEITCFo8YmScPgEAG6o9tA (envelope-from ) for ; Mon, 15 May 2023 16:06:18 +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 8D43DCFA4 for ; Mon, 15 May 2023 16:06:17 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pyYpB-000295-54; Mon, 15 May 2023 10:05:17 -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 1pyYp4-00026W-GU for emacs-orgmode@gnu.org; Mon, 15 May 2023 10:05:12 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pyYow-0007dj-LD for emacs-orgmode@gnu.org; Mon, 15 May 2023 10:05:06 -0400 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1aaf70676b6so91205605ad.3 for ; Mon, 15 May 2023 07:04:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684159499; x=1686751499; h=mime-version:in-reply-to:reply-to:date:subject:cc:to:from :user-agent:references:message-id:from:to:cc:subject:date:message-id :reply-to; bh=DIwdrrUdj0S1bb12/8YJc0Kms6+wKygAm1dh3n1ENPk=; b=Hj8TYZNcqKNFmJoRmhWE2ieDHf2lX1GN3Ps10+OoCl8yeMS3vmQ4UdwIFKGzYjeaKB iFHY2yYX92Pjri8vaTfy+vGxqvsjUNCwEHmJU3O9YwiWf9hUx2hoBciu+BACKDo5lljt akiwnHCZuY6JW545khzDIwDxIDmJ70f6GLroCgYCNpGxHLY7aXATWgJbJxUyAiZniegW qlvfolb7fHlS/XppYWtFt0s8k40LWmKpRlf6z78pNic53xA+xm5QJ7KLN1d0a05cCASN rLSTS+EQLcfdz/bE1zfMCzXFWQfbTWfryKhrqmYrckI9tKtv6uFn6WuUo6jTwzeYTdPL AVQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684159499; x=1686751499; h=mime-version:in-reply-to:reply-to:date:subject:cc:to:from :user-agent:references:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DIwdrrUdj0S1bb12/8YJc0Kms6+wKygAm1dh3n1ENPk=; b=G1X2gSIFIMYtf2UrlNywYcj+jyFUBDMqSdW+HVhR62TCgoFThvjZcz5IkF4h9TItIr fDaz/UyYCsw9I5+Mzx/mdwMSjxgzCvQZw3KxZeFD2f7G+ohv34rF30xwbHZl6BNsKCUm rVhiJTi0tmcz77gLmR+uoiBE/gdWGOPGyCfaKDD0cAig1W3pE9QDCQM8VYciNHlqJ90Q 5EEZgcc/rDV0aq9BNCafGsm0H0W7UeoILTiL7jXP0IOS6gGqL7+alRKYZYwbo6YCP4V/ PFM9kFaYjH+wL9tUNLixyAuEy6SE8anSq2t0JnBAos12w5AW7pTxjZU4iIp4W3n9xlfU zKZQ== X-Gm-Message-State: AC+VfDyiBIgJwetYXoDWD2yJ/DxzNnvCSjl7rKc6G2ACBrjZeLTLfRZV oz0xPTMx9uUNR3MzDKMNbQ== X-Google-Smtp-Source: ACHHUZ7o4wXAv0tnlwr4xuVFJHxnSXiFEVT/5y17/D0cZUeGAtN21NVVmLBJ+drjpOCzFaeQFhLHSg== X-Received: by 2002:a17:902:f391:b0:1ac:6ef0:a96e with SMTP id f17-20020a170902f39100b001ac6ef0a96emr25832611ple.31.1684159498782; Mon, 15 May 2023 07:04:58 -0700 (PDT) Received: from Mac-mini.local ([39.171.215.147]) by smtp.gmail.com with ESMTPSA id h17-20020a170902f55100b001a64ed4621csm13598061plf.182.2023.05.15.07.04.56 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 15 May 2023 07:04:57 -0700 (PDT) Message-ID: <64623c09.170a0220.52bf9.9437@mx.google.com> X-Google-Original-Message-ID: Received: by Mac-mini.local (Postfix, from userid 501) id B85638DB0A79; Mon, 15 May 2023 22:04:27 +0800 (CST) References: <6461a84b.a70a0220.b6d36.5d00@mx.google.com> <87sfbxhmxe.fsf@localhost> User-agent: mu4e 1.10.3; emacs 30.0.50 From: "Christopher M. Miles" To: Ihor Radchenko Cc: numbchild@gmail.com, Org mode Subject: [PATCH v2] Re: [PATCH] add a function to only refresh inline images under current headline instead of global buffer Date: Mon, 15 May 2023 22:00:02 +0800 In-reply-to: <87sfbxhmxe.fsf@localhost> 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::633; envelope-from=numbchild@gmail.com; helo=mail-pl1-x633.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-Flow: FLOW_IN X-Migadu-Country: US ARC-Seal: i=1; s=key1; d=yhetil.org; t=1684159577; a=rsa-sha256; cv=none; b=mYSMFoU6zyeU94qR9uX37myA2yfcLerbxm0n95PfFf1NeopzEdLHW/zBC7IottrHOTBy15 iDIB4JfIzMnhVEHVLLoh7LtRjsSiBlN0pxYkvHuQUxmpWxriITNN+ZfaKFdInd9iJtVhIq KRzXI4r4H9r39e8cSX59ZNQlQAyduXuwvodpK0qv824dE5kbEaY7sCmVOfBg3++YYWAyio 8HEHIh/NOmYmxlkWBZIZsZOXwt7P8wOzuRLr98W0B2unby8kROAwcVI5JFsii9p8i3gRVk sG+hgWF1hPF+xth45IpzgqUWXtx7wazNKHduOCtbR9pTnR4nyqcvQUKhplegYw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=Hj8TYZNc; 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=1684159577; h=from:from:sender:sender:reply-to: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=DIwdrrUdj0S1bb12/8YJc0Kms6+wKygAm1dh3n1ENPk=; b=U82cUtLewKjzxCIpdXcKf0NiHNeWuONo8UxnFPdmr52Qx2ZXwkY60P9niwT/7V7tfxhc3S qXoih7jCeiEkINKeou172DR0fY9AlMTRznuEBzzfdWlLgSEQlgXkEcwxobh8YMV0ClHvKb gVlp5lJevUTndx53nBgYyPHIriLmyx9xqciwOfHqJ+GByNTICBKcqtU8wBZQkWW1l4Gs+I PZ7qriqIDN/uID3kOHsbC9DiUqZ7V9nMUx4RC7k7qOe8pTNjcXGGgUZzc37r5/9LcXnI+R hhxYH83LEnfzy3jvDihUnGOcA8cOgd2bJJ34saJiJ104T1nUvN3czAkh/C97nw== X-Migadu-Scanner: scn1.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=Hj8TYZNc; 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-Migadu-Spam-Score: -6.47 X-Spam-Score: -6.47 X-Migadu-Queue-Id: 8D43DCFA4 X-TUID: QmZuXKQWQwzu --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Ihor Radchenko writes: > "Christopher M. Miles" writes: > >> 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. > > I'd prefer something more closely resembling `org-latex-preview' > approach with prefix arguments: > > Toggle preview of the LaTeX fragment at point. >=20=20=20=20=20 > If the cursor is on a LaTeX fragment, create the image and > overlay it over the source code, if there is none. Remove it > otherwise. If there is no fragment at point, display images for > all fragments in the current section. With an active region, > display images for all fragments in the region. >=20=20=20=20=20 > With a C-u prefix argument ARG, clear images for all fragments > in the current section. >=20=20=20=20=20 > With a C-u C-u prefix argument ARG, display image for all > fragments in the buffer. >=20=20=20=20=20 > With a C-u C-u C-u prefix argument ARG, clear image for all > fragments in the buffer. > > `org-toggle-inline-images' should also be changed. Here is the source code of `org-toggle-inline-images'. I implement this by reference `org-latex-preview'. I have not write testing, but only manually tested with Edebug and on actual Org buffer displaying and disable inline images. The command works fine. Ihor, can you review the cod= e? #+begin_src emacs-lisp (defun org-toggle-inline-images (&optional arg include-linked beg end) "Toggle the display of inline images at point. INCLUDE-LINKED is passed to `org-display-inline-images'. If cursor is on an inline image link, display the inline image. If there is none, remove it otherwise. If there is no inline image link at point, display all inline images in the= current section. With an active region, display inline images in the region. With a `\\[universal-argument]' prefix argument ARG, clear inline images in the current section. With a `\\[universal-argument] \\[universal-argument]' prefix argument ARG, display all inline images in the buffer. With a `\\[universal-argument] \\[universal-argument] \ \\[universal-argument]' prefix argument ARG, clear all inline images in the buffer." (interactive "P") (cond ((not (display-graphic-p)) nil) ;; Clear whole buffer inline images. ((equal arg '(64)) (org-remove-inline-images (point-min) (point-max)) (message "Inline images preview disabled in buffer.")) ;; Display whole buffer inline images. ((equal arg '(16)) (message "Displaying all inline images in buffer...") (org-display-inline-images include-linked nil (point-min) (point-max)) (message "Displaying all inline images in buffer... done.")) ;; Clear current section. ((equal arg '(4)) (let* ((beg (if (use-region-p) (region-beginning) (if (org-before-first-heading-p) (point-min) (save-excursion (org-with-limited-levels (org-back-to-heading t) (point)))))) (end (if (use-region-p) (region-end) (org-with-limited-levels (org-entry-end-position)))) (inline-images (org--inline-image-overlays beg end))) (org-remove-inline-images beg end) (message "%d inline images display removed." (length inline-images)))) ;; Display region selected inline images. ((use-region-p) (message "Displaying inline images in region...") (org-display-inline-images include-linked t (region-beginning) (region-= end)) (message "Displaying inline images in region... done.")) ;; Toggle display of inline image link at point. ((let ((context (org-element-context))) (and (memq (org-element-type context) '(link)) (let ((beg (org-element-property :begin context)) (end (org-element-property :end context))) (if (org--inline-image-overlays beg end) (progn (org-remove-inline-images beg end) (message "Display inline image at point removed.")) (org-display-inline-images include-linked t beg end) (message "Displaying inline image at point ... done.")) t)))) ;; Display inline images under current section. (t (let ((beg (if (org-before-first-heading-p) (point-min) (save-excursion (org-with-limited-levels (org-back-to-heading t) (point))))) (end (org-with-limited-levels (org-entry-end-position)))) (message "Displaying inline images in section...") (org-display-inline-images include-linked t beg end) (message "Displaying inline images in section... done."))))) #+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----- iQEzBAEBCAAdFiEE8J9lDX1nSBmJJZFAG13xyVromsMFAmRiO+sACgkQG13xyVro msPKfwgAmfKoWfjHpuNRMfRziWut+14tQ7uveiXH+7YqT3Au8mI/9AWfINr0nguh NO0XHn8JajRAklHNyEn+q4U/DUZbzig/fUjx1b+HKgXVCkBw2BKAkHVPKhvC5GYk i8Ejkv2eGFRlrNgrND5pB1i0tzlZ63XkHXTN5FxVOiND1umqLwFeQKPkCM1e/L/8 YHk9dDL+YzMtV0Ue1CQqyp6MgEAMu8VnU4BFXRIModGGODhcfV+hRDQDYA2z1v4d tXZu7bRqi5TxCyVzG+dtUd2KrvDe0+w1ixcYcSIgcyIYXAbT4yA3/SNRGcEZR9Oq ezIYYo+27qyjrcdmTUfalyCrh3aSpg== =Mj53 -----END PGP SIGNATURE----- --=-=-=--