I tried to execute an org-mode code block in octave, using the example in this SO question:

#+name: factor
#+begin_src octave :session *octave* :exports code :results silent

But I got an error:

org-babel-execute-src-block: No org-babel-execute function for octave!

I have enabled org-babel for matlab and ocatve in emacs init file as far as I can. Emacs seems to recognize .m files when loaded (The buffer is recognized as a Octave buffer).

Am I missing something in configuring org-mode for octave?

By the way, this is with the default Emacs 26 from Ubuntu 20.04 LTS. And my org-babel configuration is:

    '((emacs-lisp . t)
       (octave . t)
       (matlab . t)

and I also have this for octave mode in my init file:

;; (autoload 'octave-mode "octave-mod" nil t) ;;outdated
(setq auto-mode-alist
  (cons '("\\.m$" . octave-mode) auto-mode-alist))

(add-hook 'octave-mode-hook
          (lambda ()
            (abbrev-mode 1)
            (auto-fill-mode 1)
            (if (eq window-system 'x)
                (font-lock-mode 1))))
  • That should be enough. What happens if you say M-x load-library RET ob-octave RET?
    – NickD
    Jun 2 '20 at 12:29
  • @NickD Thanks. that seems to work: Loading ob-octave...done after M-x load-library RET ob-octave RET, and executing Octave code block (factor)... after C-c C-c. Is there a way to load-library in emacs init.el?
    – tinlyx
    Jun 2 '20 at 13:35
  • The org-babel-do-load-languages call should have done that: you should investigate why it is not effective. Do you get any messages in the Messages buffer when it is evaluated?
    – NickD
    Jun 2 '20 at 13:38
  • Also check the value of org-babel-load-languages with C-h v org-babel-load-languages RET (in a fresh invocation of emacs) and see if octave is included. Also check the value of load-path to make sure that emacs can find everything it needs to load.
    – NickD
    Jun 2 '20 at 13:42
  • @NickD Thanks. It seems that the problem is solved after I restart emacs. I guess it happened somewhere before I added the last configuration in the question.
    – tinlyx
    Jun 2 '20 at 13:45

Your Answer

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

Browse other questions tagged or ask your own question.