Working setup for emacs org-mode

I am confused when reading posts that used ob-emacs or ESS. Could someone post a .emacs setup that works? The idea is to write Julia codes in emacs org-mode and run the codes there.

Thanks!

I use https://github.com/dzop/emacs-jupyter and I really like it! I don’t have my config handy, but I can post it later.

2 Likes

Thank you! Yes, please!

Here you go:

(require 'package)
(setq package-enable-at-startup nil)

(setq package-archives
      '(("GNU ELPA"     . "https://elpa.gnu.org/packages/")
        ("MELPA Stable" . "https://stable.melpa.org/packages/")
        ("MELPA"        . "https://melpa.org/packages/"))
      package-archive-priorities
      '(("MELPA Stable" . 10)
        ("GNU ELPA"     . 5)
        ("MELPA"        . 0)))

(package-initialize)

(unless (package-installed-p 'use-package)
	(package-refresh-contents)
	(package-install 'use-package))

(eval-when-compile
  (require 'use-package))

(use-package jupyter
  :ensure t
  :config
  (require 'jupyter-julia))

(setq org-src-fontify-natively t
      org-src-tab-acts-natively t
      org-confirm-babel-evaluate nil
      org-edit-src-content-indentation 0)

(org-babel-do-load-languages
 'org-babel-load-languages
 '((emacs-lisp . t)
   (jupyter . t)))

(add-to-list 'org-structure-template-alist
	     '("j" "#+BEGIN_SRC jupyter-julia :session jl
?
#+END_SRC"))

(setq org-babel-default-header-args:jupyter-julia '((:async . "yes")
						    (:exports . "both")
						    (:results . "scalar")))

This should be sufficient to have a pretty pleasant out-of-the-box Jupyter Julia experience in org mode and should auto-install the requisite packages.

I set it so that typing <j and then hitting the tab button will make a

#+BEGIN_SRC jupyter-julia :session jl

#+END_SRC

block where you can then write julia code and evaluate it C-c C-c.

2 Likes