Skip to content

Latest commit

 

History

History
1093 lines (916 loc) · 22 KB

dan-tests.org

File metadata and controls

1093 lines (916 loc) · 22 KB

Local and remote working dirs

:results output

:session
Rcode
date()
system("hostname")
getwd()
local
<<dir-test-R>>
remote
<<dir-test-R>>
rubycode
system("date")
system("hostname")
system("pwd")
local
<<dir-test-ruby>>
remote
<<dir-test-ruby>>
pythoncode
import os, time
print time.ctime()
print os.uname()
print os.getcwd()
local
<<dir-test-python>>

shellcode
date
hostname
pwd
local
<<dir-test-shell>>
remote
<<dir-test-shell>>

string
'string from octave'
matlabnumeric matrix NB matlab-shell doesn’t currently respond to a remote default-directory. A hack is to insert a line like

(cd “/ddavison@tombstone.princeton.edu:”)

into matlab-shell.

magic(3)
string
'string from matlab'
non-session
Rlocal
<<dir-test-R>>

rubylocal
<<dir-test-ruby>>

shelllocal
<<dir-test-shell>>

perlcode
system("date");
system("hostname");
system("pwd");
local
<<dir-test-perl>>
remote
<<dir-test-perl>>
matlab
6 * exp(i*pi)

:results value

:session
Rcode
c(date(), system("hostname", intern=TRUE), getwd())
local
<<dir-test-R-value>>

local
<<dir-test-ruby-value>>
remote
<<dir-test-ruby-value>>
pythoncode
import os, time
[time.ctime(), os.uname(),os.getcwd()]
local
<<dir-test-python-value>>

local But Looks like a shell ‘:session :results value’ bug here.
<<dir-test-shell-value>>
remote
<<dir-test-shell-value>>
perl : NAoctavenumeric
ans = z^3
string
ans = 'string from octave with 100%'
vector
123
123
456
x+0
x+0
matlabnumeric
magic(3)
string
'string from matlab'
non-session
Rlocal
<<dir-test-R-value>>

rubylocal
<<dir-test-ruby-value>>
remote
[1,2]
pythoncode
import os, time
return [time.ctime(), os.uname(),os.getcwd()]
local
<<dir-test-python-value-nonsession>>

shelllocal
<<dir-test-shell-value>>
remote
<<dir-test-shell-value>>
perlcode
(`date`,`hostname`,`pwd`) ;
local
<<dir-test-perl-value>>
remote
<<dir-test-perl-value>>
clojurelocal
(+ 2 2)
remote (setq swank-clojure-binary “/home/dan/bin/clojure”)
(+ 2 33)
(+ 2 2)
octavenumeric
z / 100
string
['tab	with', 'embedded tabs']
matlabnumeric
[z / 6; z / 7]
string
'string from matlab'

File output links

Set up

mkdir -p /tmp/images

These don’t use :dir so should be same as before

ditaa
+-----------+
| cBLU      |
| Org       |
|    +------+
|    |cPNK  |
|    |babel |
|    |      |
+----+------+
latex
$e^{i\pi} = -1$
R

#+source R-dir-eg

curve(sin(x), 0, 2*pi)
gnuplot
independent varfirst dependent varsecond dependent var
0.10.4250.375
0.20.31250.3375
0.30.249999930.28333338
0.40.2750.28125
0.50.260.27
0.60.258333380.24999993
0.70.246428450.23928553
0.80.231250.2375
0.90.233333230.2333332
10.22250.22
1.10.209090750.22272708
1.20.199999980.21458333
1.30.196153680.21730748
set title "Implementing Gnuplot"
plot data using 1:2 with lines

With :dir, should expand when :dir differs from current buffer dir

But not during export

ditaa
+-----------+
| cBLU      |
| Org       |
|    +------+
|    |cPNK  |
|    |babel |
|    |      |
+----+------+
latex
$e^{i\pi} = -1$
R
curve(sin(x), 0, 2*pi)
gnuplot

Looks like gnuplot doesn’t respond to default-directory. I think that is because shell-command-to-string uses call-process instead of process-file. We may want to use shell-command-on-region or shell-command.

set title "Implementing Gnuplot"
plot data using 1:2 with lines

Behaviour on error

results value

Required change on line 90 of s-c-o-r
shell

Shell worked from the start

local
cat /nothere

Shell command exited with code 1

Traceback (most recent call last):
  File "<stdin>", line 5, in <module>
  File "<stdin>", line 3, in main
Exception: Something went wrong
remote
import os
raise Exception('Something went wrong on %s %s %s %s %s' % os.uname())
Non-empty stderr
import sys
sys.stdout.write("this is on stdout!")
sys.stderr.write("this is on stderr!")

R
  • State “DONE” from “TODO” [2010-03-01 Mon 09:21]
  • State “TODO” from “” [2010-03-01 Mon 09:20]
Exception
stop("Error message!")
output on stderr Silent
cat("This is on stderr\n", file=stderr())
no error Window movement – was there before? No.
1:3
elisp
  • State “DEFERRED” from “” [2010-03-01 Mon 09:33]

Output to minibuffer and Messages

(error "Error message!")
perl
  • State “DONE” from “TODO” [2010-03-01 Mon 09:37]
  • State “TODO” from “” [2010-03-01 Mon 09:20]
Compile error
  • State “DONE” from “TODO” [2010-03-01 Mon 09:36]
  • State “TODO” from “” [2010-03-01 Mon 09:20]
local
$dummy = 1
split " ", "1 2 3"
remote
$dummy = 1
split " ", "1 2 3"
throw runtime error
  • State “DONE” from “TODO” [2010-03-01 Mon 09:36]
  • State “TODO” from “” [2010-03-01 Mon 09:20]
die "Error message!";
No error Window movement – was there before?
split " ", "1 2 3";

Write to stderr I’m not sure why that’s 16
$stderr.write "Hello on stderr\n"
$stdout.write "Hello on stdout\n"

No error
(+ 2 2)

python
import sys
sys.stdout.write("this is on stdout!\n")
sys.stderr.write("this is on stderr!\n")
R
output on stderr
cat("This is on stderr\n", file=stderr())

Point in comint

If window is visible, point moves; if not it doesn’t.

(setq comint-move-point-for-output t) ;; doesn’t solve it

Python

b=10
b

R

a=6
a

Inline images

R

plot(1, main="i")

latex

$e^{i\pi} \neq -6$
mogrify -resize 200% $file
echo $file

R session

2+2
system("hostname", intern=TRUE)