branch: externals/org-transclusion
commit c514b35e09dcf16215e8922fda3cd117523138b6
Author: Noboru Ota <[email protected]>
Commit: Noboru Ota <[email protected]>

    chg: Add support Org-id with search option `[[id:<id>::heading title]]`
---
 org-transclusion.el | 12 +++++++++---
 test/test-2.0.org   |  6 +++++-
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/org-transclusion.el b/org-transclusion.el
index b1c271b4f4..f06d2da7c5 100644
--- a/org-transclusion.el
+++ b/org-transclusion.el
@@ -17,7 +17,7 @@
 
 ;; Author:        Noboru Ota <[email protected]>
 ;; Created:       10 October 2020
-;; Last modified: 02 January 2025
+;; Last modified: 03 January 2025
 
 ;; URL: https://github.com/nobiot/org-transclusion
 ;; Keywords: org-mode, transclusion, writing
@@ -942,13 +942,19 @@ hooks in `org-transclusion-add-functions'."
         (run-hook-with-args 'org-transclusion-after-add-functions beg end))
       t)))
 
+(defun org-transclusion-id-marker (path)
+  (save-selected-window
+    (org-id-open path nil)
+    ;; In the target buffer temporarily
+    (move-marker (make-marker) (point))))
+
 (defun org-transclusion-add-org-id (link plist)
   "Return a list for Org-ID LINK object and PLIST.
 Return nil if not found."
   (when (string= "id" (org-element-property :type link))
     ;; when type is id, the value of path is the id
-    (let* ((id (org-element-property :path link))
-           (mkr (ignore-errors (org-id-find id t)))
+    (let* ((path (org-element-property :path link))
+           (mkr (ignore-errors (org-transclusion-id-marker path)))
            (payload '(:tc-type "org-id")))
       (if mkr
           (append payload (org-transclusion-content-org-marker mkr plist))
diff --git a/test/test-2.0.org b/test/test-2.0.org
index 230b2b9a20..8292ce025e 100644
--- a/test/test-2.0.org
+++ b/test/test-2.0.org
@@ -2,6 +2,11 @@
 ** make from link
 This is a link to a [[id:2022-05-30T203553][Bertrand Russell]] wikipedia 
excerpt
 #+transclude: [[id:2022-05-30T203553][Bertrand Russell]]
+
+#+transclude: [[id:2022-10-10T173507::*H2]]
+
+[[id:2022-10-10T173507::*H2]]
+
 ** test empty file
 #+transclude: [[file:empty.txt::2][empty text file]]
 
@@ -199,4 +204,3 @@ Temporarily set ~org-transclusion-include-first-section~ to 
nil
   # id-1234 end here
   return fname # return this to org-mode
 #+end_src
-

Reply via email to