[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: py-execute-region temporary buffers
From: |
Michael Albinus |
Subject: |
Re: py-execute-region temporary buffers |
Date: |
Mon, 26 Sep 2011 22:31:55 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) |
Paul Northug <address@hidden> writes:
> I am using ipython shell through tramp through multi-hop ssh. It works
> very well (thank you developers!)
>
> I am missing the py-execute-region functionality. When I mark a region
> and do C-c |, a temporary local file of the region is created that is
> passed on to the running python interpreter and executed. Through
> tramp, a local file is created rather than a remote file and the
> remote python shell complains for example:
>
> IOError: [Errno 2] No such file or directory:
> '/var/folders/0l/rbzbq01d1yz3ysh8dbhgrl5h0000gn/T/python-35908Jta.py'
>
> I was wondering if this functionality could be added somehow.
First, I have no experience with python/ipython at all.
Looking at python.el from Emacs 24.0.90, the following change might do
the trick:
--8<---------------cut here---------------start------------->8---
*** /home/albinus/src/emacs/lisp/progmodes/python.el.~105925~ 2011-09-26
22:09:16.993851430 +0200
--- /home/albinus/src/emacs/lisp/progmodes/python.el 2011-09-26
22:09:03.783832044 +0200
***************
*** 1616,1622 ****
;; Fixme: Write a `coding' header to the temp file if the region is
;; non-ASCII.
(interactive "r")
! (let* ((f (make-temp-file "py"))
(command
;; IPython puts the FakeModule module into __main__ so
;; emacs.eexecfile becomes useless.
--- 1616,1622 ----
;; Fixme: Write a `coding' header to the temp file if the region is
;; non-ASCII.
(interactive "r")
! (let* ((f (concat (file-remote-p default-directory) (make-temp-file "py")))
(command
;; IPython puts the FakeModule module into __main__ so
;; emacs.eexecfile becomes useless.
--8<---------------cut here---------------end--------------->8---
However, this could not be a final solution. make-temp-file should be
enhanced to work also on remote hosts, checking for the existence of a
temporary file etc.
If you use python-mode.el, it might be sufficient to customize
py-temp-directory.
Best regards, Michael.