Christophe Weblog Wiki Code Publications Music
swankr.git
13 years agosort out printing functions
Christophe Rhodes [Fri, 1 Oct 2010 15:18:24 +0000 (16:18 +0100)]
sort out printing functions

R has capture.output as equivalent to with-output-to-string, so use it.

printToString, used by the slime-repl, now reverts back to calling
print.  New function prin1ToString, used by swank:interactive-eval and
swank:eval-and-grab-output, uses deparse.

13 years agoR implementation of the swank side of the (brand-new) slime-media contrib
Christophe Rhodes [Thu, 16 Sep 2010 20:01:25 +0000 (21:01 +0100)]
R implementation of the swank side of the (brand-new) slime-media contrib

Define a generic function to be used with the new
makeReplResultFunction hook, with an implementation using png files
for trellis objects.

13 years agonew makeReplResultFunction hook
Christophe Rhodes [Thu, 16 Sep 2010 19:59:46 +0000 (20:59 +0100)]
new makeReplResultFunction hook

default makeReplResult function doing the standard
(:write-string value :repl-result) thing for the REPL.

13 years agoimplement swank:eval-string-in-frame
Christophe Rhodes [Sun, 12 Sep 2010 17:06:26 +0000 (18:06 +0100)]
implement swank:eval-string-in-frame

Reified environments make quite a lot of this fairly easy...

13 years agoimplement swank:inspect-current-condition and swank:inspect-frame-var
Christophe Rhodes [Sun, 12 Sep 2010 16:40:48 +0000 (17:40 +0100)]
implement swank:inspect-current-condition and swank:inspect-frame-var

13 years agoimplement a default method for emacsInspect
Christophe Rhodes [Sun, 12 Sep 2010 16:40:25 +0000 (17:40 +0100)]
implement a default method for emacsInspect

Stands a chance of making the inspector not utterly annoying

13 years agoimplement swank:inspector-eval
Christophe Rhodes [Sat, 11 Sep 2010 09:58:10 +0000 (10:58 +0100)]
implement swank:inspector-eval

It took me quite some time to remember that parse returns a list of
expressions rather than just a single expression...

13 years agoimplement swank:inspector-pop and swank:inspector-next
Christophe Rhodes [Fri, 10 Sep 2010 21:53:44 +0000 (22:53 +0100)]
implement swank:inspector-pop and swank:inspector-next

Wow, nearly working.  There's some way of causing R to get into the
proper debugger; not sure how to reproduce it yet.

13 years agofix one multiple-string bug in the inspector
Christophe Rhodes [Thu, 9 Sep 2010 23:12:52 +0000 (00:12 +0100)]
fix one multiple-string bug in the inspector

13 years agoslightly more working inspector
Christophe Rhodes [Thu, 9 Sep 2010 22:28:11 +0000 (23:28 +0100)]
slightly more working inspector

Use an environment for istate rather than a list

implement swank:inspector-nth-part and swank:inspect-nth-part

13 years agoimplement `swank:quit-inspector`
Christophe Rhodes [Thu, 9 Sep 2010 15:31:17 +0000 (16:31 +0100)]
implement `swank:quit-inspector`

13 years agothe beginnings of an inspector
Christophe Rhodes [Thu, 9 Sep 2010 09:38:53 +0000 (10:38 +0100)]
the beginnings of an inspector

Implement enough that C-c I begins to work, at least for values like
list(1,2,3).  The resulting inspector on the emacs side apparently has
no features, and an error message results on quitting the inspector
because I've only implemented `swank:init-inspector`, and not
`swank:quit-inspector`.  Still, good enough to checkpoint.

13 years agoimplement withRetryRestart
Christophe Rhodes [Tue, 7 Sep 2010 07:38:19 +0000 (08:38 +0100)]
implement withRetryRestart

Use it in swank:interactive-eval and swank:eval-and-grab-output

13 years agoimplement withOutputToString
Christophe Rhodes [Tue, 7 Sep 2010 07:27:59 +0000 (08:27 +0100)]
implement withOutputToString

