Skip to content

Latest commit

 

History

History
116 lines (68 loc) · 2.25 KB

Emacs-07.org

File metadata and controls

116 lines (68 loc) · 2.25 KB

Configure Everything with Org Babel

Check out the GitHub repo

https://github.com/daviwil/emacs-from-scratch

Org Babel

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

https://orgmode.org/worg/org-contrib/babel/ https://orgmode.org/worg/org-contrib/babel/languages.html

42
(org-babel-do-load-languages
  'org-babel-load-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)
(org-babel-tangle-file "~/Projects/Code/emacs-from-scratch/Emacs.org")

Configuring Other Apps

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

To create output directories automatically, add :mkdirp yes

My mpv configuration

Noweb Blocks

Enables you to pass variables into a source block!

55

Add :noweb yes!

value=<<the-value>>

Per-System Settings

Tips

  • Automatically tangle on save
  • Should I also commit tangle output?
;; Automatically tangle our Emacs.org 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/Emacs.org"))
    ;; Dynamic scoping to the rescue
    (let ((org-confirm-babel-evaluate nil))
      (org-babel-tangle)))

(add-hook 'org-mode-hook (lambda () (add-hook 'after-save-hook #'efs/org-babel-tangle-config)))