public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
* Re: Different behavior for -s argument in Kawa 2.0?
       [not found] <CAFVyn8RdRnhc9DGpzT=oA6sQ0oWcbRM71hYvVUROV+7grKkTMQ@mail.gmail.com>
@ 2015-01-09 16:48 ` Jeff Gonis
  2015-01-09 20:51   ` Per Bothner
  0 siblings, 1 reply; 10+ messages in thread
From: Jeff Gonis @ 2015-01-09 16:48 UTC (permalink / raw)
  To: kawa

Hi Per,

First let me thank you for your quick response when I last emailed the
list asking about r7rs libraries and their behavior.  2.0 is proving
to be really great to work with!

I wish that I could give you a better report than what follows but I
am not sure where to start looking.  With kawa 1.9, running on windows
and using emacs 24.3 (although I have also tried this with 24.4 as
well and experience the same behaviour), launch kawa with -s as an
argument allows me to have a nice repl inside emacs and evaluate
scheme code in another buffer with it. All in all, a nice development
environment.

With kawa 2.0, and changing nothing else in my setup, I am unable to
get kawa to create a repl within emacs.  I can definitely launch kawa
from within emacs by dropping the -s argument, but this creates a java
window to represent the repl and then I lose out on paredit and other
goodies. If I launch kawa from within emacs with the -s argument it
appears as though nothing happens, I can't see the java process
increasing in memory or using cpu, however when I attempt to kill that
buffer emacs will report that there is still a process associated with
that buffer, so maybe kawa is running and just hangs early on.

Anyway, please let me know if you need any additional details, or if I
can do any other investigation for you.

Thanks for all your hard work,
Jeff

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Different behavior for -s argument in Kawa 2.0?
  2015-01-09 16:48 ` Different behavior for -s argument in Kawa 2.0? Jeff Gonis
@ 2015-01-09 20:51   ` Per Bothner
  2015-01-09 22:07     ` Jeff Gonis
  0 siblings, 1 reply; 10+ messages in thread
From: Per Bothner @ 2015-01-09 20:51 UTC (permalink / raw)
  To: Jeff Gonis, kawa

On 01/09/2015 08:48 AM, Jeff Gonis wrote:
> With kawa 2.0, and changing nothing else in my setup, I am unable to
> get kawa to create a repl within emacs.
> ...
> Anyway, please let me know if you need any additional details, or if I
> can do any other investigation for you.

Please give the exact commands you use to launch kawa.
-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Different behavior for -s argument in Kawa 2.0?
  2015-01-09 20:51   ` Per Bothner
@ 2015-01-09 22:07     ` Jeff Gonis
  2015-01-09 22:31       ` Jamison Hope
  2015-01-09 22:37       ` Per Bothner
  0 siblings, 2 replies; 10+ messages in thread
From: Jeff Gonis @ 2015-01-09 22:07 UTC (permalink / raw)
  To: Per Bothner; +Cc: kawa

On Fri, Jan 9, 2015 at 1:50 PM, Per Bothner <per@bothner.com> wrote:
> On 01/09/2015 08:48 AM, Jeff Gonis wrote:
>>
>> With kawa 2.0, and changing nothing else in my setup, I am unable to
>> get kawa to create a repl within emacs.
>> ...
>> Anyway, please let me know if you need any additional details, or if I
>> can do any other investigation for you.
>
>
> Please give the exact commands you use to launch kawa.
> --
>         --Per Bothner
> per@bothner.com   http://per.bothner.com/

Hi Per,

I launch kawa from emacs using the run-scheme function, which depends
on the variable scheme-program-name.  If I set this to the following:
java -jar "d://jeffs Folder//kawa//kawa-2.0.jar" -s then I will not be
able to get a repl inside of emacs.

If I change scheme-program to: java -jar "d://jeffs
Folder//kawa//kawa-1.90.jar" -s then I am able to successfully launch
the repl.  Nothing changes between the two commands besides the
version of kawa.  Same instance of emacs, same version of java, same
folder location.

Thanks for the follow up and please let me know if you need more information.
Jeff

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Different behavior for -s argument in Kawa 2.0?
  2015-01-09 22:07     ` Jeff Gonis