Possibly, anyway.  I think the semantics are right.  Use it in
printToString and in swank:eval-and-grab-output.

13 years agoswank:value-for-editing and swank:commit-edited-value
Christophe Rhodes [Fri, 3 Sep 2010 16:03:08 +0000 (17:03 +0100)]
swank:value-for-editing and swank:commit-edited-value

These are (in principle, at least) really, really easy.

13 years agoalternative printing for the REPL
Christophe Rhodes [Fri, 3 Sep 2010 07:10:09 +0000 (08:10 +0100)]
alternative printing for the REPL

instead of using print(), use str().  Also, be even more cautious
about cleaning up in printToString; previously, errors in printing
would lead to a sink to a closed fifo...

Printing is still not really right, and I forsee that we will end up
writing our own printer to get something more lispy.  But at least
this approach tends not to dump huge tables into the REPL.

13 years agointegrate into R's event loop, possibly
Christophe Rhodes [Fri, 3 Sep 2010 07:07:43 +0000 (08:07 +0100)]
integrate into R's event loop, possibly

in readPacket, call socketSelect() before actually trying to read on
the connection.  This seems to allow R to update graphics windows and
other such niceties.

It would be nice to be able to preserve the (inferior) R REPL as well,
but I haven't yet discovered whether that's possible.

13 years agoimplement swank:find-definitions-for-emacs
Christophe Rhodes [Wed, 1 Sep 2010 10:11:52 +0000 (11:11 +0100)]
implement swank:find-definitions-for-emacs

A simple implementation, only looking for a single function
definition (no methods, whether S3 or S4, or indeed anything else).
Enough to support M-., though.

13 years agouse srcfile$wd when going to source for an sldb frame
Christophe Rhodes [Wed, 1 Sep 2010 10:11:06 +0000 (11:11 +0100)]
use srcfile$wd when going to source for an sldb frame

it worked before while emacs and R were started with the same working
directory; this is not always going to be the case.

13 years agosupport swank:clear-repl-results in swank-presentations
Christophe Rhodes [Tue, 31 Aug 2010 08:02:14 +0000 (09:02 +0100)]
support swank:clear-repl-results in swank-presentations

This makes my worry about lacking weak hash tables a bit less
pressing.

13 years agoinitial implementation of support for REPL presentations
Christophe Rhodes [Tue, 31 Aug 2010 07:54:54 +0000 (08:54 +0100)]
initial implementation of support for REPL presentations

There's a lot here that's ugly, unfinished or just downright horrible.
Most notably, presentation support depends on swank-side read-time
evaluation (indicated with Common Lisp syntax, which hilariously is a
comment in R).  We can't support that in general, but we can
special-case the presentation-specific operator.

