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

How to convert shell to python shell? #2043

Open
fkgruber opened this issue Apr 30, 2024 · 2 comments
Open

How to convert shell to python shell? #2043

fkgruber opened this issue Apr 30, 2024 · 2 comments

Comments

@fkgruber
Copy link

Hi
I would like to run python on a shell buffer and then convert this shell to a python buffer so I can use elpy with it.
Essentially I'm looking for something equivalent to ess-remote for R where you can can convert a shell buffer running R into an R inferior.

By the way, the reason I want to do this is that I want to run python inside a screen session.

So far the best I have is to add the python-shell-eval-setup-code and python-shell-eval-file-setup-code and change the name of the buffer. This kind of work but sending a line to the inferior is super slow. takes several seconds so something is not right. But I don't know what other variables we should be setting.

(defun python-remote()
  (interactive)
  "convert python running on a shell into an python inferior so you can use elpy"
  (end-of-buffer)
  (insert python-shell-eval-setup-code)
  (comint-send-input)
  (comint-send-input)
  (end-of-buffer)
  (insert python-shell-eval-file-setup-code)
  (comint-send-input)
  (comint-send-input)
  (end-of-buffer)
  (inferior-python-mode)
  )
@gopar
Copy link
Collaborator

gopar commented Apr 30, 2024

Not sure I understand, but there is a built in command run-python that will open up a python shell. Having elpy running a pyhton shell (from what I remember) isn't suitable b/c of lag/issues that have come up (again, my memory is fuzzy on this).

If you need to customize shell things, they're available via python-shell-* variables.

@fkgruber
Copy link
Author

I will be working on a remote machine. I want to start a shell, and run screen on it so it becomes persistent. Then I want to run python on that shell.

This way in the future when I reopen emacs I can connect to the remote server, open a shell, reattach to the screen and I will be back to the python session.

I don't see why it wold not be possible to convert the shell to a python inferior just like the one generated by run-python. I just don't know what variables need to be set and to what.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants