I have a named org-babel source block like this:
#+NAME: my-org-babel-block #+BEGIN_SRC elisp :results output (print org-babel-load-languages) #+END_SRC
Is there any way to call this block with
Stack Exchange network consists of 181 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.Visit Stack Exchange
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.Sign up to join this community
No, but you can do something like this:
#+begin_src emacs-lisp (defun my-org-babel-block () (interactive) (org-sbe "my-org-babel-block")) #+end_src
defining a command (i.e. a function with an
interactive spec) that executes the block with the given name. You can now call the command with
M-x my-org-babel-block which will use
org-sbe to execute the block.
The doc string of
org-sbe (which you can get with
C-h f org-sbe RET) says in part:
org-sbe is a Lisp macro in ‘ob-table.el’.
(org-sbe SOURCE-BLOCK &rest VARIABLES)
Return the results of calling SOURCE-BLOCK with VARIABLES.
Each element of VARIABLES should be a list of two elements: the first element is the name of the variable and second element is a string of its value.
org-sbeexecutes a code block - it doesn't care what language the code block is in.
my-org-babel-block. Dec 7, 2020 at 21:52