[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] remote plot with local output?

From: Charles C. Berry
Subject: Re: [O] remote plot with local output?
Date: Tue, 15 Sep 2015 09:19:04 -0700
User-agent: Alpine 2.20 (OSX 67 2015-01-07)

On Tue, 15 Sep 2015, Benda Xu wrote:

Hi Charles,

"Charles C. Berry" <address@hidden> writes:

Look at the :post header arg

        (info "(org) post")

You write a src block that extracts the remote file name from *this*,
creates a local file name from it, copies the remote file to the local
host, then substitutes the local file name in *this* and uses it as
the return value.

Use the name of that src block as the argument to :post

Thanks for your hint.  I come up with the following example:

  #+NAME: line
  | 1 |
  | 2 |
  | 3 |

  #+name: localize
  #+BEGIN_SRC emacs-lisp :var file="" dir=""
    (let ((rfile (concat (file-name-as-directory dir) file)))
      (let ((lfile (car (last (split-string rfile ":")))))
        (copy-file rfile lfile 1)

  #+HEADER: :post localize(*this*, "/ipmuap02:/tmp")
  #+BEGIN_SRC python :results file :var dt=line :dir /ipmuap02:/tmp
    from matplotlib import pylab as plt
    return "line.png"


*this* only returns the resulting file name, without :dir.  I have to
set the same remote directory again in the :post call.  Is there a
smarter way to achieve it without duplication?

Untested, but try this :

#+name: localize
#+BEGIN_SRC emacs-lisp :var file="" srcinfo=(org-babel-get-src-block-info)
  (let* ((dir (cdr (assoc :dir (nth 2 srcinfo))))
         (rfile (concat (file-name-as-directory dir) file))
         (lfile (car (last (split-string rfile ":")))))
    (copy-file rfile lfile 1)

then use

#+HEADER: :post localize(*this*)

in your python src block.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]