# How to do transclusion to org-files as fast as possible?

**URL:** <https://org-roam.discourse.group/t/how-to-do-transclusion-to-org-files-as-fast-as-possible/3002>\
**Category:** How To\
**Created:** [February 28, 2023, 6:54am UTC](https://org-roam.discourse.group/t/how-to-do-transclusion-to-org-files-as-fast-as-possible/3002 "2023-02-28T06:54:05Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![FFS](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/ffs/32/1286_2.png) [@FFS](https://org-roam.discourse.group/u/FFS)\
**Post date:** [February 28, 2023, 6:54am UTC](https://org-roam.discourse.group/t/how-to-do-transclusion-to-org-files-as-fast-as-possible/3002/1 "2023-02-28T06:54:05Z")

</div>

I wonder what people in org-roam community conveniently use to get transclusion job done as fast as possible.  
Say I have a `source.org` buffer with 50 lines of text and `target.org` buffer ready to receive the transclusion. My current workflow is while I am in the source buffer I hit `C-u C-c l` org-store-link to get a link to the source buffer NAME then I move to the target buffer and hit `tx TAB` this will invoke a yasnippet completion to:  
#+transclude : [pointer-will-be-positioned-here-waiting] :lines

then at where pointer sits I hit C-c C-l (org-insert-link), then I specify the lines to be transcluded like :lines 22-22 (yes this is how to transclude one line).

First off, is there an easier way to do it?

Second, I don’t like it when org-store-link fetches org buffer name, it would be much better if it could fetch org-id of the current node, because in org-roam it is much better to do connections using the node IDs. So how to get org-store-link get the ID of the node rather than the name of it?

Third, may be in org-roam there is an easy way, I am still unaware of, to always fetch the id of the current buffer, which would be then usefully exploited to do the desired transclude. There is a function `org-roam-node-at-point` to get elisp structure of the node, but this requires some elisp skill to make use of it, unfortunately it’s not my venue.  
It would be nice to see a function that fetches the id from the output of the function above and concatenate it with `[[id:<number>]]`.

---

<div class="post-metadata">

**Author:** ![nobiot](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/nobiot/32/159_2.png) [@nobiot](https://org-roam.discourse.group/u/nobiot)\
**Post date:** [February 28, 2023, 7:44am UTC](https://org-roam.discourse.group/t/how-to-do-transclusion-to-org-files-as-fast-as-possible/3002/2 "2023-02-28T07:44:27Z")

</div>

Either `org-id-store-link` and then `org-insert-link`, or `org-roam-node-insert` to insert an ID link, followed by `org-transclusion-make-from-link`.

I think you can create a custom function to insert and make link in one go. I thought there was an issue in the repository where I suggested the same thing, but I cannot locate it at the moment.

---

<div class="post-metadata">

**Author:** ![FFS](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/ffs/32/1286_2.png) [@FFS](https://org-roam.discourse.group/u/FFS)\
**Post date:** [March 4, 2023, 7:43am UTC](https://org-roam.discourse.group/t/how-to-do-transclusion-to-org-files-as-fast-as-possible/3002/3 "2023-03-04T07:43:42Z")

</div>

Hi @nobiot Thanks a lot for these valuable info. I am now trying to experiment with your suggestions to get the most efficient way to do it. By the way I discovered a gem function `org-id-get-create` in org-mode (always fascinating):

> It is bound to C-c i d.
> 
> (org-id-get-create &optional FORCE)
> 
> Create an ID for the current entry and return it.  
> If the entry already has an ID, **just return it**.  
> With optional argument FORCE, force the creation of a new ID.

But unfortunately, what is getting in the way, is a minor thing, the IDs of org-roam nodes are just NOT UNDER AN ENTRY (heading entry), there must be an entry so that `C-c i d` can do its job. Just to share my little disappointment.

---

<div class="post-metadata">

**Author:** ![FFS](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/ffs/32/1286_2.png) [@FFS](https://org-roam.discourse.group/u/FFS)\
**Post date:** [March 4, 2023, 7:51am UTC](https://org-roam.discourse.group/t/how-to-do-transclusion-to-org-files-as-fast-as-possible/3002/4 "2023-03-04T07:51:34Z")

</div>

> [@nobiot](#):
>
> Either `org-id-store-link` and then `org-insert-link`

when I do `org-insert-link` I am constantly getting prompted to enter values? What variant of links you pick? `roam:` , `id:`, `file:`, those I have tried to no avail. Neither I got org-id copied to the kill-ring (clipboard) by `org-id-store-link`.

---

<div class="post-metadata">

**Author:** ![FFS](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/ffs/32/1286_2.png) [@FFS](https://org-roam.discourse.group/u/FFS)\
**Post date:** [March 4, 2023, 8:05am UTC](https://org-roam.discourse.group/t/how-to-do-transclusion-to-org-files-as-fast-as-possible/3002/5 "2023-03-04T08:05:04Z")

</div>

> [@nobiot](#):
>
> or `org-roam-node-insert` to insert an ID link, followed by `org-transclusion-make-from-link`.

This works great. However, in my humble opinion, when I do `org-transclusion-make-from-link` I didn’t like the effect of IMMEDIATELY doing the transclusion into the buffer when the org-transclusion-mode is on (which is almost the case) because my buffer get cluttered so fast causing a bit of inconvenience. I would like to have the default to just show the transclusion keyword and the link, that’s it, because at this point, I would rather pick some lines to be transcluded and not everything. This is true when you are doing transclusion to a reference node buffer, where I have many notes (org-noter entries) for a PDF. So the desired behavior for `org-transclusion-make-from-link` to just put the keyword and stop right there, to allow the user at this point to decide whether to go with everything or pick some lines and add some other options (mostly the case). As such, I am left with one inconvenient option: to disable `org-transclusion-mode` before doing `org-transclusion-make-from-link` to get the desired effect.

---

<div class="post-metadata">

**Author:** ![nobiot](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/nobiot/32/159_2.png) [@nobiot](https://org-roam.discourse.group/u/nobiot)\
**Post date:** [March 4, 2023, 1:11pm UTC](https://org-roam.discourse.group/t/how-to-do-transclusion-to-org-files-as-fast-as-possible/3002/6 "2023-03-04T13:11:46Z")

</div>

> [@FFS](#):
>
> NOT UNDER AN ENTRY (heading entry), there must be an entry so that `C-c i d` can do its job. Just to share my little disappointment.

> [@FFS](#):
>
> when I do `org-insert-link` I am constantly getting prompted to enter values? What variant of links you pick? `roam:` , `id:`, `file:`

You can check the value of variable `org-id-link-to-org-use-id` and use `org-store-link` instead. It should work (and works on my end) when the ID is for the file before the first headline.

> [@FFS](#):
>
> As such, I am left with one inconvenient option: to disable `org-transclusion-mode` before doing `org-transclusion-make-from-link` to get the desired effect.

I have pushed [this fix](https://github.com/nobiot/org-transclusion/commit/be1a4984a58f47d2c51cfe2175ff34fda5e7dfdd) now; you should be able to use `universal-argument` in the way that makes sense to you (and I believe for others).

---

<div class="post-metadata">

**Author:** ![FFS](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/ffs/32/1286_2.png) [@FFS](https://org-roam.discourse.group/u/FFS)\
**Post date:** [March 4, 2023, 7:17pm UTC](https://org-roam.discourse.group/t/how-to-do-transclusion-to-org-files-as-fast-as-possible/3002/7 "2023-03-04T19:17:05Z")

</div>

> [@nobiot](#):
>
> You can check the value of variable `org-id-link-to-org-use-id` and use `org-store-link` instead. It should work (and works on my end) when the ID is for the file before the first headline.

Yep. It was set to `'use-existing` not set to `nil` and it works now. Thanks.

> [@nobiot](#):
>
> I have pushed [this fix](https://github.com/nobiot/org-transclusion/commit/be1a4984a58f47d2c51cfe2175ff34fda5e7dfdd) now; you should be able to use `universal-argument` in the way that makes sense to you (and I believe for others).

Oh, super fast! Sir, excuse me this is the first feature request to a package author I have seen so fast responded in my life. Thank You.
