I would like to have a link that runs a Babel source-code block. Does Org-mode support running something from the library of babel in a link, or a source block via a file+blockname reference? A Hyperbole button would also be acceptable.

2 Answers 2


You can easily define your own link type that runs source blocks:

 :follow #'org-babel-ref-resolve)

Afterwards a click on run:hello executes the source block in the following Orgmode file.

#+name: hello
#+begin_src emacs-lisp :var n=1
(message "Hello. n=%s" n)

#+RESULTS: hello
: Hello


  • Hi @Tobias. Is it possible to also pass an argument in the link? For example run:hello(n=2)? I'm not good enough with elisp to figure it out. Any help is very welcome.
    – Ajned
    Commented Apr 24, 2020 at 17:39
  • 2
    @Andre I have edited the answer. The new version should also allow source block header arguments as you want to apply them.
    – Tobias
    Commented Apr 24, 2020 at 21:07
  • Thank you. It works perfectly. I would never have been able to find the function org-babel-ref-resolve on my own. Thanks again
    – Ajned
    Commented Apr 24, 2020 at 21:13

The usual way to do this is like this:

#+name: mysum
#+BEGIN_SRC emacs-lisp
(+ 5 5)

#+call: mysum()

: 10

I am not sure what the point of doing this in a link would be, where would the results go for example?

You can make a link like this: [[elisp:(progn (org-babel-goto-named-src-block "mysum") (org-babel-execute-src-block-maybe))]]

which will jump to that block and run it.

  • My goal is to create a dashboard for phone SSH sessions. Clicking on links makes it easier. Commented Jun 13, 2019 at 0:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.