This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Re: swank-kawa.scm
- From: Helmut Eller <eller dot helmut at gmail dot com>
- To: Chuah Teong Leong <teongleong at gmail dot com>
- Cc: kawa at sourceware dot org
- Date: Sun, 21 Apr 2013 20:29:32 +0200
- Subject: Re: swank-kawa.scm
- References: <CAHxu6d9TsvJ3ofdtsY01y6RmC+dDHrLL0e422ZpzY4sE4b1K7w at mail dot gmail dot com>
On Sun, Apr 21 2013, Chuah Teong Leong wrote:
> Hi Helmut Eller,
>
> I've been looking into kawa support within emacs. So far I have slime,
> scheme-complete, paredit set up. I came across this code you wrote.
>
> I have 2 problems that I'm hoping you could help me with.
>
> 1) Compilation
> I'm working on windows and I'm not exactly sure if I got the
> compilation process correct. I ran kawa with -cp to tools.jar and
> kawa.jar and did (compile "swank-kawa.scm" "swank-kawa") from the
> repl. There wasn't any error message and it produced a swank-kawa.zip
> within slime\contrib. I'm wondering if it should have been renamed to
> a jar and included it in the classpath. I haven't done anything yet
> and assume that is how it should be.
Initially I would recommend not to compile the file. You can load the
source file with (require ".../swank-kawa.scm"). Try this from the Kawa
REPL outside of Emacs in a normal shell to minimize confusion.
If you really want to know how to compile, here are some hints:
I think that compile-file is obsolete in Kawa or at least Per Bothner
considers it bad practice. If you use compile-file you should use the
load function instead of require: (load "..swank-kawa.zip").
The recommended way to compile is from the shell with something like
"kawa -C swank-kawa.scm". Add classpath stuff and other flags as
needed. This produces .class files like javac does. These .class files
can then be put in a jar file with the normal jar tool, just like normal
java classes. To load such a jar, the jar file needs to be in the
classpath and you need to use (import (swank-kawa)) inside Kawa.
>
> 2) Usage
> at the end of the instruction you said
> "Start everything with M-- M-x slime kawa"
>
> I couldn't quite figure how to do that.
> I did M-x slime and got this
>
> (begin (require "G:/emacs-24.2/lisp/slime/contrib/swank-kawa.scm")
> (start-swank "c:/Users/****/AppData/Local/Temp/slime.13604"))
> Listening for transport dt_socket at address: 49420
> #|kawa:1|# Thread[swank,5,main]
> #|kawa:2|# connection: Socket[addr=/127.0.0.1,port=49424,localport=49423]
> listener: Thread[swank-listener,5,main] 28560412 chan@df11d5 #<environment r0>
> attaching: $PPID 20
> attaching2: com.sun.jdi.ProcessAttach (defaults: pid=, timeout=)
> {pid=pid=$PPID, timeout=timeout=20}
> java.util.ServiceConfigurationError:
> com.sun.tools.attach.spi.AttachProvider: Provider
> sun.tools.attach.WindowsAttachProvider could not be instantiated:
> java.lang.UnsatisfiedLinkError: no attach in java.library.path
> closing socket: ServerSocket[addr=0.0.0.0/0.0.0.0,port=0,localport=49423]
> exception in thread Thread[swank,5,main]: java.lang.Error: mcase failed tmp
> (chan@cc7ed2
> (error "java.io.IOException: no providers installed" "IOException"
> ("com.sun.tools.jdi.ProcessAttachingConnector.attach(ProcessAttachingConnector.java:104)"
> "swank$Mnkawa.attach(swank-kawa.scm:1777)"
> "swank$Mnkawa.vmAttach(swank-kawa.scm:1758)"
OK, it seems that your setup is mostly correct but it runs in to a
problem in my code. The function getpid in swank-kawa.scm is supposed
to return the process id of the current process; to my knowledge there's
no portable way to do that in Java. The code simply assumes that we run
on Linux and uses a Linux specific trick to figure out the pid (that's
where the $PPID comes from in the debug output). I don't know what the
best trick is on Windows. Maybe steal something from the Clojure people:
https://github.com/pallet/ritz/blob/develop/repl-utils/src/ritz/repl_utils/sys.clj
On Linux
((java.lang.management.ManagementFactory:getRuntimeMXBean):getName)
seems to return something useful. but (java.lang.System:getProperty
"pid") doesn't.
Anyway, if you want to explore this further then I would recommend that
you start swank in Kawa REPL outside of Emacs like so:
#|kawa:1|# (require "/home/helmut/lisp/slime/contrib/swank-kawa.scm")
#|kawa:2|# (create-swank-server 4005)
Listening on port: 4005
Then you can use M-x slime-connect in Emacs to proceed and the Kawa side
should print something like:
connection: Socket[addr=/127.0.0.1,port=52781,localport=4005]
listener: Thread[swank-listener,5,main] 11515472 chan@1ea71d4
#<environment main>
attaching: 3763 20
attaching2: com.sun.jdi.ProcessAttach (defaults: pid=, timeout=)
{pid=pid=3763, timeout=timeout=20}
Helmut