Created
March 2, 2015 01:30
-
-
Save johnpauljanecek/2522eb41919d8d5313c5 to your computer and use it in GitHub Desktop.
Client file to be used to communicate with ipython
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require 'epc) | |
(defvar py-epc nil) | |
(defun py-epc:connect (port) | |
(interactive "nEnter py-epc port : ") | |
(setq py-epc (epc:start-epc-debug port)) | |
) | |
(defun py-epc:run-cell-region (start end) | |
(interactive "r") | |
(when py-epc | |
;;(message (buffer-substring-no-properties start end)) | |
(deferred:$ | |
(epc:call-deferred py-epc 'write_err | |
(list "py-epc:run-cell-region\n")) | |
(lambda (x) t) | |
(deferred:$ | |
(epc:call-deferred py-epc 'run_cell | |
(list | |
(buffer-substring-no-properties start end))) | |
(deferred:nextc it | |
(lambda (x) (message "run cell done"))) | |
)))) | |
(defun py-epc:disconnect () | |
(interactive) | |
(epc:stop-epc py-epc) | |
) | |
;;(kbd "s-k s") s on my machine is the windows key | |
(global-set-key (kbd "s-p c") 'py-epc:connect) | |
(global-set-key (kbd "s-p r") 'py-epc:run-cell-region) | |
(global-set-key (kbd "s-p d") 'py-epc:py-epc:disconnect) | |
;;(epc:call-sync py-epc 'ex '("a = 10")) | |
;;(epc:call-sync py-epc 'run_cell '("a = 10\nb=20\n\n")) | |
;;(epc:call-sync py-epc 'set_next_input '("a = 10\nb=20\n")) | |
;;(epc:stop-epc py-epc) | |
;;epc:call-sync py-epc 'ev '("a = 10\nb=20")) | |
;;(epc:call-sync py-epc 'run_cell '("a = 10\nb=20\n\n")) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment