There is Org Mode for Emacs in which you can do writing as well as literate programming. Here's my Emacs config (written in Org Mode) which doubles as documentation and includes lots of custom code: <a href="https://github.com/munen/emacs.d" rel="nofollow">https://github.com/munen/emacs.d</a>