0

I've recently started creating notes with org mode... I'd like to understand better what do I have to do in order to execute code with it... Let's say I've created the following code.org file:

#+BEGIN_SRC python
  print('test')
#+END_SRC

#+BEGIN_SRC bash
  echo "test"
#+END_SRC

#+BEGIN_SRC node
  console.log("test")
#+END_SRC

I'd like to be able to execute codes in different programming languages in blocks, I'm not completely sure if that's the right way of doing it, when I try to execute any of those blocks with C-c C-c I receive an error message saying no org-babel-execute function for python (node and bash are the same). I've tried to check the command list-packages to see if I could install an org mode for them but I didn't find anything specific for org-mode with those languages... What am I missing? Can I execute any programming language that I can execute on the command line with org mode? What extra steps do I need to do in order to start executing code in org mode?


Different attempt

I've also seen this answer in a simular question where the answer instructs to use the following to make a C code execute:

(org-babel-do-load-languages
 'org-babel-load-languages '((C . t)))

Then I tried putting the following on my .emacs file:

(org-babel-do-load-languages
 'org-babel-load-languages '((bash . t)))

But it also doesn't work and emacs indicates the error File is missing: Cannot open load file, No such file or directory, ob-bash...

raylight
  • 217
  • 8

1 Answers1

2

For using bash you should add (shell . t), otherwise I think you are doing alright.

You can find which 'org babel' files are available by doing M-x find-library RET ob- and pressing TAB.

I guess for node you should use ob-js (add (js . t)). You might have to set which executable to use.

You can find customization options using M-x customize-group org-babel.

dalanicolai
  • 6,108
  • 7
  • 23
  • Cool, I managed to execute with those three languages now. However, I can't find `ob-js`, `ob-python` or `ob-shell` with `M-x list-packages` or `M-x find-library ob-` `TAB`... I'm assuming they already exist with the emacs installation. Is there any way of knowing which values exist for me to use inside `org-babel-load-languages`? – raylight Oct 20 '22 at 14:52
  • I guess there was a misunderstanding, did you try to press `RET` first after `M-x find-library`? (that's why I added the space between that and `ob-`, I have edited the answer now) – dalanicolai Oct 20 '22 at 19:15