nobiot / org-transclusion

Emacs package to enable transclusion with Org Mode
https://nobiot.github.io/org-transclusion/
GNU General Public License v3.0
917 stars 44 forks source link

Allow linking directly to source blocks #173

Open ParetoOptimalDev opened 1 year ago

ParetoOptimalDev commented 1 year ago

This would make it easier than it currently is without live sync for source blocks because jumping to them would be easier.

Currently I just jump to the headline transcluded calling org-transclusion-open-source and then call org-babel-next-src-block.

It could be done by supporting #31 and using (ref:some-name) links like in this somewhat(?) contrived example:

* core packages
** git

#+name: src
#+begin_src nix -r
git  (ref:git-src)
#+end_src

* emacs
** magit
*** depends on

#+transclude: [[(git-src)]] :level 4

* nix
** depends on

#+transclude: [[(git-src)]] :level 3

* local vars
# Local Variables:
# org-id-method: org
# org-open-link-functions: nil
# End:

Note the -r is from https://orgmode.org/manual/Literal-Examples.html and strips out the ref syntax.

nobiot commented 1 year ago

I think #+transclude: [[./file-name.org::src]] would work for your case. It looks like the same case as this issue; the only difference is that it is about LaTeX equation block whereas your case is a source code block.

But if you do this, :level property will be meaningless as you would directly transclude a source block, not a subtree -- you would need to add a headline separately in the target file.