Skip to content

Commit 447a3f4

Browse files
committed
feat: internal-link live sync (WIP)
1 parent b3f8a44 commit 447a3f4

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

org-transclusion.el

+25-10
Original file line numberDiff line numberDiff line change
@@ -1451,19 +1451,24 @@ the transcluded region is large."
14511451
(defun org-transclusion-live-sync-source-range-markers (beg end)
14521452
"Find and return source range based on transclusion's BEG and END.
14531453
Return \"(src-beg-mkr . src-end-mkr)\"."
1454-
(let ((src-buf (overlay-buffer (get-text-property (point)
1455-
'org-transclusion-pair)))
1456-
(src-search-beg (org-transclusion-find-source-marker beg end)))
1454+
(let* ((src-ov (get-text-property (point) 'org-transclusion-pair))
1455+
(src-buf (overlay-buffer src-ov))
1456+
(src-search-beg (org-transclusion-find-source-marker beg end)))
14571457
(if (not src-search-beg)
14581458
(user-error "No live-sync can be started at: %d" (point))
1459-
(with-current-buffer src-buf
1460-
(goto-char src-search-beg)
1461-
(when-let* ((src-elem (org-transclusion-live-sync-enclosing-element))
1462-
(src-beg (org-element-property :begin src-elem))
1463-
(src-end (org-element-property :end src-elem)))
1459+
(if (equal (current-buffer) src-buf)
1460+
;;; This if statement is a experiment
14641461
(cons
1465-
(move-marker (make-marker) src-beg)
1466-
(move-marker (make-marker) src-end)))))))
1462+
(move-marker (make-marker) (overlay-start src-ov))
1463+
(move-marker (make-marker) (overlay-end src-ov)))
1464+
(with-current-buffer src-buf
1465+
(goto-char src-search-beg)
1466+
(when-let* ((src-elem (org-transclusion-live-sync-enclosing-element))
1467+
(src-beg (org-element-property :begin src-elem))
1468+
(src-end (org-element-property :end src-elem)))
1469+
(cons
1470+
(move-marker (make-marker) src-beg)
1471+
(move-marker (make-marker) src-end))))))))
14671472

14681473
(defun org-transclusion-live-sync-source-content (beg end)
14691474
"Return text content between BEG and END.
@@ -1659,6 +1664,16 @@ links and IDs."
16591664
(setq tc-ov (text-clone-make-overlay beg end))))
16601665
(cons src-ov tc-ov))))
16611666

1667+
(defun org-transclusion-live-sync-buffers-org (type)
1668+
"Return cons cell of overlays for source and trasnclusion.
1669+
The cons cell to be returned is in this format:
1670+
1671+
(src-ov . tc-ov)
1672+
1673+
This function uses TYPE to identify Org files to work on only Org
1674+
links and IDs."
1675+
(when (org-transclusion-type-is-org type)))
1676+
16621677
(defun org-transclusion-live-sync-buffers-others-default (_type)
16631678
"Return cons cell of overlays for source and trasnclusion.
16641679
The cons cell to be returned is in this format:

0 commit comments

Comments
 (0)