From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.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 kE7dAnb7mWc3NgEA62LTzQ:P1 (envelope-from ) for ; Wed, 29 Jan 2025 09:57:10 +0000 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id kE7dAnb7mWc3NgEA62LTzQ (envelope-from ) for ; Wed, 29 Jan 2025 10:57:10 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=OLHro9bb; 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-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=OLHro9bb; 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=1738144627; a=rsa-sha256; cv=none; b=cGy+4JrG2JeK3iwoRbyMaYzWirEixoueo2iA8fX8jUnuMYnKR4U3U8jAQRbeqAcubE4mtL 16thzUQ7vFNwapxGoI+zS6JpEXS2lu67rJdTdfAbeDKzQUP/eVo1YkkkhqnEb10su0SYBy ByY97QSDUhwsGkGLczwuEq7GL33CNFsX2JE7aKUy6o4PZb0sCZjzCHdKOAndAxkqbWuius Uhmr5Zi1obnRwlEzh7k7mAw7ogjHbksxo4jlIZ3rGIb6jfqPgHbmr2cBPVl/SCLq5Ex4Wa 7yPgyJtI82VRvudv9rjdVNE+AkU6yn7I+QBwq6hP5KmLZFC1mg2gSHrmzHWAWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1738144627; h=from:from:sender:sender: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=5dnuVJl8hxHblnLc4ulKoTpCUNI9hbGsJ747Jy6FlAA=; b=ahm4UI9hfYpQZtqISeIvfphzVl+yK1plLh2JcgXupJKDKikWuyAVwaMBAd9WQ0j79oVNmD isQvTUJ84SWFBk5tfYAMBDiZ1bMm3sLBq17ulXYuh2tnsm4e2H8L74j7+qobgGv4uzjf3Z r6cnmTR480w+IJuRGGxJUKABHyq5zEn8+wyHH3upeNtZBV7IE19RycUZ7fgl7sdLiLwQdE P9wbp+fcbzY6pv2TNfv0zlQjnVqhq2PTJZyjB/eg9Iexns39Z5J+4QibK1rBG9b8uYTBgN TRV/bf5P5FHnDmfvfSLxqqwqkkKo8wV0OtfoX6yv6Vy8Qg6eRDfbJvog8ncrUA== 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 ACBA41AEBF for ; Wed, 29 Jan 2025 10:57:07 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1td4ny-0003qU-6l; Wed, 29 Jan 2025 04:56:21 -0500 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 1td4ne-0003le-LJ for emacs-orgmode@gnu.org; Wed, 29 Jan 2025 04:55:58 -0500 Received: from mail-lj1-x22d.google.com ([2a00:1450:4864:20::22d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1td4nc-0001FN-Ck for emacs-orgmode@gnu.org; Wed, 29 Jan 2025 04:55:58 -0500 Received: by mail-lj1-x22d.google.com with SMTP id 38308e7fff4ca-303548a9361so54941571fa.0 for ; Wed, 29 Jan 2025 01:55:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738144551; x=1738749351; darn=gnu.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=5dnuVJl8hxHblnLc4ulKoTpCUNI9hbGsJ747Jy6FlAA=; b=OLHro9bbNVH/+dBSUCjZBWpsqCW3i/IXuhQvOE63mx7dTC1zBJrWFkf/FJW6DJ057t ip39VbYW5ybSiXKPcUxK4rUO/QeRzwpdm+0fhGAc0h+pcuZhqur6D+F20eZdLRYr5pqC Fzfaq7/gsbIoZ8uZ/UnaIIhdUeZPdZbna/B1snSC0ZI8LoKdEaoG1FFpsjdvQOEYXUuB Mi4Tl6ZRoYjNSW+Ip5NsCGyuBYVc+NLHG8nyAXpRVmUkBlI+sN44xN7HgJg6tx/6+pb3 pjT/kDzEnvs8N54S42Sz1s4TvnsWB9+FJ9Vwr1DTZ7o/h2nKt4htHwppIRezofi9XE5p oBww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738144551; x=1738749351; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=5dnuVJl8hxHblnLc4ulKoTpCUNI9hbGsJ747Jy6FlAA=; b=wyDH5pkzfz8gJ2ENgciFHF2pDRDl7y4JAHlfnjC2fNIKJXv2OtdhWa8nkRc9GLqAh4 rWqCh2SH4/lrNb9hH4iWpnre8h1fQinAbLHBxldk0KMQfz8HuWT0O0/S/1YDE5Q2GH0z uWwOiqiHM2PI7Q2T8tq3oJ417PtdKFTH3jRv5NKDxxq0DBhZV07g3+sLaTioZOfQTtdI vuGaXfGDX5yq9WekTv72RorwvsFND0niQJG45RdGYC2uLgd3xedLHLrynNv08lFvYzVb iCNbC/ELC25BRhBVK2GqSKVs5xZqH/TTQFZNB8lCg9Yc8IDuQLHkdypsjcH52CFqRODF jVSw== X-Gm-Message-State: AOJu0Yy/+K5IKOamFUPVpSMNNjESd7IGgP+yDny/PIuqwS0kRhARFJg7 zvcWbFeNrlXkaPTAesJbYWaZymGJQLf/CknDmGkdgHmc5PrDjOj8D9BG/szq9yEBaQa8K5X6PM3 +1DmPTbAXUAhc5KDcwP1bqvNtEojcjrmkIA== X-Gm-Gg: ASbGncsG0yYm4uzA62ZgOSoQ16EZZJuYLjitp5Z1FArgM14VATOPgMhMTQtTE8O2/41 GObSdWLLGqS2+ObHD/Uf0mJdSKfyulgUeijQiqX38Rd6PaFBMFJONPPKrc80auXBc3sWOGrM= X-Google-Smtp-Source: AGHT+IGk2ldF/zxUTCPhr+BnnJAZBe9rAp8T26a4EmPKFEErqpuvKatNVz2lR3cZo+MycovPO5tW2HWMu7lkORxBXI4= X-Received: by 2002:a2e:bc24:0:b0:302:1861:6de7 with SMTP id 38308e7fff4ca-307968e0bc1mr8008191fa.24.1738144550575; Wed, 29 Jan 2025 01:55:50 -0800 (PST) MIME-Version: 1.0 From: stardiviner Date: Wed, 29 Jan 2025 17:55:23 +0800 X-Gm-Features: AWEUYZkVH_H1IJPtt594bOsJusquyufLZKu0AYqbyEriWfZPADZyed-IuLMUzpA Message-ID: Subject: [PATCH] The function `org-link-preview-region` should detect whether already has overlay. To: Org-mode Content-Type: multipart/alternative; boundary="000000000000816975062cd55074" Received-SPF: pass client-ip=2a00:1450:4864:20::22d; envelope-from=numbchild@gmail.com; helo=mail-lj1-x22d.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, HTML_MESSAGE=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: , 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: -7.75 X-Spam-Score: -7.75 X-Migadu-Queue-Id: ACBA41AEBF X-Migadu-Scanner: mx10.migadu.com X-TUID: tB/b/oOn5034 --000000000000816975062cd55074 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable When headline cycle expanding on STATE is `subtree` in function `org-cycle-display-link-previews`, assume I have org-mode content like bellowing: #+begin_src org ** TODO iamtxt.com DEADLINE: <2025-01-17 Fri> :LOGBOOK: - State "TODO" from [2025-01-17 Fri 00:19] :END: https://www.iamtxt.com/book/47744.html https://www.iamtxt.com/book/47681.html *** kk https://www.iamtxt.com/book/41334.html https://www.iamtxt.com/book/42259.html #+end_src The first two links will be previewed twice. (I use package "org-link-beautify.el" which display icon on link. Then it will link previewing with two icons.) So checked source code in `org-link-preview-region`. It should check whether already has org-mode link preview overlay. For example, adding a condition outside of the `while-let*` binding code. #+begin_src diff modified =EE=98=B2 lisp/ol.el @@ -2056,25 +2056,26 @@ buffer boundaries with possible narrowing." ;; Collect links to preview (while (re-search-forward org-link-any-re end t) (forward-char -1) ;ensure we are on the link - (when-let* - ((link (org-element-lineage (org-element-context) 'link t)) - (linktype (org-element-property :type link)) - (preview-func (org-link-get-parameter linktype :preview)) - (path (and (or include-linked - (not (org-element-contents-begin link))) - (org-element-property :path link)))) - ;; Create an overlay to hold the preview - (let ((ov (make-overlay - (org-element-begin link) - (progn - (goto-char - (org-element-end link)) - (unless (eolp) (skip-chars-backward " \t")) - (point))))) - (overlay-put ov 'modification-hooks - (list 'org-link-preview--remove-overlay)) - (push ov org-link-preview-overlays) - (push (list preview-func ov path link) preview-queue)))) + (unless (overlays-at (point)) ;; <-------------- Added condition here. (I think the condition can be more explicit detect on org-mode link preview property detection) + (when-let* + ((link (org-element-lineage (org-element-context) 'link t)) + (linktype (org-element-property :type link)) + (preview-func (org-link-get-parameter linktype :preview)) + (path (and (or include-linked + (not (org-element-contents-begin link))) + (org-element-property :path link)))) + ;; Create an overlay to hold the preview + (let ((ov (make-overlay + (org-element-begin link) + (progn + (goto-char + (org-element-end link)) + (unless (eolp) (skip-chars-backward " \t")) + (point))))) + (overlay-put ov 'modification-hooks + (list 'org-link-preview--remove-overlay)) + (push ov org-link-preview-overlays) + (push (list preview-func ov path link) preview-queue))))) ;; Collect previews in buffer-local LIFO preview queue (setq org-link-preview--queue (nconc (nreverse preview-queue) org-link-preview--queue)) #+end_src [stardiviner] GPG key ID: 47C32433 IRC(freeenode): stardiviner Twitter: @numbchild Key fingerprint =3D 9BAA 92BC CDDD B9EF 3B36 CB99 B8C4 B8E5 47C3 2433 Blog: http://stardiviner.github.io/ --000000000000816975062cd55074 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
When headline cycle expanding on STATE is= `subtree` in function `org-cycle-display-link-previews`, assume I have org= -mode content like bellowing:

#+begi= n_src org
** TODO iamtxt.com=
DEADLINE: <2025-01-17 Fri>
:LOGBOOK:
- State "TODO= " =C2=A0 =C2=A0 =C2=A0 from =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0[2025-01-17 Fri 00:19]
:END:

https://www.iamtxt.com/book/47744.html
https://www.iamtxt.com/book/476= 81.html

*** kk

https://www.iamtxt.com/book/41334.html
https://www.iamtxt.com/book/42259.html
#+end_src

The first = two links will be previewed twice. (I use package "org-link-beautify.e= l" which display icon on link. Then it will link previewing with two i= cons.)

So checked source code in `or= g-link-preview-region`. It should check whether already has org-mode link p= review overlay.

For example, adding = a condition outside of the `while-let*` binding code.

=
#+begin_src diff
modified =C2=A0 =EE=98= =B2 lisp/ol.el
@@ -2056,25 +2056,26 @@ buffer boundaries with possible n= arrowing."
=C2=A0 =C2=A0 =C2=A0 =C2=A0;; Collect links to preview=C2=A0 =C2=A0 =C2=A0 =C2=A0(while (re-search-forward org-link-any-re end = t)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(forward-char -1) =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ;ensure we are on the link
- =C2=A0 =C2= =A0 =C2=A0 =C2=A0(when-let*
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(= (link (org-element-lineage (org-element-context) 'link t))
- =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (linktype (org-element-property :type li= nk))
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (preview-func (org-link= -get-parameter linktype :preview))
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 (path (and (or include-linked
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(not (org= -element-contents-begin link)))
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(org-element-property :path li= nk))))
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0;; Create an overlay to hold = the preview
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(let ((ov (make-overlay<= br>- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = (org-element-begin link)
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 (progn
- =C2=A0 =C2=A0 =C2=A0 (goto-char
-= (org-element-end link))
- =C2=A0 =C2=A0 =C2=A0 (unless (eolp) (skip= -chars-backward " \t"))
- =C2=A0 =C2=A0 =C2=A0 (point)))))- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(overlay-put ov 'modificat= ion-hooks
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 (list 'org-link-preview--remove-overlay))
-= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(push ov org-link-preview-overlay= s)
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(push (list preview-func o= v path link) preview-queue))))
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0(unless (ove= rlays-at (point)) ;; <-------------- Added condition here. (I think the = condition can be more explicit detect on org-mode link preview property det= ection)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(when-let*
+ =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0((link (org-element-lineage (org-elem= ent-context) 'link t))
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 (linktype (org-element-property :type link))
+ =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (preview-func (org-link-get-parameter linkt= ype :preview))
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (path = (and (or include-linked
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(not (org-elemen= t-contents-begin link)))
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(org-element-property :path li= nk))))
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0;; Create an overlay t= o hold the preview
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(let ((ov = (make-overlay
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 (org-element-begin link)
+ =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (progn
+ =C2=A0 = =C2=A0 =C2=A0 =C2=A0 (goto-char
+ =C2=A0(org-element-end link))
+ = =C2=A0 =C2=A0 =C2=A0 =C2=A0 (unless (eolp) (skip-chars-backward " \t= "))
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 (point)))))
+ =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(overlay-put ov 'modification-hooks+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 (list 'org-link-preview--remove-overlay))
+ =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(push ov org-link-preview-over= lays)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(push (list prev= iew-func ov path link) preview-queue)))))
=C2=A0 =C2=A0 =C2=A0 =C2=A0;; = Collect previews in buffer-local LIFO preview queue
=C2=A0 =C2=A0 =C2=A0= =C2=A0(setq org-link-preview--queue
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0(nconc (nreverse preview-queue) org-link-preview--queue))
#+end_src


=
[stardiviner]=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 <Hack this world!>=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 GPG key ID: 47C32433
IRC(freeenode): stardiviner = =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 Twitter:=C2=A0 @numbchild
Key fi= ngerprint =3D 9BAA 92BC CDDD B9EF 3B36=C2=A0 CB99 B8C4 B8E5 47C3 2433
Bl= og: http://star= diviner.github.io/
--000000000000816975062cd55074--