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

    refac(src): search-option ::number and ::/regexp/ are limitations
    
    Now in theory both work (and are working), only ::number makes sense.
    ::/regepxp/ opens an occur buffer for users to interact, which requires user
    interaction. The source buffer is open behind the occur buffer but the point
    does not move. Thus... ::/regexps/ is no longer a limitation; it's 
functionally
    working but Org-transclusion does not interact with the occur buffer.
---
 org-transclusion-src-lines.el | 27 ++++++++-------------------
 test/test-2.0.org             | 12 +++++++++++-
 2 files changed, 19 insertions(+), 20 deletions(-)

diff --git a/org-transclusion-src-lines.el b/org-transclusion-src-lines.el
index cc443c0c7c..5b58d78c5e 100644
--- a/org-transclusion-src-lines.el
+++ b/org-transclusion-src-lines.el
@@ -135,10 +135,8 @@ omitted (e.g. -10), it means from the beginning of the 
file to
 line 10. Likewise, when the second number is omitted (e.g. 10-),
 it means from line 10 to the end of file."
   (let* ((src-mkr (org-transclusion-add-target-marker link))
-         (path (org-element-property :path link))
          (search-option (org-element-property :search-option link))
          (type (org-element-property :type link))
-         (entry-pos)
          (buf (and src-mkr (marker-buffer src-mkr)))
          (lines (plist-get plist :lines))
          (end-search-op (plist-get plist :end))
@@ -146,27 +144,18 @@ it means from line 10 to the end of file."
          (thing-at-point (plist-get plist :thing-at-point))
          (thing-at-point (when thing-at-point
                            (make-symbol (cadr (split-string 
thing-at-point))))))
-    (if (not (string= type "id"))
-        buf
-      (let ((filename-pos (org-id-find path)))
-        (setq buf (find-file-noselect (car filename-pos)))
-        (setq entry-pos (cdr filename-pos))))
     (when buf
       (with-current-buffer buf
         (org-with-wide-buffer
          (let* ((start-pos (cond
-                            (entry-pos)
-                            ((when search-option
-                               (save-excursion
-                                 (if noweb-chunk
-                                     
(org-transclusion--goto-noweb-chunk-beginning search-option)
-                                   (ignore-errors
-                                     ;; FIXME `org-link-search' does not
-                                     ;; return position when eithher
-                                     ;; ::/regex/ or ::number is used
-                                     (if (org-link-search search-option)
-                                       (line-beginning-position)))))))
-                            ((point-min))))
+                            ;; org-element only finds search-option only when
+                            ;; type=file. This condition is only for noweb now
+                            ((and (equal type "file") search-option 
noweb-chunk)
+                             (save-excursion
+                               (org-transclusion--goto-noweb-chunk-beginning 
search-option)))
+                            ;; for others, non-file types, assume that the
+                            ;; position in the marker is the intended point
+                            (t (marker-position src-mkr))))
                 (bounds (when thing-at-point
                           (let ((count (if end-search-op
                                            (string-to-number end-search-op) 
1)))
diff --git a/test/test-2.0.org b/test/test-2.0.org
index 47d9704d31..6b73df5ab3 100644
--- a/test/test-2.0.org
+++ b/test/test-2.0.org
@@ -39,6 +39,12 @@ ID with "first section" [[id:2022-06-26T152831]]
 
 #+transclude: [[id:2022-06-26T152831]]
 
+** org-id with lines
+
+   [[id:2022-10-10T173507::*H2]]
+
+#+transclude: [[id:2022-10-10T173507::*H2]]  :lines 1-5
+
 ** test empty file
 #+transclude: [[file:empty.txt::2][empty text file]]
 
@@ -51,6 +57,10 @@ ID with "first section" [[id:2022-06-26T152831]]
 
    #+transclude: [[file:test.txt][text file]]
 
+   #+transclude: [[file:test.txt::3]]  :lines 1-1
+
+   #+transclude: [[file:test.txt::/Gab/]]  :lines 1-1
+
    #+transclude [[file:test.txt][text file]]
 
    #+trans [[file:test.txt][text file]]
@@ -122,8 +132,8 @@ Temporarily set ~org-transclusion-include-first-section~ to 
nil
 * Orgit-file (link to git rev)
 
   [[orgit-file:~/src/org-transclusion/::main::org-transclusion.el::Last 
modified][Orgit-file link to main]]
-#+transclude: 
[[orgit-file:~/src/org-transclusion/::main::org-transclusion.el::Last 
modified][Orgit-file link to main]]  :lines 1- :src emacs-lisp :end "URL"
 
+#+transclude: 
[[orgit-file:~/src/org-transclusion/::main::org-transclusion.el::Last 
modified][Orgit-file link to main]]  :lines 1- :src emacs-lisp :end "URL"
 
 * Live-Sync
 ** center-block dynamic-block example-block export-block special-block 
verse-block

Reply via email to