Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emacs doesn't understand Julian in Windows #5271

Closed
ShuguangSun opened this issue Dec 31, 2013 · 13 comments
Closed

Emacs doesn't understand Julian in Windows #5271

ShuguangSun opened this issue Dec 31, 2013 · 13 comments
Labels
system:windows Affects only Windows

Comments

@ShuguangSun
Copy link

Emacs 24.3.50 + Win 7 (32 bit)
Julia 0.2.0-rc4

When I start shell (M-x shell) and run julia.bat or julia-baisic, I cann't see the prompt "julia>". But I can run julia script/command after that. When I want exit jula, I need to type exit() return and return again.

I run test-julia.bat in emacs cmd shell and got "�[32;1mSUCCESS�[0m".

In ESS, when I run julia by M-x Julia, emacs/ESS got frozen. I can use C-g to escape, and I have the Julia buffer, and threre is a running julia process for that buffer, and I can run julia script/command in this buffer. When I want to exit julia, I can type C-c C-q, which will pass "exit()" to julia, but I need to hit an additional return in the Julia buffer (the same issue with cmd shell).

I tried these code:

function run()
    ssize = 10000
end
for i in 1:4
    print("$(@elapsed run())  ")
end
function run()
    ssize = 10000
end
for i in 1:4
    print("$(@elapsed run())  ")
end

I can get:

run (generic function with 1 method)
7.9e-7  7.9e-7  7.9e-7  3.95e-7  run (generic function with 1 method)
0.0  0.0  3.95e-7  0.0

There seems a "return" is missing after the output in emacs cmd shell.

@vtjnash
Copy link
Member

vtjnash commented Jan 3, 2014

related to #4589

@ShuguangSun
Copy link
Author

The emacs is not under cygwin, but windows/gtk, you can find at
http://ftp.gnu.org/gnu/emacs/windows/
or
http://sourceforge.net/projects/emacs-bin/files/snapshots/

@xificurC
Copy link

I get the same behavior under windows.

@vtjnash
Copy link
Member

vtjnash commented Oct 11, 2014

since #4589 is now closed, can you post the string returned from calling uv_pipe_getsockname
https://github.com/joyent/libuv/blob/49cb40c47902dd04c7787e6543e9e13368dc1840/include/uv.h#L1266

@vtjnash vtjnash closed this as completed Nov 16, 2014
@vtjnash
Copy link
Member

vtjnash commented Nov 16, 2014

closing due to non-response. perhaps this is now fixed?

@fradav
Copy link

fradav commented Jul 16, 2015

No it is not fixed at all. The problem is that julia’s REPL (even the BasicREPL) expects a Base.TTY on its stdin/stdout/stderr, and emacs can’t give it on windows (non-cygwin).
But there is an easy workaround, just load (-L) julia with this :

using Base.Terminals: UnixTerminal
using Base.REPL: BasicREPL, run_repl

type PipeTerminal <: UnixTerminal
    in_stream::Base.Pipe
    out_stream::Base.Pipe
    err_stream::Base.Pipe
end

run_repl(BasicREPL(PipeTerminal(STDIN,STDOUT,STDERR)))

And then ESS/julia works.

@pao
Copy link
Member

pao commented Jul 16, 2015

That seems helpful--I'm not completely familiar with the pieces to this puzzle, but is there a place we can fit it in where this would Just Work? If so it would be great to have a pull request which puts this all together.

@fradav
Copy link

fradav commented Jul 16, 2015

Fixing it from the emacs side is easy : put the above code in <yourfile.jl> and

(setq inferior-julia-args "-L <yourfile.jl>")

in your .emacs.

Fixing it from the julia side is a different story (it involves modifying the base repl.jl file in order to detect if we are in a situation which requires Base.Pipe instead of Base.TTY for terminal handling AND to test if it doesn't break anything else...).
The real question is : is there a real need for this ?

@pao
Copy link
Member

pao commented Jul 16, 2015

Is the Emacs code something that would fit into julia-mode.el? Can we drop this little scrap in contrib/? Do we have an appropriate README?

I'm just looking for ways to break this out of a string of GitHub issue comments is all.

@vtjnash
Copy link
Member

vtjnash commented Jul 16, 2015

is there any way to detect this from the julia side? for example, for cygwin pipes, we do a string comparison against the name of the pipe to determine if it came from a cygwin process.

@ShuguangSun
Copy link
Author

It seems the code doesn't work for Julia 0.4 dev. Emacs hang and when I run it in Julia terminal, I got error message:

ERROR: LoadError: MethodError: `convert` has no method matching convert(::Type{Base.Pipe}, ::IOStream)
This may have arisen from a call to the constructor Base.Pipe(...),
since type constructors fall back to convert methods.
Closest candidates are:
  Base.Pipe(::Any)
  call{T}(::Type{T}, ::Any)
  convert{T}(::Type{T}, !Matched::T)
  ...
 in call at c:\Users\user\HOME\_julia:5
 in include at boot.jl:259
 in include_from_node1 at loading.jl:267
 in process_options at client.jl:308
 in _start at client.jl:411
while loading c:\Users\user\HOME\_julia, in expression starting on line 10

@vtjnash
Copy link
Member

vtjnash commented Aug 25, 2015

rather than Base.Pipe in the above example, I would use simply IO.

@ShuguangSun
Copy link
Author

'IO' works for Julia 0.4 dev + Emacs 20.0.50.1.
It needs the full path to the load file "<yourfile.jl>" if it is not under current directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
system:windows Affects only Windows
Projects
None yet
Development

No branches or pull requests

5 participants