Ryan Scott <[email protected]> writes:

> I've been working through a few different approaches. What's shaping up is 
> something more general, having a special value
> for directory parameters (i.e. 'attach) and auto-detection of link paths that 
> are in the attachment directory.
> The latest iterations don't move any files around, so can't actually enforce 
> the output directory. That makes it safer
> overall as with my initial patch if you were to return a path to something 
> you didn't want moved to your attachment
> directory you might get very surprising results.

I used to created a similar function extension called "ob-clojure-literate.el" 
for ob-clojure.el.
One functionality is to save plotting result image to a header argument :dir 
specified directory.
But it's a little complicated. Then later I found another solution through 
*header argument evaluation*:

#+begin_src clojure :results file link :dir "data/images" :file 
"ob-clojure-incanter-move.png" :var dir=(concat (file-name-directory 
(buffer-file-name)) "data/images/")
(use '(incanter core io charts stats))
(import '(java.io File))

(def hist (histogram (sample-normal 1000)))
(save hist "ob-clojure-incanter-move.png")
(.renameTo (File. "ob-clojure-incanter-move.png") (File. (str dir 
"ob-clojure-incanter-move.png")))
#+end_src

But this code has a disadvantage:

This solution breaks Literate Programming tangling concept by introduced 
un-reimplemented variable ~dir~.

>
> I'll post a new patch with a different approach in a little bit.
>
> On Mon, Oct 4, 2021 at 5:06 PM Christopher M. Miles <[email protected]> 
> wrote:
>
>  Ihor Radchenko <[email protected]> writes: 
>
>  Greg Minshall <[email protected]> writes: 
>
>  i can imagine wanting to have input files and output files in separate 
> directories. (for ease in "make
>  clean", if for no other conceptual reason.) (but, probably i don't 
> understand.) 
>
>  I agree with this thought. We should separate two directories. 
>
>  Makes sense. Currently, there is :dir header arg to set working directory 
> (aka input files directory). Maybe we
>  can introduce something like :results-dir header arg to set the output 
> directory? It's value can be a directory
>  path or symbol 'attach. 
>
>  `:results file :results-dir 'attach` will be equivalent of `:results file 
> attach` in the patch proposed by Ryan
>  Scott. 
>
>  WDYT? 
>
>  I agree with this idea. Use :results-dir 'attach is better. 
>
>  Will the patch be updated? 
>
>  Best, Ihor 
>
>  <#secure method=pgpmime mode=sign>
>  -- 
>  [ stardiviner ]
>         I try to make every word tell the meaning that I want to express.
>
>         Blog: https://stardiviner.github.io/
>         IRC(freenode): stardiviner, Matrix: stardiviner
>         GPG: F09F650D7D674819892591401B5DF1C95AE89AC3


<#secure method=pgpmime mode=sign>
-- 
[ stardiviner ]
       I try to make every word tell the meaning that I want to express.

       Blog: https://stardiviner.github.io/
       IRC(freenode): stardiviner, Matrix: stardiviner
       GPG: F09F650D7D674819892591401B5DF1C95AE89AC3

Reply via email to