[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] org babel before excute hook
From: |
Charles Berry |
Subject: |
Re: [O] org babel before excute hook |
Date: |
Sat, 12 Oct 2013 02:28:20 +0000 (UTC) |
User-agent: |
Loom/3.14 (http://gmane.org/) |
John Kitchin <jkitchin <at> andrew.cmu.edu> writes:
>
>
>
> I have a related kind of problem. When preparing notes
> for a class, I may end up with 70 code blocks in an org file, many of
> which create graphics. I am always worried about accidentally using the
> same filename and overwriting a graphic from an earlier block. A unique,
> but reproducible filename would be sufficient for my needs.
>
Header arg values can be elisp calls. You can use `make-temp-file'.
So every time this block is executed, a new file is created and the
file link is added to the results.
#+BEGIN_SRC R :results output append :file (make-temp-file "temp")
cat(date(),"\n")
#+END_SRC
#+RESULTS:
[[file:/var/folders/kb/2hchpbyj7lb6z76l0q73w_fh0000gn/T/temp302IjV]]
[[file:/var/folders/kb/2hchpbyj7lb6z76l0q73w_fh0000gn/T/temp3028Lu]]
See `temporary-file-directory', too, if you want to use this, as the
default may not be what you intend.
You might want to use this:
#+BEGIN_SRC emacs-lisp
(defun local-tfile (file)
(let ((temporary-file-directory "."))
(make-temp-file file)))
#+END_SRC
Then the files go in the local directory when this is executed:
#+BEGIN_SRC R :file (local-tfile "tfile") :results output append
cat(date(),"\n")
#+END_SRC
You might not want `append' in this case.
HTH,
Chuck
[rest deleted]
- [O] org babel before excute hook, Henning Redestig, 2013/10/11
- Re: [O] org babel before excute hook, John Kitchin, 2013/10/11
- Re: [O] org babel before excute hook,
Charles Berry <=
- Re: [O] org babel before excute hook, Henning Redestig, 2013/10/12
- Re: [O] org babel before excute hook, Henning Redestig, 2013/10/13
- Re: [O] org babel before excute hook, Samuel Wales, 2013/10/13
- Re: [O] org babel before excute hook, Henning Redestig, 2013/10/14
- [O] [babel] Feature request - WAS: org babel before excute hook, Rainer M Krug, 2013/10/14
- Re: [O] org babel before excute hook, Eric Schulte, 2013/10/14
- Re: [O] org babel before excute hook, Samuel Wales, 2013/10/26
- Re: [O] org babel before excute hook, Eric Schulte, 2013/10/14