But then the next difficulty comes along; actually performing that
read-time evaluation needs to happen in a different environment than
the evaluation of the REPL form.  In order to achieve this, we abuse
bquote() the equivalent of Lisp's backquote facility, by calling what
in CL terms would be its macro-function on the parsed, preprocessed
expression; only after doing that (and hence resolving the `read-time'
evaluations) do we evaluate the call itself.

The implementation of presentation protocol messages is also slightly
ugly; having to implement cl:nth-value is particulraly horrible, but
the lack of weak references / weak tables in R (at least as far as I
can tell at the moment) is a cause of niggling concern.

13 years agoA proper implementation of swank:swank-require
Christophe Rhodes [Mon, 30 Aug 2010 20:45:48 +0000 (21:45 +0100)]
A proper implementation of swank:swank-require

We can do this nicely now that we have an evaluator of :emacs-rex
forms that can cope with quote.

13 years agoimplement a mini code-walker to support nested function calls in :emacs-rex
Christophe Rhodes [Mon, 30 Aug 2010 20:42:59 +0000 (21:42 +0100)]
implement a mini code-walker to support nested function calls in :emacs-rex

This is all a bit horrible, but probably limited in maintenance headaches.

13 years agomake swank:listener-eval be a bit more like the CL version
Christophe Rhodes [Mon, 30 Aug 2010 18:55:59 +0000 (19:55 +0100)]
make swank:listener-eval be a bit more like the CL version

don't return (:ok (:values "string")); instead, send a separate
(:write-string "string" :repl-result) and return (:ok ())

13 years agouse an environment holding the Slime I/O connection
Christophe Rhodes [Mon, 30 Aug 2010 09:03:42 +0000 (10:03 +0100)]
use an environment holding the Slime I/O connection

Rather than having a bare io argument everywhere, encapsulate it in an
environment.  (An environment is just about the only thing I can find
in R that isn't copy-on-write; this isn't helpful for the i/o
connection, but will be once we start implementing inspectors and
presentations...)

13 years agoslightly clarified the relationship to ESS
Christophe Rhodes [Sat, 28 Aug 2010 19:18:14 +0000 (20:18 +0100)]
slightly clarified the relationship to ESS

In particular, be careful not to overclaim.  Motivated by preparing to
announce to the ESS mailing list.

13 years agoadd README
Christophe Rhodes [Thu, 26 Aug 2010 10:39:18 +0000 (11:39 +0100)]
add README

13 years agoAdd licence information to swank.R
Christophe Rhodes [Thu, 26 Aug 2010 10:36:30 +0000 (11:36 +0100)]
Add licence information to swank.R

Same terms as R itself: GNU GPLv2 or later version

13 years agoimplement swank:frame-source-location
Christophe Rhodes [Wed, 25 Aug 2010 17:14:38 +0000 (18:14 +0100)]
implement swank:frame-source-location

Now v in the debugger mostly works.

13 years agofactor out backtraceForEmacs() into `swank:backtrace`
Christophe Rhodes [Wed, 25 Aug 2010 17:14:19 +0000 (18:14 +0100)]
factor out backtraceForEmacs() into `swank:backtrace`

write `swank:debugger-info-for-emacs` out, and hence delete
debuggerInfoForEmacs().

Now wandering past the --more-- prompt in sldb gives an infinite
sequence of NULLs, but at least it's not a cascade of errors any more.

13 years agoimplement swank:interactive-eval and swank:eval-and-grab-output
Christophe Rhodes [Wed, 25 Aug 2010 14:57:56 +0000 (15:57 +0100)]
implement swank:interactive-eval and swank:eval-and-grab-output

This allows C-c : and C-u C-c : to work, modulo the printing of an
unnecessary [1].  The evaluation semantics of R are not what a Lisper might
expect; printToString(eval(parse(...))) does not necessarily perform the
evaluation before altering the output stream with sink() -- so capturing
all sorts of incidental output if something goes wrong.

This commit brought to you using C-c C-c.

13 years agoensure that the fifo is closed in printToString()
Christophe Rhodes [Wed, 25 Aug 2010 14:55:41 +0000 (15:55 +0100)]
ensure that the fifo is closed in printToString()

Whoops.  Good to know that I can make the same basic stream mistakes
in any language.

13 years agoimplement swank:compile-string-for-emacs
Christophe Rhodes [Tue, 24 Aug 2010 17:06:48 +0000 (18:06 +0100)]
implement swank:compile-string-for-emacs

As long as my defun-prompt-regexp is set up right, I can now use C-c
C-c to develop swankr.  Go me.

13 years agoimplement swank:simple-completions
Christophe Rhodes [Fri, 20 Aug 2010 19:17:02 +0000 (20:17 +0100)]
implement swank:simple-completions

Probably fails as soon as slime and R disagree about what are token
constituents, or if an R token contains regexp metacharacters.

13 years agostub for swank:operator-arglist
Christophe Rhodes [Fri, 20 Aug 2010 19:16:00 +0000 (20:16 +0100)]
stub for swank:operator-arglist

13 years agoreturn properly from sldbLoop()
Christophe Rhodes [Thu, 19 Aug 2010 07:59:42 +0000 (08:59 +0100)]
return properly from sldbLoop()

Always emit a :debug-return message.  The extra :sldb-return stuff in
swank.lisp is (I think) only needed for multiple threads.

13 years agoput abort restarts around the main and sldb loops
Christophe Rhodes [Sun, 15 Aug 2010 15:46:13 +0000 (16:46 +0100)]
put abort restarts around the main and sldb loops

Also hide the abort restart imposed on us by the R interpreter itself,
which has the side-effect of aborting swank completely.

13 years agoThe beginnings of a vaguely-useful sldb
Christophe Rhodes [Sat, 14 Aug 2010 20:55:14 +0000 (21:55 +0100)]
The beginnings of a vaguely-useful sldb

Implement swank:frame-locals-and-catch-tags.  There are problems:

1. it seems that some names can be present in an environment but not have
   a value, causing eval to blow up;
2. the default printing routines aren't really adapted to the constraints
   of rendering in sldb;
3. trying to display locals of some of the swank frames (perhaps anything
   with a tryCatch or similar block?) causes R to complain about a promise
   already in the process of evaluation;
4. (probably) other things I haven't yet found

13 years agostore calls and frames on entry to sldb itself
Christophe Rhodes [Sat, 14 Aug 2010 20:12:20 +0000 (21:12 +0100)]
store calls and frames on entry to sldb itself

Rather than do complicated stuff to keep track of where we are in the
stack, simply store the interesting frames and calls in the sldb state
structure.

13 years agoimplement swank:buffer-first-change
Christophe Rhodes [Fri, 13 Aug 2010 16:24:02 +0000 (17:24 +0100)]
implement swank:buffer-first-change

Simply stub it in, to stop things whining at me when I type into the
wrong window and edit a Lisp file (which happens to be in slime
mode...)

13 years agoreturn stack frames in slime's order (most recent first)
Christophe Rhodes [Fri, 13 Aug 2010 16:10:16 +0000 (17:10 +0100)]
return stack frames in slime's order (most recent first)

13 years agoget definitions (use of <-) to work in the REPL
Christophe Rhodes [Fri, 13 Aug 2010 16:00:22 +0000 (17:00 +0100)]
get definitions (use of <-) to work in the REPL

the REPL now evaluates with envir=globalenv(), rather than in the
environment of `swank:listener-eval`...

13 years agosupport invoking restarts from sldb
Christophe Rhodes [Fri, 13 Aug 2010 15:03:51 +0000 (16:03 +0100)]
support invoking restarts from sldb

13 years agouse a restart description for restart printing, if available
Christophe Rhodes [Fri, 13 Aug 2010 14:22:58 +0000 (15:22 +0100)]
use a restart description for restart printing, if available

13 years agorework to support sldb
Christophe Rhodes [Fri, 13 Aug 2010 10:49:48 +0000 (11:49 +0100)]
rework to support sldb

R doesn't have much in the way of dynamic binding; you can fake it by
messing with environments, but that's not fun.

So instead, pass around the connection (`io') and an object
representing the SLDB state (`sldbState') to all functions.
Poor-man's explicit continuation-passing-style...

We need to call some of the mainLoop internal functions from elsewhere
now, so make them not-internal any more.

Fix ridiculous thinko in the logical branch of writeSexpToString

use simpleCondition rather than simpleError in swank:throw-to-toplevel

implement swank:debugger-info-for-emacs

Now `q' in sldb (sldb-quit) works.  Things that don't work:
1. the backtrace is the wrong way up.
2. calling any restarts
3. frame locals
4. returning from frames (dunno if R actually supports this)
5. zoom to source
6. probably other things

13 years agoimplement swank:throw-to-toplevel
Christophe Rhodes [Wed, 11 Aug 2010 14:58:47 +0000 (15:58 +0100)]
implement swank:throw-to-toplevel

13 years agoinclude swank.R hacks from today
Christophe Rhodes [Wed, 11 Aug 2010 14:02:47 +0000 (15:02 +0100)]
include swank.R hacks from today

We get far enough to start up a swank server in R and connect to it from
emacs; we get a REPL which formats the R-style results from parsing and
evaluating the input it receives.  Debugging, stepping, documentation,
arglist and so on is basically entirely missing.