From: Benda Xu <heroxbd@gentoo.org>
To: emacs-orgmode@gnu.org
Subject: Re: remote plot with local output?
Date: Fri, 18 Sep 2015 17:58:58 +0900 [thread overview]
Message-ID: <874mis2je5.fsf@gentoo.org> (raw)
In-Reply-To: <87mvwn862v.fsf@gentoo.org> (Benda Xu's message of "Wed, 16 Sep 2015 11:13:12 +0900")
Hi,
Benda Xu <heroxbd@gentoo.org> writes:
> "Charles C. Berry" <ccberry@ucsd.edu> writes:
>
>> 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)
>> lfile)
>> #+END_SRC
>>
>> then use
>>
>> #+HEADER: :post localize(*this*)
>>
>> in your python src block.
>
> It successfully extracts the :dir field. Thanks!
Python works this way. But babel R has a completely different *this*
value. Consider the following example:
#+BEGIN_SRC R :results output graphics :file line.png :dir /ipmuap02:/tmp
plot(c(1,2,3))
#+END_SRC
#+RESULTS:
[[file:/scp:ipmuap02:/tmp/line.png]]
*this* equals "[[file:/scp:ipmuap02:/tmp/line.png]]", but in babel
python *this* equals "line.png".
So I come up with
#+name: localize
#+BEGIN_SRC emacs-lisp :var file="" srcinfo=(org-babel-get-src-block-info)
(let ((lang (car srcinfo)))
(cond ((string= lang "python")
(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)
lfile))
((string= lang "R")
(let* ((rfile (substring file 7 -2))
(lfile (car (last (split-string rfile ":")))))
(copy-file rfile lfile 1)
(concat "[[file:" lfile "]]")))))
#+END_SRC
But the result is a string rather than a file link:
#+HEADER: :post localize(*this*)
#+BEGIN_SRC R :results output graphics :file line.png :dir /ipmuap02:/tmp
plot(c(1,2,3))
#+END_SRC
#+RESULTS:
: [[file:/tmp/line.png]]
Any hints?
Yours,
Benda
next prev parent reply other threads:[~2015-09-18 8:59 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-14 15:11 remote plot with local output? Benda Xu
2015-09-14 16:48 ` Suvayu Ali
2015-09-15 8:54 ` Benda Xu
2015-09-15 8:57 ` Benda Xu
2015-09-14 20:42 ` Charles C. Berry
2015-09-15 8:28 ` Benda Xu
2015-09-15 16:19 ` Charles C. Berry
2015-09-16 2:13 ` Benda Xu
2015-09-18 8:58 ` Benda Xu [this message]
2015-09-18 18:11 ` Charles C. Berry
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=874mis2je5.fsf@gentoo.org \
--to=heroxbd@gentoo.org \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.