2

I recently started using emacs to code in Python. I currently prefer to use python mode (defined in python.el) alongside ansi-term for the python interactive shell. I'm trying to change the behavior of C-c C-c in python mode so it sends the buffer into ansi-term to be executed. That is, I'd like it to act as if I wrote 'execfile([current .py file i'm working on])' in the ansi-term.

Is there a way to do this? If not specifically through C-c C-c, with some other shortcut/method?

dieggsy
  • 475
  • 2
  • 10
  • 1
    The problem is that you could have many ansi-terms open at the same time, so finding the right one would require more thinking, but suppose you want it to be the one called `*term`* already running Python interpreter, then `(let ((f (buffer-file-name))) (with-current-buffer "*term*" (insert (format "execfile(['%s'])" f) (term-send-input)))`, and then bind this to whatever key you want. – wvxvw Jan 04 '16 at 06:17
  • 1
    Have you looked at [isend](https://github.com/ffevotte/isend-mode.el)? – user2699 Jan 04 '16 at 14:25
  • [How to define a function that calls a console process using ansi-term?](http://emacs.stackexchange.com/q/18672/454) may also be of interest. – phils Jan 04 '16 at 20:19

0 Answers0