ffevotte / isend-mode.el

Interactively send parts of an Emacs buffer to an interpreter
77 stars 17 forks source link

Not working with the latest IPython console (moved away from pyreadline) #6

Closed amelio-vazquez-reina closed 8 years ago

amelio-vazquez-reina commented 8 years ago

Hi, I have been using isend-modewith ansi-term terminals in Emacs very happily for several years now and after upgrading IPython to the latest version 5.0 it stopped working. It looks like they moved away from pyreadline to something called prompt_toollkit.

Any thoughts on what could be going on ?

amelio-vazquez-reina commented 8 years ago

It's actually odd. It's not that I get any errors or anything. It's just that it sometimes (most of the times) it doesn't send anything, but sometimes it does..

amelio-vazquez-reina commented 8 years ago

In case it's helpful, here is the package that IPython relies on for its terminal: Python Prompt Toolkit. It actually seems to include some code to manage Emacs terms properly.

amelio-vazquez-reina commented 8 years ago

Also, to clarify, why I say it doesn't work, I specifically mean that, If I do C-RET on a given line, it most of the times just duplicates the current line without sending code (or %paste in my case) to it. E.g. of trying several times:

screen shot 2016-07-17 at 12 50 42 am
amelio-vazquez-reina commented 8 years ago

Thanks @ffevotte. No problem at all! (responding here since I think this thread has a better description of the actual problem)

It all happens very quickly, but:

  1. I see "%paste" (or %cpaste, whichever I am using) inserted in the terminal. I see it at the bottom of the buffer for a fraction of a second (i.e. not where the current prompt is).
  2. Python reacts to it as if only a RET had been inserted. I know this since it just creates a new line with the same prompt index, as in the screenshot above, and that's exactly what IPython does when you just manually enter RET in the prompt (the index doesn't go up, it just creates a new line).
  3. I don't see any Python code expanded from the clipboard. This makes sense, since as per my point (2) above IPython seems to only be interpreting a RET, i.e. it does not see the %paste so it can't expand it.

Does that make sense?

On a related note, in case you don't know this already, one super fast way of testing any Python package is to use anaconda MIT license to install binaries directly. You can have virtual envs. choose which version of what package to install etc.

albertstartup commented 7 years ago

@amelio-vazquez-reina I encountered the same problem as you. The solution is to make the ipython repl reach past the bottom of the buffer. The way i solved this is by commenting line 272: (goto-char (point-max))

albertstartup commented 7 years ago

I would like to send a pull request, but I dont know if there are cases where going to "point-max" is nessesary. If not, then the solution would be just to remove that line. Either way i just override the function in my init file after loading isend-mode.

albertstartup commented 7 years ago

Instead of (point-max) it should be (process-mark (get-buffer-process (current-buffer)))

ffevotte commented 7 years ago

@albertstartup Thanks for your feedback. Have you also read #8 (not sure exactly why, but this discussion has been split into two parts...)

I agree that your fix should be the correct thing to do. But from the end of the discussion in #8, it looked like it wasn't necessary for recent Emacs versions...