org-transclusion icon indicating copy to clipboard operation
org-transclusion copied to clipboard

Allow linking directly to source blocks

Open ParetoOptimalDev opened this issue 2 years ago • 1 comments

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.

ParetoOptimalDev avatar Mar 06 '23 05:03 ParetoOptimalDev

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.

nobiot avatar Mar 08 '23 17:03 nobiot