| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 | From: "Eric H. Neilsen, Jr." <neilsen@fnal.gov>Subject: [Orgmode] A tool for creating source code files from example and src blocks in org filesTo: emacs-orgmode@gnu.orgDate: Tue, 02 Jun 2009 13:50:58 -0500Hi,First, thank you Carsten and others, for putting this thing together;org-mode is the most useful tool I've run across in a long time.I recently put together a few commands to create source code filesfrom SRC and EXAMPLE blocks in org-mode files. The original idea is tobe able to compile examples in my notes without needing to merge theminto a separate source file by hand. As I was writing it I realizedthis is exactly the same tool one needs to turn org-mode into aliterate programming tool (see http://www.literateprogramming.com/ ),so I adopted some of the nomenclature. (I tried literate programming afew years ago, and gave up in frustration with the tools. I am temptedto try again with org-mode.)The two user level commands are org-tangle and org-untangle, bestexplained through example. Running org-tangle in a buffer that lookslike this:---------------------- begin /tmp/test.org ---------------------------* Some fileSome text here#+CHUNK file1.sh 1#+BEGIN_SRC bashecho "line 1"echo "line 2"#+END_SRCmore text** Some subsection#+CHUNK file1.sh 2#+BEGIN_SRC bashecho "line 5"echo "line 6"#+END_SRCblah blah blah#+CHUNK README.txt 1#+BEGIN_EXAMPLEtext line 1text line 2text line 3#+END_EXAMPLEfoo foo bar baz#+CHUNK file1.sh 1.5#+BEGIN_SRC bashecho "line 3"echo "line 4"#+END_SRC-------------- end /tmp/test.org ----------------results in the creation of these two files, opened in emacs buffers:------------- begin /tmp/file1.sh ----------------#      ORGCHUNK /tmp/test.org  1echo "line 1"echo "line 2"#      ORGCHUNK /tmp/test.org  1.5echo "line 3"echo "line 4"#      ORGCHUNK /tmp/test.org  2echo "line 5"echo "line 6"------------- end /tmp/file1.sh ---------------------and------------ begin /tmp/README.txt -------------text line 1text line 2text line 3------------ end /tmp/README.txt ---------------If you then edit file1.sh and run org-untangle in the buffer, changesto it will overwrite the literal blocks in the org-mode file fromwhence they came.Is there any interest in this? My organization's rules for releasingcode to open source projects are being revised, but I am likely to beable to do so under a BSD-like license. If there is interest, I willpush to try and figure out how to do this, and maybe even see if I cando the assignment of copyright stuff needed for it to get under themain umbrella (although I am not optimistic).(If anyone feels like rewriting it, that would be even better; asidefrom a fairly straightforward .emacs, this is my first ever lisp code,so it is likely to need cleaning and refactoring.)   -Eric-- Eric H. Neilsen, Jr.http://home.fnal.gov/~neilsen_______________________________________________Emacs-orgmode mailing listRemember: use `Reply All' to send replies to the list.Emacs-orgmode@gnu.orghttp://lists.gnu.org/mailman/listinfo/emacs-orgmode
 |