@ 2015-01-09 22:31       ` Jamison Hope
  2015-01-09 23:05         ` Per Bothner
  2015-01-09 22:37       ` Per Bothner
  1 sibling, 1 reply; 10+ messages in thread
From: Jamison Hope @ 2015-01-09 22:31 UTC (permalink / raw)
  To: kawa@sourceware.org list

As a further data point, I think I'm seeing the same behavior.  I'm using xscheme.el and defining xscheme-process-command-line to

"java -cp [a bunch of other JARs]:/path/to/kawa-2.0.1.jar kawa.repl -s"

The *scheme* buffer displays its usual preamble at the top, and then.. nothing.

BUT, if I try to evaluate a Scheme expression, it works.  So the REPL is running, it just isn't displaying the "#|kawa:N|#" prompt:

> This is the Scheme process buffer.
> Type C-x C-e to evaluate the expression before point.
> Type C-c C-c to abort evaluation.
> Type C-h m for more information.
> 
> (+ 1 2)^x^e
> 3
> 
> java.lang.Math:PI^x^e
> 3.141592653589793


Jeff, can you try evaluating some expressions to see if you are also just missing the prompt?

-Jamie

On Jan 9, 2015, at 5:06 PM, Jeff Gonis <jeff.gonis@gmail.com> wrote:

> On Fri, Jan 9, 2015 at 1:50 PM, Per Bothner <per@bothner.com> wrote:
>> On 01/09/2015 08:48 AM, Jeff Gonis wrote:
>>> 
>>> With kawa 2.0, and changing nothing else in my setup, I am unable to
>>> get kawa to create a repl within emacs.
>>> ...
>>> Anyway, please let me know if you need any additional details, or if I
>>> can do any other investigation for you.
>> 
>> 
>> Please give the exact commands you use to launch kawa.
>> --
>>        --Per Bothner
>> per@bothner.com   http://per.bothner.com/
> 
> Hi Per,
> 
> I launch kawa from emacs using the run-scheme function, which depends
> on the variable scheme-program-name.  If I set this to the following:
> java -jar "d://jeffs Folder//kawa//kawa-2.0.jar" -s then I will not be
> able to get a repl inside of emacs.
> 
> If I change scheme-program to: java -jar "d://jeffs
> Folder//kawa//kawa-1.90.jar" -s then I am able to successfully launch
> the repl.  Nothing changes between the two commands besides the
> version of kawa.  Same instance of emacs, same version of java, same
> folder location.
> 
> Thanks for the follow up and please let me know if you need more information.
> Jeff

--
Jamison Hope
The PTR Group
www.theptrgroup.com



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Different behavior for -s argument in Kawa 2.0?
  2015-01-09 22:07     ` Jeff Gonis
  2015-01-09 22:31       ` Jamison Hope
@ 2015-01-09 22:37       ` Per Bothner
  1 sibling, 0 replies; 10+ messages in thread
From: Per Bothner @ 2015-01-09 22:37 UTC (permalink / raw)
  To: Jeff Gonis; +Cc: kawa



On 01/09/2015 02:06 PM, Jeff Gonis wrote:
> I launch kawa from emacs using the run-scheme function, which depends
> on the variable scheme-program-name.  If I set this to the following:
> java -jar "d://jeffs Folder//kawa//kawa-2.0.jar" -s then I will not be
> able to get a repl inside of emacs.
>
> If I change scheme-program to: java -jar "d://jeffs
> Folder//kawa//kawa-1.90.jar" -s then I am able to successfully launch
> the repl.  Nothing changes between the two commands besides the
> version of kawa.  Same instance of emacs, same version of java, same
> folder location.

All I can say is "works for me".

I eval:

(setq scheme-program-name "/opt/jdk1.8/bin/java -jar /home/bothner/Kawa/archive/kawa-2.0.jar -s")

and then I can M-x run-scheme with no problem.

This is emacs 24.4.1 running on (and shipped by) Fedora (with gtk).

It is possible a folder name with a space might cause problems, but
then one would expect the same behavior for 1.90 and 2.0.

