Since my last post, I was thinking about remodeling a to a

This new orgmode is used to apply Literate Programming and get:

  • dotfiles at $HOME
  • csh files at $HOME/bin
  • lib files at $HOME/lib

All important information about this

  • Purpose
  • The Result
  • Requirements

Applying Literate Programming Use Emacs + Orgmode babel to convert source code blocks into files with tangle is something very easy.

Bellow an example to create the file: $HOME/.gitconfig with a core and user sections:

* git
*** .gitconfig
    :tangle:   ~/.gitconfig
**** Core
     #+begin_src conf
       excludesfile = ~/.gitignore
       editor = "vim"
       autocrlf = input
       filemode = false
       pager = less -r
**** User
     My personal information and GPG key for signing commits.
     #+begin_src conf
       name = Lenilson Jose Dias
       email =
       signingkey = 5074D5CF

It's possible to create shell scripts too:

** Setup emacs
   :tangle:   ~/bin/setup-emacs
   :mkdirp:   yes
   :shebang:  "#!/usr/bin/env csh"
   ~$HOME/bin/setup-emacs~ for now clone an Emacs git repository...
   #+begin_src sh
     rm -rf ~/.emacs.d
     git clone ~/.emacs.d

This source code block will create a csh shell script $HOME/bin/setup-emacs.

It's possible create files in a different file-mode too:

*** msmtp
    :tangle:   ~/.msmtprc
    :tangle-mode: (identity #o600)
    [[][msmtp]] is a SMTP client. From [[][here]]:

    #+begin_src conf
      # Set default values for all following accounts.
      auth           on
      tls            on
      tls_trust_file /etc/ssl/certs/ca-certificates.crt
      logfile        ~/.msmtp.log

      # Gmail
      account        personal_email
      port           587

      account default : personal_email

Here with :tangle-mode: (identity #o600) will create $HOME/.msmtprc with 600 permission mode.

The section Purpose has some inspiration references like this video from @howardabrams.

For this project I am using a Makefile to set up everything, but you can only call:

emacs --batch --eval "(require 'org)(require 'ob-tangle)" --eval '(org-babel-tangle-file "<path to>/")'
by Lenilson Jose Dias
Written on 2017-06-06