Configure Everything with Org Babel

Org Babel

Execution: C-c C-c (output, value results)

Org Babel Documentation Org Babel: Languages

  '((emacs-lisp . t)
    (python . t)))

(setq org-confirm-babel-evaluate nil)

Structure Templates

;; This is needed as of Org 9.2
(require 'org-tempo)

(add-to-list 'org-structure-template-alist '("sh" . "src shell"))
(add-to-list 'org-structure-template-alist '("el" . "src emacs-lisp"))
(add-to-list 'org-structure-template-alist '("py" . "src python"))

Setting Up the Config

Apply the same configuration to every block:

Tangling Output

(org-babel-tangle-file "~/Projects/Code/emacs-from-scratch/")

Configuring Other Apps

(push '("conf-unix" . conf-unix) org-src-lang-modes)

To create output directories automatically, add :mkdirp yes

Noweb Blocks

Enables you to pass variables into a source block!


Add :noweb yes!



  • Automatically tangle on save
  • Should I also commit tangle output?
;; Automatically tangle our config file when we save it
(defun efs/org-babel-tangle-config ()
  (when (string-equal (buffer-file-name)
                      (expand-file-name "~/Projects/Code/emacs-from-scratch/"))
    ;; Dynamic scoping to the rescue
    (let ((org-confirm-babel-evaluate nil))

(add-hook 'org-mode-hook (lambda () (add-hook 'after-save-hook #'efs/org-babel-tangle-config)))
Subscribe to the System Crafters Newsletter!
Stay up to date with the latest System Crafters news and updates! Read the Newsletter page for more information.
Name (optional)
Email Address