-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Different behavior for -s argument in Kawa 2.0?
  2015-01-09 22:31       ` Jamison Hope
@ 2015-01-09 23:05         ` Per Bothner
  2015-01-09 23:39           ` Per Bothner
  0 siblings, 1 reply; 10+ messages in thread
From: Per Bothner @ 2015-01-09 23:05 UTC (permalink / raw)
  To: kawa



On 01/09/2015 02:31 PM, Jamison Hope wrote:
> Jeff, can you try evaluating some expressions to see if you are also just missing the prompt?

If so, it may be useful to evaluate: (current-input-port):class

This should result in: class gnu.kawa.io.TtyInPort

You would not get a prompt otherwise.  And this is controlled by the
haveConsole method in InPort.java, which calls System.console().
It might work for me because I'm on GNU/Linux, and you're on Windows,
and the latter doesn't have try PTYs.  Thus System.console() might
return null in  an Emacs context.

A possible solution is to add a --console flag (similar to
sh's -i flag), which would be the inverse of the --no-console flag,
in that it would force haveConsole to return true.
-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Different behavior for -s argument in Kawa 2.0?
  2015-01-09 23:05         ` Per Bothner
@ 2015-01-09 23:39           ` Per Bothner
  2015-01-10  0:06             ` Per Bothner
  0 siblings, 1 reply; 10+ messages in thread
From: Per Bothner @ 2015-01-09 23:39 UTC (permalink / raw)
  To: kawa, Jeff Gonis

