From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:306:2d92::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id kIalMRIGyWTuMwEASxT56A (envelope-from ) for ; Tue, 01 Aug 2023 15:18:10 +0200 Received: from aspmx1.migadu.com ([2001:41d0:306:2d92::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id WEXNMBIGyWSNGQEA9RJhRA (envelope-from ) for ; Tue, 01 Aug 2023 15:18:10 +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 05D7947467 for ; Tue, 1 Aug 2023 15:18:09 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=Wnhrxz3A; 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=1690895890; 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=ELANJ6td0GYZ0w7oSRJV0D/8aX1oOO+ksKkVbVmEwPY=; b=nI8RHykBzeiQcNwYxB2J8MTLGE9WEuOKBTKII5OYcSs3949A+kCNIT9N2KaKJHhDop4Ag7 YyLY+m8zxeSuHxc6s3m9EOTtI/IHhMK60R/8yhNGHUsxFmdJeD/szSEl81Jhp3SMK0vmMP NjDS5NS8n89vegYI1ZOiCN/IPu3HDumfrOLyvRmCWezEO6URVXYNtCSsYejxUngQwe0JdW 42cO7kltrGylHhBsKQAKakYomLc4PHPezs8oK2OocIZLp1M/DbZ8r0PLC/8fkDN2Ioq53B 7TLUtAaOUMX204+urZzmzptz1zhcoELShgLoA9E1SUoMBTxmHnc7I8OUznP/iw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=Wnhrxz3A; 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=1690895890; a=rsa-sha256; cv=none; b=BZDv+g4H8BEQK4fQ53uWSrkrxs3pOPlNpax0WA2tfPtKNZjxAT4nzPABp6p3Sz/mhm4x8I cC2KtGydaGVqZMRNLfJRWIUzJoAS1mQ6XjduSKYZnYN+6fRmBET57OO9Bjw8tcnD8YIOW7 YcZgoy9p/JS2oOnxWFxlkh8n8Po8ZQcFGaerfSeZ3fTCTqXdIGV1t86MHwWzrFdC3B/7jJ BEKL3oXp98gnEhf4j2hfQle8tGUuMNtSouC9eH835qvfeuNcQ58+v/mecDnZJlICOOLcSw k7p1ONJTcljTbkJzUvsvHU8QdDoU2/tXkzmML+8BBSlDdUnHdfWS2nyFYjx99g== Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qQpFX-0007US-H8; Tue, 01 Aug 2023 09:17:19 -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 1qQpFU-0007TY-LT for emacs-orgmode@gnu.org; Tue, 01 Aug 2023 09:17:16 -0400 Received: from mail-pg1-x529.google.com ([2607:f8b0:4864:20::529]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qQpFS-0003T7-4Q for emacs-orgmode@gnu.org; Tue, 01 Aug 2023 09:17:16 -0400 Received: by mail-pg1-x529.google.com with SMTP id 41be03b00d2f7-53fbf2c42bfso4205161a12.3 for ; Tue, 01 Aug 2023 06:17:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690895832; x=1691500632; 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=ELANJ6td0GYZ0w7oSRJV0D/8aX1oOO+ksKkVbVmEwPY=; b=Wnhrxz3Au0rZqoGXyld4VHWWlhbhD3F79cQu+D5JX8ll5mYBo8QqWM2m5Vm62Sii1T x+F4aMpk9pM3UTVtFpG3cA16MUy1rAuHz33LJwLz+Nn0ceOZCydAJ4aPKed1GU9K1cTF IXfBTcP6mtLVN+qqjY+Z7NIZVwp4/64AifggVcGMOPXhgF08MwDF2/fdxy5t3I/iz1p5 NlfAPZzA59c+U87GGO9jfoaux3fy7K42oz33lzismeV7ygPUBzCbEdVkyJQjbUghD/i8 eeu62AwKOp2YNVrpjKuVQ4jWGTuTXH6wHzcY01u1rPYwBbdpbC2YvPS3PraFMlrewWac z0/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690895832; x=1691500632; 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=ELANJ6td0GYZ0w7oSRJV0D/8aX1oOO+ksKkVbVmEwPY=; b=O+cwOrOU3SXIxtZL3sbKLnvkVXjOTt1+Q18mM5INTQJ3Cmir4Iy5gtvxXD/G3Uh/Jg WJBnRxWBsxW88yTdZ76NoZQEWRYj3+0hNzBXGhGw8f7XxkN9OEPa7H+Jkeu8ZuXKXE6D IUquzu1QA+TGCnov8/4K/uQ02F2q9Kl3ebVhNs9AVZDuFL5AjmHQUf835sHK9R4mXnqd yLlllOxm3j8pCSBstYd0wtRLe//To9A1gcPMN7Er7SLO75mgXi0PxzKCNO2k3MmFIumC 5e/u9s0gmLfJ1ZpuGxnOvqiKFE/0gfgMTvLyD05OVoFBcsduJhd0oZIeowyF8VNuxqxa 1uog== X-Gm-Message-State: ABy/qLZVY3X/BokobomB3jg1yMe592tTulQYMDeWhNjWiPumLETENl6P ceFqZGQiyRaH3G89VPl8hA== X-Google-Smtp-Source: APBJJlFNeLed+GcLyuGX0j+ho5r3Pg90aOyVKt4u/nQcpa702fIeTl+t8fXoNUIar0uFE3v/Ztd7rA== X-Received: by 2002:a17:90b:1e41:b0:267:ed84:c74d with SMTP id pi1-20020a17090b1e4100b00267ed84c74dmr11218425pjb.22.1690895832409; Tue, 01 Aug 2023 06:17:12 -0700 (PDT) Received: from Mac-mini.local ([39.171.199.49]) by smtp.gmail.com with ESMTPSA id 14-20020a17090a190e00b00260cce91d20sm8214332pjg.33.2023.08.01.06.17.11 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 01 Aug 2023 06:17:11 -0700 (PDT) Message-ID: <64c905d7.170a0220.f434a.fddb@mx.google.com> X-Google-Original-Message-ID: Received: by Mac-mini.local (Postfix, from userid 501) id AF8399CD48E6; Tue, 1 Aug 2023 21:17:06 +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> <64c8a313.a70a0220.93ee0.14fb@mx.google.com> <87il9zgpdp.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.1] Re: [PATCH] add a function to only refresh inline images under current headline instead of global buffer Date: Tue, 01 Aug 2023 20:17:04 +0800 In-reply-to: <87il9zgpdp.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::529; envelope-from=numbchild@gmail.com; helo=mail-pg1-x529.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-Scanner: mx2.migadu.com X-Migadu-Spam-Score: -8.62 X-Spam-Score: -8.62 X-Migadu-Queue-Id: 05D7947467 X-TUID: /Oq4IbOJjNFZ --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain Ihor Radchenko writes: > "Christopher M. Miles" writes: > >>> 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) > > You can just use `org--inline-image-overlays'. > Aha, I forget this API function, I applied in new patch. >>> 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? > > The problem here is backwards compatibility. `org-toggle-inline-images' > is bound to C-c C-x C-v and people may be used to C-u C-c C-x C-v > displaying linked images like > > [[https://orgmode.org/resources/img/org-mode-unicorn.svg][description]] > > I will need to think more how to approach this. > Indeed. >>> 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. > > Sure. But the idea of this specific C-1 prefix argument is to toggle the > hypothetical defcustom `org-inline-images-include-linked'. If we flip it > we may need to remove/add linked image previews or otherwise risk users > being confused by the defcustom not taking effect. I checked source code, don't know where to insert this functionality. Is it be in `org-display-inline-images` or somewhere else? I will find time to checking code whether can add this in another patch. If you have plan for this, let me know. I think current patch is ready for merging now. WDYT? --=-=-= 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=202f68f0172dc5e452c05a9d254eab8ae797bcd15b 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 | 89 ++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 74 insertions(+), 15 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index e72cf056a..04f713d26 100644 =2D-- a/lisp/org.el +++ b/lisp/org.el @@ -16160,22 +16160,81 @@ 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) + (let ((beg (region-beginning)) + (end (region-end))) + (if (org--inline-image-overlays beg end) + (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 t beg 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----- iQEzBAEBCAAdFiEE8J9lDX1nSBmJJZFAG13xyVromsMFAmTJBc8ACgkQG13xyVro msNkLggAzC1mYudTfjs9gudpRt6Kz2Mb3B9x66+isRGVH4Yl+JHLtY3MHYyloUlA FtMpFBnahfOMuZ6AdU4iu6liKuvF9vlYPDVwvQpvaAhxbFHqdJJGNJ/Et34WU39i 6ZYLr4C/FqlHjg/FpalxNtgl1pfDLXQ9jeXb2QbjjY+3kvxdwARLaZbL9o+ZbOhQ ziNdVKZmyXpxmrpMR/ciRIfKXWqm/IG1CaJmjGR0gStDB8ATe77n8r4kX5MHCqo5 KRN8W57QKwToByLK1nCGzXXsUigAuB1qH/6jnfe6PDrD6K4D5h42i46VNGGb6xaS CpOG2I6KQWAlO9Q1Nrx/UULuHYIl6g== =PBYF -----END PGP SIGNATURE----- --==-=-=--