Hi Following a discussion about how one could create a TODO list in ESS (see below), Thomas Dye and Dan Davison suggested to look into org-mode and org-babel and it looks really interesting. I just have one aspect, which would be more difficult with my workflow. Let me explain. I am writing fairly complex simulations, and I prefer to keep functions for different aspects of the simulation in different files. Therefore I have several files, each one containing R code, which is sourced from a main file, which then sets the simulation up, which I then can start with calling simulateIt() in R. I could use .org files and tangle the code, but, as I am not that organised, I even forget sometimes to save before I source the file and therefore still work with the old version - this would be more difficult, if I had to tangle each file in addition to the saving (Ctrl-x s saves all files - very useful for me!). One option would be to combine all actual files into a single one, and then tangle in different .R files, but I somehow do not like the idea of having one HUGE file, with all the code, which then will be tangled into several .R files. So I would like to have several .org files, where each one will be tangled into a separate .R file, which then will be sourced from a final main file. As I understand org-mode, I could still have a single TODO list, based on the agenda in org-mode. So my question is, if this process could be automated. One idea was a kind of a "make file", in which I specify: tangle file1.org tangle file2.org tangle file3.org tangle fileAll.org These would then result in the files attached, which then can be used from fileAll.R Another idea was to have emacs automatically tangle the file after saving. But I am sure there are also other possibilities. I have to say, I am absolutely new to org-mode, and know nearly nothing about lisp. Cheers, Rainer ---------- Forwarded message ---------- From: Dan Davison Date: Mon, Feb 1, 2010 at 9:59 PM Subject: Re: Fwd: [ESS] generating TODO list? To: Rainer M Krug Cc: "Thomas S. Dye" [...] > Sure, when you change the code in the org file, you have to re-run > org-babel-tangle before you run your new R code. > > > Ant this is the critical point: I can save all files which need to be saved in > ESS by Ctrl-x s (or was it Ctrl-x Ctrl-s ? I always do both). But having > manually to go through all files, is something I am likely to forget. If I > could tangle all files with one command, that wouls work (I have about 10 files > for the project which are then sourced...). Could I combine the save-all with a > tangle-all, or have the saving action automatically followed by a tangling (if > it is an org file)? > > > But that's just one possibility. Another would be simply to tangle all > the blocks of R code to the same file. Then when you run that file, you > know that your function definitions will be up to date. > > > It is quite strange, that there is no possibility to script emacs from org mode > like all the other languages? because that would be perfect for this. I am certain that there is going to be a good solution for all your concerns! I think you want to be thinking along the lines of maintaining a _single_ org file for your project, and either including the code in different subtrees of that file, or referring to external files from within that file. But if the right solution doesn't doesn't already exist, and it's a good idea, then someone will cook it up in elisp. Could we move this discussion to the org-mode list? If you describe what you want to do, with a toy example if that's helpful, then I believe you will see that problems do not remain without solution for very long on emacs-orgmode@gnu.org. Meanwhile, have a look at this http://doc.norang.ca/org-mode.html to see some of what org-mode can do (the website itself is made in org-mode of course). Dan > > > > By the way, have you tried out the export facilities of org-mode? Have a > look at the html export of the above org file [C-c C-e (org-export) > brings up the export options]. You can create links in the org file to > graphical output from R and these graphs will be included in the > exported HTML/LaTeX. > > > No - I just discovered the org-mode yesterday. > > Cheers, > > Rainer > > > > Dan > > > > > If that could be done, it would be a perfect example, how one could use > > org-babel in real R programming. The other option, would be a "make file" > > equivalent, which contains all the "tangle file ..." commands, and which > could > > be executed in the block above. > > > > > > > > And it's also worth looking at the noweb-style references for > assembling > > > > different code blocks into a single code block. So with reference to > the > > distinction between "source is real" vs. "R objects are real", from > > the org-babel point of view the org-mode files are real and contain > the > > source code along with essential project development and planning > notes, > > and the .R files are an ephemeral product of the org-mode source. > > > > > > As I said, it makes perfect sense, but the problem is the additional step > > needed. If this could be avoided (e.g. "make file") I would very likely > use the > > org-mode. > > > > Thanks for your very helpful comments, > > > > Rainer > > > > > > > > Dan > > > > http://orgmode.org/worg/org-contrib/babel/intro.php# > literate-programming > > http://orgmode.org/worg/org-contrib/babel/reference.php# > > function-org-babel-tangle > > > > > > > > > > > > > > I will be looking into it anyway, because it REALLY looks very > > useful. > > > > > > > > > > > > You might want to join the Org-mode mailing list. The > authors of > > > Org-babel, Dan Davison and Eric Schulte, both respond to > > questions > > > there. Also, there are several Org-babel users there who > are > > much > > > better than I am at figuring out why things aren't working > right. > > > > > > What happens when you try Ctrl-C ' while in a code block? > If > > Org-babel > > > is initialized then this should take you to a new window > with ESS > > as > > > the editing mode. > > > > > > > > > Well - I used Ctrl-c ` instead of Ctrl-c ' -- working now. > > > > > > > > > Thanks a lot, > > > > > > Rainer > > > > > > > > > > > > > > > All the best, > > > Tom > > > > > > > > > -- NEW GERMAN FAX NUMBER!!! Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Cell: +27 - (0)83 9479 042 Fax: +27 - (0)86 516 2782 Fax: +49 - (0)321 2125 2244 email: Rainer@krugs.de Skype: RMkrug Google: R.M.Krug@gmail.com