5

I'm a big fan of supporting as many languages as possible. In particular, I wouldn't like to exclude support for any particular language from org-babel. (Who knows? Maybe I'll need to write some Fortran one day.) However, I know that loading support for all of the available languages at once can be painful.

Is there any way for org-babel to load support for languages when I actually try to use a code block with that language?

EDIT: org-babel-execute-src-block is probably the function that needs to be advised.

4

This seems to do it for me:

#+BEGIN_SRC emacs-lisp
(defadvice org-babel-execute-src-block (around load-language nil activate)
  "Load language if needed"
  (let ((language (org-element-property :language (org-element-at-point))))
    (unless (cdr (assoc (intern language) org-babel-load-languages))
      (add-to-list 'org-babel-load-languages (cons (intern language) t))
      (org-babel-do-load-languages 'org-babel-load-languages org-babel-load-languages))
    ad-do-it))
#+END_SRC

At least, it worked for gnuplot (after I installed the gnuplot package and executable).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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