From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id 2BbFIyaDmGYRDAEAe85BDQ:P1 (envelope-from ) for ; Thu, 18 Jul 2024 02:51:18 +0000 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id 2BbFIyaDmGYRDAEAe85BDQ (envelope-from ) for ; Thu, 18 Jul 2024 04:51:18 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="PPS3/AZ/"; 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=1721271078; 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:resent-to:resent-from:resent-message-id: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=r/kTX3HTf08oWW+X2dmfFQAJbMR1WCUuRPZr9Nn05cU=; b=JwR7GYWc0C6KUVultmHDDvMUC3u4k8A7uviN3E/l9QA8dlBDRlQ/gfVuAiSI+K6ffux9oO jTGA5m/dRgKjnNRZTgRcUZB8190EHRkKgnNh0k32G3SFhML3kH/cLosCglEF7CL+fcL2VY V2cg8mA7Kobef/RFgZuBTLIfZEiVo/QIzpdv/sRR3/7juLWv092mov7GR75755/3MXb8Lp X+yi06rZb3CK/x5fNVQfg0LBK2xtmmq/54OWSXTAXj4EY+8nwj84kQRj/vdlOo/zDLPXAO VWZsfSpPHJkUO64OYsYznZSAIJ3T2BZ+zMUszRDOvCOJ6LP165rt+JnuoSRc7g== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="PPS3/AZ/"; 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=1721271078; a=rsa-sha256; cv=none; b=KbpqBc9apWtBkEZi0KIZ5tSyFPQNKGXABUle0eVEbWKfpDIZspur0L2BQ3i24GKkDzEotW LFJngGRnLy36tMmh2xga8APUUlBNzk2z98RV7j3WcfA9I/0pFbXQGcpUhvFmSEAb1SzBfV 7uNjMwl1r7zNC3RKGvDorh7firAr4z+yvh5zM4SbEYfbo6qa7J7UYPK4upEEg24fCD0GCv 4ttxdjkLd1UOXGqzMsFixScvYMJlqg3s4n/iluuj/LZ9M4hP8OxiwFUYWt7u4IU4WmkZ3W rN9dZXkCm+unmR1Ccwe0OPK2ukoCUR08a31lWEnpAAIl7EszyyqV1eRB7ATZEw== 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 035692458F for ; Thu, 18 Jul 2024 04:51:18 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUHDs-0004A4-Cj; Wed, 17 Jul 2024 22:50:24 -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 1sUHDq-00049p-CB for emacs-orgmode@gnu.org; Wed, 17 Jul 2024 22:50:22 -0400 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUHDm-0008Pg-76 for emacs-orgmode@gnu.org; Wed, 17 Jul 2024 22:50:20 -0400 Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-70b04cb28acso225757b3a.0 for ; Wed, 17 Jul 2024 19:50:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721271016; x=1721875816; darn=gnu.org; h=mime-version:in-reply-to:reply-to:date:subject:cc:to:from :user-agent:references:resent-message-id:resent-date:resent-from :resent-to:message-id:from:to:cc:subject:date:message-id:reply-to; bh=r/kTX3HTf08oWW+X2dmfFQAJbMR1WCUuRPZr9Nn05cU=; b=PPS3/AZ/tXGq1G5as7wJAgJ163PuijIyQscsGt4grmaSFgqU7tZC6FQHv4BqDq0VW8 osQwIhvXO/yENh2xLZNOJi6sq931Y1sAhxHH+Cv6M1KpKxs8z+BQZ8dwuJoBvE78gDFI B9YGj7F6EzeSuShHWbMReZfjzsiYa/WvJeI0FIq7CXP2kdv/RfQZJsEOQ1GPiHe+pTjv N4ndEuNppRl/FTHAUXtEOqUPCyNJ51CGJdSmPqQTG11M8LphxJTBHE9Qtp8pZ0Jg/wkF ZgSP3KkcyQ/R5BF5uzoZn2S3eeoFW4AkZQcpql24qqAyw24bmD+L34jvcjkUZCBiILfX ehgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721271016; x=1721875816; h=mime-version:in-reply-to:reply-to:date:subject:cc:to:from :user-agent:references:resent-message-id:resent-date:resent-from :resent-to:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=r/kTX3HTf08oWW+X2dmfFQAJbMR1WCUuRPZr9Nn05cU=; b=dGcKumX0kEQhhfRFwGM9m7PJ8GUd6+xCqjLDyNSJvboLz9MUfp9gB5b0wYIhb29HFM P1Dk3XaRpsT987oZRAjOeWXuLNEnoQvULu38XdcrpQxrz6P4X9a4xxrPJagLkLz6lo4T BrJb/5WGYNIjcBsXJGbEMe+mGiKSMMB3PdKbM3YHoWBynf169PJ/Pv/qYtkHsTr/h0v2 Ji6434Z8ghuO44SaXuhIA0/w32bnyxHckSOzhkr0s2r1qSXr2HYL2NGahvLlrjwAzc42 fvt+xCx692xYxO/Yjw6jVKV/BNQeCdiWoRNOJFSv8mSTaREe44MtczDxLs3f5ACW6/KD Kshw== X-Forwarded-Encrypted: i=1; AJvYcCV9FQyDxU8KBM/G+PvpGC0NhNDBByKx+FhMGzXM54UAuSuQW4PPIORMTC+NCcRN3ji9ZLcR0hXckiq5KCtTlw0fI1sB1jc= X-Gm-Message-State: AOJu0YxAcgHmK3PWa2gSwx2Vq9ASDwIehzqDHsV6bjht+BYA9HYbTvdC YNnngF4ih0TUXzD1M9dBZOHCTptFkUSOD+fNOwKyhwDj/c5VtT/nBrhQYQI= X-Google-Smtp-Source: AGHT+IFfUP+atV5CjGsg1UmfqiFogFanPe4jqvBIEUmTBQFbI4ojM1Lbl/XDAD+Ew3HgEO41X+MGig== X-Received: by 2002:a05:6a21:320b:b0:1c2:8a69:338f with SMTP id adf61e73a8af0-1c40784631cmr1956961637.12.1721271015048; Wed, 17 Jul 2024 19:50:15 -0700 (PDT) Received: from Mac-mini.local ([2409:8a28:60c2:8170:52d2:f5ff:fe16:c591]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b7eca7545sm8872436b3a.153.2024.07.17.19.50.13 for (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 17 Jul 2024 19:50:13 -0700 (PDT) Message-ID: <669882e5.050a0220.8ff6d.33c6@mx.google.com> X-Google-Original-Message-ID: Received: by Mac-mini.local (Postfix, from userid 501) id 307EFE00F08D; Thu, 18 Jul 2024 10:50:08 +0800 (CST) Resent-To: Org Mode Resent-From: "Christopher M. Miles" Resent-Date: Thu, 18 Jul 2024 10:50:08 +0800 Resent-Message-ID: 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> <64c905d7.170a0220.f434a.fddb@mx.google.com> <87o7jpoqfl.fsf@localhost> <64cc9b8a.170a0220.dfa99.2e18@mx.google.com> <87msz7kym0.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.2] Re: [PATCH] add a function to only refresh inline images under current headline instead of global buffer Date: Sat, 05 Aug 2023 13:28:34 +0800 In-reply-to: <87msz7kym0.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::433; envelope-from=numbchild@gmail.com; helo=mail-pf1-x433.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.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, MSGID_MULTIPLE_AT=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=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: , 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 X-Spam-Score: -10.85 X-Migadu-Queue-Id: 035692458F X-Migadu-Scanner: mx10.migadu.com X-Migadu-Spam-Score: -10.85 X-TUID: nG75ec9C2CWB --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain Ihor Radchenko writes: > "Christopher M. Miles" writes: > >>> I think that instead of changing the existing function, we can convert >>> your patch into a new function `org-toggle-inline-images-command' that >>> will be free to alter the argument order. We can then re-bind that >>> function in org-keys to make it used by default, but only interactively. >>> >> I don't think so, the patch main purpose is for improve image refreshing >> after babel result image displaying. Because the function is hooked by >> other ob-* packages. Another purpose is headline level images displaying. >> So modifying this function is the only way. > > Fair point. > Then, for backward compatibility, we may treat any non-nil, non-list > (like '(4), '(16), '(64)), non-number (like 1, 11) value as > INCLUDE-LINKED. This way, the existing calls like > (org-toggle-inline-images t) will not be broken. > > Also, the signature should be > > (defun org-toggle-inline-images (&optional arg beg end include-linked) > > So that the meaning of the second and third argument is unchanged. > I prefer this compromise result. I updated the patch, Please review it whether it's correct. >>> As for displaying linked images, what about something like >>> >>> >>> C-1 C-c C-x C-v being equivalent of >>> C-c C-x C-v + INCLUDE-LINKED=t >>> (display in current section/region, with linked) >>> >>> and >>> >>> C-11 C-c C-x C-v being equivalent of >>> C-u C-u C-c C-x C-v + INCLUDE-LINKED=t >>> (display in the whole buffer, with linked) >>> >> Don't know, I have not use it this way. I think INCLUDE-LINKED is just a >> option argument for function org-display-inline-images. No need to be >> available for toggle in interactive command. An option like >> org-inline-images-include-linked is enough. > > Sorry, but ignoring backwards compatibility is not an option. > If you personally haven't used some feature, it does not mean that > others also didn't. > > We can make limited compromises, but should try our best not to break > things that were working before. > See https://bzg.fr/en/the-software-maintainers-pledge/ > I agree with backward compatibility is very important. I did a source code statistics researching of using the function org-toggle-inline-images at two places: - GitHub: https://github.com/search?q=org-toggle-inline-images&ref=opensearch&type=code&p=3 (Only package scimax incoke this function with INCLUDE-LINKED argument t) - My installed Emacs packages, NO package invoke this function with argument INCLUDE-LINKED. So lucky this change will not affect lot. >>>> +If cursor is on an inline image link, display the inline image. >>>> +If there is none, remove it otherwise. >>> >>> I do not quite understand what the last line is trying to say. >> >> Emmm, I forget the meaning of it. I read the docstring again, seems it >> can be deleted. I will delete it in my patch. > >> After yesterday night studying source code, I still can't figure out >> solution. So I pass this patch to you. Wait you to finish the unfinished >> part of path. > > I hope that now you have enough information to update the patch. > Let me know if not. If this patch is still not ok, really hope you can edit my patch. --=-=-= 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=20a2707a0f92c76188c3ebb412fe2b57788b50ca9a 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-keys.el | 2 +- lisp/org.el | 95 ++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 81 insertions(+), 16 deletions(-) diff --git a/lisp/org-keys.el b/lisp/org-keys.el index 38fac57d8..7b3b84af4 100644 =2D-- a/lisp/org-keys.el +++ b/lisp/org-keys.el @@ -204,7 +204,7 @@ (declare-function org-toggle-radio-button "org" (&optional arg)) (declare-function org-toggle-comment "org" ()) (declare-function org-toggle-fixed-width "org" ()) =2D(declare-function org-toggle-inline-images "org" (&optional include-link= ed beg end)) +(declare-function org-toggle-inline-images "org" (&optional arg beg end in= clude-linked)) (declare-function org-latex-preview "org" (&optional arg)) (declare-function org-toggle-narrow-to-subtree "org" ()) (declare-function org-toggle-ordered-property "org" ()) diff --git a/lisp/org.el b/lisp/org.el index e72cf056a..c01952b97 100644 =2D-- a/lisp/org.el +++ b/lisp/org.el @@ -16160,22 +16160,87 @@ 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 beg end include-linked) + "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 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...") + (let ((include-linked t)) ; assume INCLUDE-LINKED be t here for backwa= rd compatibility. + (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))= )) + ;; [M-1] / [C-1] argument for linked images like: + ;; [[https://orgmode.org/resources/img/org-mode-unicorn.svg][descriptio= n]] + ((equal arg 1) + (let ((current-prefix-arg nil) + (include-linked t)) ; assume INCLUDE-LINKED be t here for backwa= rd compatibility. + (org-toggle-inline-images nil nil nil include-linked))) + ;; 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----- iQEzBAEBCAAdFiEE8J9lDX1nSBmJJZFAG13xyVromsMFAmTN38EACgkQG13xyVro msOziQf+JRwEKAXgf0Lul4QZsc2bLrjEhB0u/puUsV7kehB76ec2Fd6rEifaa2k9 2UZmrmrSHzHNNjD9DhPI2RsZPqFqshG4vAbfk12ZacPfT5BTvhoPTSxAte2CUspA dN0ng+cjFnpQIGq02J5j4yTn85vL5q9aRcqLTghhaAPcAbfIeXEnUfSO+UG+Fn3G 9Yncahsp2c7msRWLvcVYGpQ3LBp2ByLhZ7feiGgsALTGJPyoh3Ne+AGolfiYzVY5 JPMSJ+TBD9bjenwSCtBeI+UeuMCYEjDTZ9n7heKEqF+EJ1DomjzNKZTs05g1Egto 8YfZy5gIg6aWcQIpOW4QA+butERD7w== =7tMP -----END PGP SIGNATURE----- --==-=-=--