From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:403:4789::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id YNkJOlOjyGQ+DAAASxT56A (envelope-from ) for ; Tue, 01 Aug 2023 08:16:52 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:4789::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id ONQEOlOjyGSyGQAA9RJhRA (envelope-from ) for ; Tue, 01 Aug 2023 08:16:51 +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 474015E150 for ; Tue, 1 Aug 2023 08:16:51 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=Sr8nBnaX; 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=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1690870611; 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=PRL83RrpCFkGGV5R+GRTfzOqdvGA7lk27mhlV2LActg=; b=qoMWaDFq4uh7NV0LTqW169k7InzmnlY6xZeTVwE5ZgI+lQFW0EIDLHcv45DhaLZIp6RwJO jqCPCv7dVjxyKnTiOmMsMW8RDYrFRfCVPWj1h7+9YhGYJNh4qfWssBFrAHJXRtVZ4yD3KN pbXOpFuwZM239HjL2c2xyjHlFoDgJFyx+7P+raSFR1hjIR4BjAgFkJ10hG9bh0RzOiHUYn JXt8u1OXe4ltJAet1G1mqY9X4RHxKIp+kXD/q/VIftOkqPYwj1gYbHUoIzItBQz9BMFBd6 fpO8GAwjcrOH9PY+z16wbXpcQLlVOeAeKwCH7fUayhBOZH75/2hjXRyCoKxXsA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=Sr8nBnaX; 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=gmail.com ARC-Seal: i=1; s=key1; d=yhetil.org; t=1690870611; a=rsa-sha256; cv=none; b=qMFoW+2QI6EmVs9vY8en6BHjPkhYrZJT0cJ9Ma6yjc1NC0GsqYuwdX5pYCTCV9n4997sff E17YXB2t8w1yz9yr5Ga+7B9GkWfMKDKeKcj7FVffiNHfPe45a9IfS30hu/b5DGEoeIhelR WJlFUnthD2ZQH/CWPypGR9cyELzsEi0UeWTL6jt2gvIh2fdRBasybPpriSowrXUyrpghJ3 afjVxWk6xQ1qTpQXn/VsUT/YmvavtdDhdmxJ2UZj3zJzMQHqiyDyrWrdz49Fdo6eLlD2TT e5xrzMeliaPR/jk4d/qX8b2ZzzebUvaPUXzJWPpOM9NXsBitlCYjHd8HxUTymQ== Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qQifi-0005hO-Vh; Tue, 01 Aug 2023 02:15:55 -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 1qQifh-0005f6-6s for emacs-orgmode@gnu.org; Tue, 01 Aug 2023 02:15:53 -0400 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qQife-0002vo-TM for emacs-orgmode@gnu.org; Tue, 01 Aug 2023 02:15:52 -0400 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-686efdeabaeso3452828b3a.3 for ; Mon, 31 Jul 2023 23:15:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690870549; x=1691475349; 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=PRL83RrpCFkGGV5R+GRTfzOqdvGA7lk27mhlV2LActg=; b=Sr8nBnaX+LU03sRGbtWLABe8xcVQJSzPWG7/yXWiImSH6Lyp29RewA8m1FUB9EXP/C mwjXxniNjLmuZLLGG8Q0I35h4XutUN9jMQl4enAdH06EC9c7exK4qkRN/xLjpEc+lDBg A34k71PSZFQApFBkjKXq8qvy97Vtt50gG6Rojub1z7v/GLkgtzQHAZxGJ3jFiobDUXIO 7vl1SPy1xUv2r5BFMYfis//63Mfv/8mTHVi6M6Pn5pIlPNd7UN9qNfo9oRljfZw/dMa9 /GY/eAiHl4MNtMLlPGmGJZ7J2GUtmHyOCXv6fQBwTvdUnFpzi6J3Vwywnbb618R7LIAI wRag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690870549; x=1691475349; 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=PRL83RrpCFkGGV5R+GRTfzOqdvGA7lk27mhlV2LActg=; b=WW2NqCcv2bAV8yYIAil08dfZ/bgrOekeT3Fji1cyAU9c2mUB/7e8ZBuUjZBMN2fdbu VI2B9tjebFNqxPttaLUvQEuWEGdTrXwJVo/AlG/O+iRLKLOomLFkdHf5TL4tLuryPGuN OlqiKVEaOVtLWbOIc7TqEdlyRqMNI9fH9z2Hby7vlIEGhh1l+mbADMoPlwo+Q1wYIdT2 uWgMEIq2C+o5/4U5Hdt8U9kqv8MPzz/IzWgB3Xr6hmt6Uw5/iKyy0WPrkTcllmjWq1E3 l1dAvZByiglol6uy3DJTtM4gdcnYSKBOJC/BTWskyo/sq8M6ukZbIrI0lhBsDC0mxoXy NANg== X-Gm-Message-State: ABy/qLatZzlF/cnH2a4Ds1n/U164qjIhG5D9zUYFoFcQP/mg2oCaD49X uDzNu/qXcZOq0uJYEOUHxw== X-Google-Smtp-Source: APBJJlE/HwtPnuYa6rQ5UopUCt6KCUhdZ4vr3rXFHHuoUVPtB88KBQejGs9ST/1S1xX2v6YYJtPOpQ== X-Received: by 2002:a05:6a00:1795:b0:668:753a:b150 with SMTP id s21-20020a056a00179500b00668753ab150mr13813481pfg.21.1690870548459; Mon, 31 Jul 2023 23:15:48 -0700 (PDT) Received: from Mac-mini.local ([39.171.199.49]) by smtp.gmail.com with ESMTPSA id y15-20020aa7804f000000b00682a27905b9sm8843464pfm.13.2023.07.31.23.15.46 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 31 Jul 2023 23:15:47 -0700 (PDT) Message-ID: <64c8a313.a70a0220.93ee0.14fb@mx.google.com> X-Google-Original-Message-ID: Received: by Mac-mini.local (Postfix, from userid 501) id 397989CCDFB7; Tue, 1 Aug 2023 14:15:38 +0800 (CST) References: <6461a84b.a70a0220.b6d36.5d00@mx.google.com> <87sfbxhmxe.fsf@localhost> <64623c09.170a0220.52bf9.9437@mx.google.com> <87y1lo4ou1.fsf@localhost> <646379fc.620a0220.c0ae4.9fb2@mx.google.com> <87zg3l1rgb.fsf@localhost> User-agent: mu4e 1.11.6; emacs 30.0.50 From: "Christopher M. Miles" To: Ihor Radchenko Cc: "Christopher M. Miles" , Org mode Subject: [PATCH v3] Re: [PATCH] add a function to only refresh inline images under current headline instead of global buffer Date: Tue, 01 Aug 2023 12:40:28 +0800 In-reply-to: <87zg3l1rgb.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::436; envelope-from=numbchild@gmail.com; helo=mail-pf1-x436.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 X-Migadu-Spam-Score: -8.63 X-Spam-Score: -8.63 X-Migadu-Queue-Id: 474015E150 X-Migadu-Scanner: mx1.migadu.com X-TUID: yk5CFgaSi/nJ --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain Ihor Radchenko writes: > "Christopher M. Miles" writes: > >>> Unlike `org-latex-preview', here we need to (1) respect active region; >>> (2) keep the backward compatibility for INCLUDE-LINKED. >>> >>> For (1), for example, it would make sense to respect region when prefix >>> argument is C-u and clear images only there. For (2), we need to at >>> least allow toggling images with description using some prefix argument >>> (previously, any prefix argument would do). >> >> I indeed implemented all same behavior like `org-latex-preview' in new >> `org-toggle-inline-images'. >> >> ... >> And I also implement the toggle inline images in region logic in >> `org-toggle-inline-images' as bellowing: >> >> ;; 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.")) > > This is not a toggle. This is unconditional refresh. > Yes, indeed it's a unconditional refresh. It does not match the meaning of word "toggle". Seems need to detect whether has image overlays in region. I added this detection in new patch. Like bellowing: #+begin_src emacs-lisp ... ((use-region-p) (if (seq-contains-p (mapcar (lambda (ov) (plist-get (overlay-properties ov) 'org-image-overlay)) (overlays-in beg end)) t) (progn (org-remove-inline-images beg end) (message "Inline images in region removed.")) (message "Displaying inline images in region...") (org-display-inline-images include-linked nil (region-beginning) (region-end)) (message "Displaying inline images in region... done."))) .... #+end_src >> For (2), It's working. The code passed the parameter `include-linked' to >> `org-display-inline-images'. So they works in any case of [C-u] prefix. > > My concern is that previously C-u M-x org-toggle-inline-images would > "display links with a text description part". With your patch, it is no > longer the case because INCLUDE-LINKED is not affected by the prefix > argument. > > And there is no clean way to allow INCLUDE-LINKED while keeping > consistency with latex preview commands. About the INCLUDE-LINKED argument, I don't know how to process it. In theory, it should be handled by function org-display-inline-images instead of org-toggle-inline-images. If you have improvements on it, can you add code on my patch? > > What we might do here is making a new defcustom that will control > whether linked images should be displayed. Then, something like C-1 > org-toggle-inline-images could toggle that defcustom and refresh all the > image previews in buffer (if any). > > WDYT? Refreshing all image previews in buffer is same as old behavior. My patch's purpose is to improve function org-toggle-inline-images behavior which refresh only in current level scope instead of whole buffer with lot of inline images especially heavy and suspend Emacs. Because function org-toggle-inline-images is used in of lot Emacs ob-* related packages on after babel execution hook. Old behavior caused execute one source block need to refresh whole buffer all images. Instead of only current headline images, or just results image. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-org-Improve-inline-images-displaying-like-LaTeX-prev.patch Content-Transfer-Encoding: quoted-printable From=20635624cb8446791b9e39f2803077ac9fa6d17225 Mon Sep 17 00:00:00 2001 From: stardiviner Date: Mon, 22 May 2023 16:25:33 +0800 Subject: [PATCH] org: Improve inline images displaying like LaTeX previewing * lisp/org.el (org-toggle-inline-images): Implement LaTeX previewing same logic in inline images toggle displaying. =2D-- lisp/org.el | 92 ++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 77 insertions(+), 15 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index e72cf056a..f847a42e7 100644 =2D-- a/lisp/org.el +++ b/lisp/org.el @@ -16160,22 +16160,84 @@ SNIPPETS-P indicates if this is run to create sni= ppet images for HTML." (when (memq ov org-inline-image-overlays) (push ov result))))) =20 =2D(defun org-toggle-inline-images (&optional include-linked beg end) =2D "Toggle the display of inline images. =2DINCLUDE-LINKED is passed to `org-display-inline-images'." +(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 th= e 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") =2D (if (org--inline-image-overlays beg end) =2D (progn =2D (org-remove-inline-images beg end) =2D (when (called-interactively-p 'interactive) =2D (message "Inline image display turned off"))) =2D (org-display-inline-images include-linked nil beg end) =2D (when (called-interactively-p 'interactive) =2D (let ((new (org--inline-image-overlays beg end))) =2D (message (if new =2D (format "%d images displayed inline" =2D (length new)) =2D "No images to display inline")))))) + (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) + (if (seq-contains-p + (mapcar + (lambda (ov) + (plist-get (overlay-properties ov) 'org-image-overlay)) + (overlays-in beg end)) + t) + (progn + (org-remove-inline-images beg end) + (message "Inline images in region removed.")) + (message "Displaying inline images in region...") + (org-display-inline-images include-linked nil (region-beginning) (re= gion-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."))))) =20 (defun org-redisplay-inline-images () "Assure display of inline images and refresh them." =2D-=20 2.39.2 (Apple Git-143) --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable =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----- iQEzBAEBCAAdFiEE8J9lDX1nSBmJJZFAG13xyVromsMFAmTIowcACgkQG13xyVro msNkNgf+IS3rQlcYZr9k6tKXeQREGbKxOVRI8uBa8M5tr4t/wXUeJQn+FSsr/o4x JAHkkRwGd/59iq26wsbcNo7WQUZzVHzrZFMAo4IGUbYQ6HjFhynSAKINW7CXMxGh KjbEVzKGgGv32l6KahdPDhyS6RC3167bwbfRJ3ObzDUJ1v3l9Ac4kGqmFMl6ni52 ulasA/z/BeewP7I94Nv+6SK3W5QQGwKS8z3d7fw9ae+6Su9aH57Ay9XQCIZ/1R+u paitGR250ndEPWJZh9+V1KG11QEEGCRZBcc/YTJRw/AbnMvPIyrMgYFa0aQlXOh4 ETNPjI/wIlG0n9Y3K4F14XHrbpTUDw== =2v5i -----END PGP SIGNATURE----- --==-=-=--