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 M-x my-org-babel-block
?
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 communityNo, 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-sbe
executes a code block - it doesn't care what language the code block is in.
my-org-babel-block
.
Dec 7, 2020 at 21:52