Code Monkey home page Code Monkey logo

Comments (13)

jtmoulia avatar jtmoulia commented on June 24, 2024

Hey @andreas-roehler -- I just tried your example in the IEx prompt started by elixir-mode-iex and found the same issue. I'd give that a try, and if you find that you still have the issue then elixir-lang/emacs-elixir is probably the culprit rather than alchemist.

from alchemist.el.

jtmoulia avatar jtmoulia commented on June 24, 2024

Sorry -- scratch what I said. What command are you using for newlines? I found that I was actually using electric-newline-maybe-indent. comint-send-input, however, works like a charm.

from alchemist.el.

andreas-roehler avatar andreas-roehler commented on June 24, 2024

So do I, after "end" RET, which does comint-send-input. Still hangs...

from alchemist.el.

andreas-roehler avatar andreas-roehler commented on June 24, 2024

BTW: it's the only example bug shows up - commonly iex works well from alchemist.

from alchemist.el.

tonini avatar tonini commented on June 24, 2024

@andreas-roehler thanks for reporting, this looks really like a bug and I'll try to find the issue.

Thanks @jtmoulia for helping ❤️

from alchemist.el.

gleb avatar gleb commented on June 24, 2024

I did some investigating and somehow comint and IEx don't get along.

Here's the minimal test case:

(apply 'make-comint "IEX"
              "/usr/local/bin/iex" nil nil)

got to IEX buffer and paste

"""
foo
"""

and IEX appears to hang.

Erl works fine.

(apply 'make-comint "ERL"
              "/usr/bin/erl" nil nil)

and paste

"""
foo
"""
.

I was wondering if it was something about the prompt. To rule it out I setup .iex.exs

IEx.configure(alive_prompt: "%counter>", default_prompt: "%counter>",)

This makes IEx prompt the same as erl's default prompt. Still hangs with multiline input.

from alchemist.el.

gleb avatar gleb commented on June 24, 2024

The problem may be in IEx itself.

iex | cat

paste a multi-line expression, get a hang

from alchemist.el.

gleb avatar gleb commented on June 24, 2024

Jose confirms problem in IEx:
https://groups.google.com/forum/#!topic/elixir-lang-talk/HoTY3YZP3y8

from alchemist.el.

tonini avatar tonini commented on June 24, 2024

Thanks a lot guys for all the effort you put into hunting the issue.

My apology for respond a but late, but all these holidays and my kids were ill too made my days a bit busy. :-)

I have kind of an idea to fix this issue, I'll get back to you if I have a branch for testing ready.

from alchemist.el.

gleb avatar gleb commented on June 24, 2024

@tonini What's the idea? Tell us more :-)

Still waiting for a reply from Jose on what's the underlying problem with IEx.

Meanwhile I hacked together an IEx wrapper script that seems to workaround the problem. The idea is to always wait for a prompt (maybe secondary prompt) before sending another line of input. Seems to work, even if there are potential corner case correctness issues.

Edit: cleaned up the script

#!/usr/bin/env ruby

# based on http://stackoverflow.com/questions/2730642/wrapper-around-bash-control-stdin-and-stdout

require 'pty'
require 'thread'

mutex = Mutex.new
saw_prompt = ConditionVariable.new

system('stty -echo') if ENV['Emacs']

PTY.spawn("/usr/local/bin/iex") do |p_read, p_write|
  Thread.new do
    loop do
      mutex.synchronize {
        saw_prompt.wait(mutex)
        input = STDIN.gets
#      puts "== read from STDIN: #{input}"
#      STDOUT.flush
        p_write.print input
#      puts "== wrote to process: #{input}"
      }
    end
  end

  loop do
    output = p_read.sysread(512)
#    puts "== read from process: #{output}"
    print output
#    puts "wrote to STDOUT: #{output}"
    STDOUT.flush
    saw_prompt.signal if output.include?("iex(") || output.include?("...(")
  end
end

from alchemist.el.

tonini avatar tonini commented on June 24, 2024

@gleb If the underlaying problem could be fixed Elixir wise that would be great!

On the other hand I realized that there is an issue that we have to wait until the IEx prompt is showed up again after an input. So what I did is sending just always one line to the running IEx process instead the whole block including newlines and then always wait until the prompt is visible again. Works actually solid so far.

I will push the branch soon so you guys could test it.

from alchemist.el.

tonini avatar tonini commented on June 24, 2024

@gleb @andreas-roehler is fixed on master

from alchemist.el.

gleb avatar gleb commented on June 24, 2024

@tonini Works for me. Thanks! Will use/test it more, and let you know if anything comes up.

from alchemist.el.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.