Using DOOM EMACS

Table of Contents

1. DOOM Emacs & ORG

1.1. Why ORG?

  • Very good!
  • Very fast!
  • Very Simple!
  • Note taking made simple
  • Easily export to \(\LaTeX\) and HTML
  • Building websites
  • Serves as Jupyter Notebook but better (?)

1.2. Examples:

  • Some code:
function hmm()
    print("hmm...")
end
  • Some \(\LaTeX\):

    \begin{equation} E = mc^2 \end{equation}

1.4. DOOM Emacs ORG configuration

1.4.1. Using ORG as Jupyter notebook

The following comments are to be added to the config.el file under the .doom.d/ directory. Some of the packages that are required can be installed through M-x package-install, or manually by editing the file .doom.d/packages.el. In this tutorial, the Julia and Python languages will be taken as the example. Everything is based on the emacs package emacs-jupyter.

For the packages, the following may be installed/added to the already mentioned file:

(package! jupyter)
(package! julia-mode)

It is assumed that the file init.el has the following lines

:lang
(julia)
(org
        +babel           ; running code in org
        +jupyter)

Following to the configuration for the Jupyter notebooks, the minimal addition to config.el is

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

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

;;require and install ESS
(add-to-list 'load-path "/home/gtelo/ESS/")
(load "ess-autoloads")
  • The first block ensures the Jupyter installation and the language specific packages;
  • The second block serves to enable support for Jupyter based org source code blocks,

we add jupyter to org-babel-load-languages. It is required that the jupyter entry is added last since loading ob-jupyter depends on the value of variables such as org-src-lang-modes and org-babel-tangle-lang-exts;

  • The ESS block is Julia specific, and it is required for the current versions (I don’t recall why)

These are the minimal additions to the config.el file to have a working org-jupyter environment. With this, source code blocks with names jupyter-LANG are available to use. LANG can be any one of the kernel languages found on the system.

  • For Jupyter based source code blocks, the parameter :session is always

required. Thus, the minimal syntax would be

#+begin_src jupyter-julia :session SESSION_NAME
#+end_src
  • By default, source blocks are executed synchronously. To execute a source block asynchronously set the :async parameter to yes
  • To change the kernel, set the :kernel parameter.
#+BEGIN_SRC jupyter-julia :session SESSION_NAME :async yes :kernel julia-1.5
#+END_SRC

While its possible to always manually specify these parameters for each block, the default parameters for a language can be changed by setting org-babel-default-header-args:jupyter-LANG to an appropriate value. For example to change the defaults for the julia kernel, you can set org-babel-default-header-args:jupyter-julia to something like

(setq org-babel-default-header-args:jupyter-julia '((:session . "jl")
                                                    (:kernel . "julia-1.5")
                                                    (:async . "yes")
                                                    (:exports . "both")
                                                    (:results . "output")))

1.4.2. ORG notebooks, \(\LaTeX\), …

Author: Guilherme Telo

Created: 2022-05-03 Tue 17:45