[-- Attachment #1: Type: text/plain, Size: 618 bytes --]



On 01/09/2015 03:04 PM, Per Bothner wrote:
> A possible solution is to add a --console flag (similar to
> sh's -i flag), which would be the inverse of the --no-console flag,
> in that it would force haveConsole to return true.

Please try the attached patch.  You will need to specify --console.
You shouldn't don't need to specify -s.

(BTW one reason this got changed in 2.0 was to support binary input files.
I.e. you can now write a Kawa program that reads a binary file from the standard input port
- but only if InPort.haveConsole() returns false.)
-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

[-- Attachment #2: console.patch --]
[-- Type: text/x-patch, Size: 1664 bytes --]

Index: gnu/kawa/io/InPort.java
===================================================================
--- gnu/kawa/io/InPort.java	(revision 8255)
+++ gnu/kawa/io/InPort.java	(working copy)
@@ -31,11 +31,17 @@
 
 public class InPort extends Reader implements Printable
 {
-    public static boolean noConsole;
+    private static int haveConsole;
 
+    public static void setHaveConsole(boolean value) {
+        haveConsole = value ? 1 : -1;
+    }
+
     public static boolean haveConsole() {
-        if (noConsole)
+        if (haveConsole < 0)
             return false;
+        if (haveConsole > 0)
+            return true;
         /* #ifdef JAVA6 */
         return System.console() != null;
         /* #else */
Index: kawa/GuiConsole.java
===================================================================
--- kawa/GuiConsole.java	(revision 8255)
+++ kawa/GuiConsole.java	(working copy)
@@ -27,7 +27,7 @@
   ReplDocument document;
 
   public static void main(String[] args) {
-    InPort.noConsole = false;
+    InPort.setHaveConsole(true);
     int iArg = repl.processArgs(args, 0, args.length);
     repl.getLanguage();
     repl.setArgs(args, iArg);
Index: kawa/repl.java
===================================================================
--- kawa/repl.java	(revision 8257)
+++ kawa/repl.java	(working copy)
@@ -651,7 +651,9 @@
 	    Compilation.inlineOk = false;
 	  }
         else if (arg.equals("--no-console"))
-          InPort.noConsole = true;
+            InPort.setHaveConsole(false);
+	else if (arg.equals("--console"))
+            InPort.setHaveConsole(true);
 	else if (arg.equals("--inline"))
 	  {
 	    Compilation.inlineOk = true;

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Different behavior for -s argument in Kawa 2.0?
  2015-01-09 23:39           ` Per Bothner
@ 2015-01-10  0:06             ` Per Bothner
  2015-01-10  1:13               ` Per Bothner
  0 siblings, 1 reply; 10+ messages in thread
From: Per Bothner @ 2015-01-10  0:06 UTC (permalink / raw)
  To: kawa



On 01/09/2015 03:39 PM, Per Bothner wrote:
>
>
> On 01/09/2015 03:04 PM, Per Bothner wrote:
>> A possible solution is to add a --console flag (similar to
>> sh's -i flag), which would be the inverse of the --no-console flag,
>> in that it would force haveConsole to return true.
>
> Please try the attached patch.  You will need to specify --console.
> You shouldn't don't need to specify -s.

The patch doesn't work, because setHaveConsole is executed before
InPort is initialized.


-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Different behavior for -s argument in Kawa 2.0?
  2015-01-10  0:06             ` Per Bothner
@ 2015-01-10  1:13               ` Per Bothner
  2015-01-16 18:24                 ` Jeff Gonis
  0 siblings, 1 reply; 10+ messages in thread
From: Per Bothner @ 2015-01-10  1:13 UTC (permalink / raw)
  To: kawa; +Cc: Jeff Gonis

[-- Attachment #1: Type: text/plain, Size: 657 bytes --]

On 01/09/2015 04:06 PM, Per Bothner wrote:
>
>
> On 01/09/2015 03:39 PM, Per Bothner wrote:
>>
>>
>> On 01/09/2015 03:04 PM, Per Bothner wrote:
>>> A possible solution is to add a --console flag (similar to
>>> sh's -i flag), which would be the inverse of the --no-console flag,
>>> in that it would force haveConsole to return true.
>>
>> Please try the attached patch.  You will need to specify --console.
>> You shouldn't don't need to specify -s.
>
> The patch doesn't work, because setHaveConsole is executed before
> InPort is initialized.

Please try the attached console2.patch instead.

-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

[-- Attachment #2: console2.patch --]
[-- Type: text/x-patch, Size: 4280 bytes --]

Index: gnu/Makefile.am
===================================================================
--- gnu/Makefile.am	(revision 8257)
+++ gnu/Makefile.am	(working copy)
@@ -221,6 +221,7 @@
   kawa/io/BinaryOutPort.java \
   kawa/io/CharArrayInPort.java \
   kawa/io/CharArrayOutPort.java \
+  kawa/io/CheckConsole.java \
   kawa/io/FilePath.java \
   kawa/io/InPort.java \
   kawa/io/LogWriter.java \
Index: gnu/Makefile.in
===================================================================
--- gnu/Makefile.in	(revision 8257)
+++ gnu/Makefile.in	(working copy)
@@ -453,6 +453,7 @@
   kawa/io/BinaryOutPort.java \
   kawa/io/CharArrayInPort.java \
   kawa/io/CharArrayOutPort.java \
+  kawa/io/CheckConsole.java \
   kawa/io/FilePath.java \
   kawa/io/InPort.java \
   kawa/io/LogWriter.java \
Index: gnu/kawa/io/CheckConsole.java
===================================================================
--- gnu/kawa/io/CheckConsole.java	(revision 0)
+++ gnu/kawa/io/CheckConsole.java	(working copy)
@@ -0,0 +1,26 @@
+package gnu.kawa.io;
+
+/** Helper class to decide if we have an interactive console.
+ * This needs to be separate from InPort, since the latter uses haveConsole
+ * in its static constructor, but we may need to call setHaveConsole first.
+ */
+
+public class CheckConsole {
+    private static int haveConsole;
+
+    public static void setHaveConsole(boolean value) {
+        haveConsole = value ? 1 : -1;
+    }
+
+    public static boolean haveConsole() {
+        if (haveConsole < 0)
+            return false;
+        if (haveConsole > 0)
+            return true;
+        /* #ifdef JAVA6 */
+        return System.console() != null;
+        /* #else */
+        // return true;
+        /* #endif */
+    }
+}
Index: gnu/kawa/io/InPort.java
===================================================================
--- gnu/kawa/io/InPort.java	(revision 8255)
+++ gnu/kawa/io/InPort.java	(working copy)
@@ -31,23 +31,11 @@
 
 public class InPort extends Reader implements Printable
 {
-    public static boolean noConsole;
-
-    public static boolean haveConsole() {
-        if (noConsole)
-            return false;
-        /* #ifdef JAVA6 */
-        return System.console() != null;
-        /* #else */
-        // return true;
-        /* #endif */
-    }
-
     public static final String systemInFilename = "/dev/stdin";
     private static InPort systemInPort;
     static {
         Path systemInPath = Path.valueOf(systemInFilename);
-        if (haveConsole())
+        if (CheckConsole.haveConsole())
             systemInPort = new TtyInPort(System.in, systemInPath,
                                          OutPort.outInitial);
         else
Index: kawa/GuiConsole.java
===================================================================
--- kawa/GuiConsole.java	(revision 8255)
+++ kawa/GuiConsole.java	(working copy)
@@ -1,5 +1,6 @@
 package kawa;
 
+import gnu.kawa.io.CheckConsole;
 import gnu.kawa.io.InPort;
 import gnu.kawa.io.OutPort;
 import gnu.mapping.*;
@@ -27,7 +28,7 @@
   ReplDocument document;
 
   public static void main(String[] args) {
-    InPort.noConsole = false;
+    CheckConsole.setHaveConsole(true);
     int iArg = repl.processArgs(args, 0, args.length);
     repl.getLanguage();
     repl.setArgs(args, iArg);
Index: kawa/repl.java
===================================================================
--- kawa/repl.java	(revision 8257)
+++ kawa/repl.java	(working copy)
@@ -12,6 +12,7 @@
 import gnu.bytecode.ClassType;
 import gnu.kawa.servlet.HttpRequestContext;
 import gnu.kawa.io.CharArrayInPort;
+import gnu.kawa.io.CheckConsole;
 import gnu.kawa.io.InPort;
 import gnu.kawa.io.OutPort;
 import gnu.kawa.io.Path;
@@ -651,7 +652,9 @@
 	    Compilation.inlineOk = false;
 	  }
         else if (arg.equals("--no-console"))
-          InPort.noConsole = true;
+            CheckConsole.setHaveConsole(false);
+	else if (arg.equals("--console"))
+            CheckConsole.setHaveConsole(true);
 	else if (arg.equals("--inline"))
 	  {
 	    Compilation.inlineOk = true;
@@ -893,7 +896,7 @@
 	    getLanguage();
 	    setArgs (args, iArg);
 	    checkInitFile();
-            if (! InPort.haveConsole())
+            if (! CheckConsole.haveConsole())
               startGuiConsole();
             else
               {

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Different behavior for -s argument in Kawa 2.0?
  2015-01-10  1:13               ` Per Bothner
@ 2015-01-16 18:24                 ` Jeff Gonis
  0 siblings, 0 replies; 10+ messages in thread
From: Jeff Gonis @ 2015-01-16 18:24 UTC (permalink / raw)
  To: kawa

On Fri, Jan 9, 2015 at 6:13 PM, Per Bothner <per@bothner.com> wrote:
>
> On 01/09/2015 04:06 PM, Per Bothner wrote:
>>
>>
>>
>> On 01/09/2015 03:39 PM, Per Bothner wrote:
>>>
>>>
>>>
>>> On 01/09/2015 03:04 PM, Per Bothner wrote:
>>>>
>>>> A possible solution is to add a --console flag (similar to
>>>> sh's -i flag), which would be the inverse of the --no-console flag,
>>>> in that it would force haveConsole to return true.
>>>
>>>
>>> Please try the attached patch.  You will need to specify --console.
>>> You shouldn't don't need to specify -s.
>>
>>
>> The patch doesn't work, because setHaveConsole is executed before
>> InPort is initialized.
>
>
> Please try the attached console2.patch instead.
>
>
> --
>         --Per Bothner
> per@bothner.com   http://per.bothner.com/


Hi Per,

Sorry for the delayed response I was in the moutains for the last few
days, and thus away from a computer.  I built kawa from the 2.0
sources after applying your patch and then ran the resulting jar using
the --console argument in emacs on windows, and I do in fact get the
repl appearing in emacs.  Fantastic!!!  Thank you so much for your
efforts here, I am excited to dig into kawa 2.0 and see what it has to
offer.

Please let me know if there is any other information that I can
provide, or if there is anything else that you would like me to test.
Thanks for your efforts,
Jeff

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2015-01-16 18:24 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CAFVyn8RdRnhc9DGpzT=oA6sQ0oWcbRM71hYvVUROV+7grKkTMQ@mail.gmail.com>
2015-01-09 16:48 ` Different behavior for -s argument in Kawa 2.0? Jeff Gonis
2015-01-09 20:51   ` Per Bothner
2015-01-09 22:07     ` Jeff Gonis
2015-01-09 22:31       ` Jamison Hope
2015-01-09 23:05         ` Per Bothner
2015-01-09 23:39           ` Per Bothner
2015-01-10  0:06             ` Per Bothner
2015-01-10  1:13               ` Per Bothner
2015-01-16 18:24                 ` Jeff Gonis
2015-01-09 22:37       ` Per Bothner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).