diff options
| -rw-r--r-- | lisp/ravi-init-python.el | 29 | ||||
| -rw-r--r-- | snippets/org-mode/ipython_block.snippet | 7 |
2 files changed, 27 insertions, 9 deletions
diff --git a/lisp/ravi-init-python.el b/lisp/ravi-init-python.el index 70118f7..100b448 100644 --- a/lisp/ravi-init-python.el +++ b/lisp/ravi-init-python.el @@ -31,8 +31,9 @@ (progn (add-hook 'python-mode-hook 'ravi/python-mode-hook) - (defun ravi/python-mode-hook() - ;; Set ipython as our interpreter + + (defun ravi/old-ipython-setup () + "Set up ipython interpreter for version less than 4, which works with readline" (setq python-shell-interpreter "ipython" python-shell-interpreter-args "--pylab" python-shell-prompt-regexp "In \\[[0-9]+\\]: " @@ -43,13 +44,23 @@ "';'.join(module_completion('''%s'''))\n" python-shell-completion-string-code "';'.join(get_ipython().Completer.all_completions('''%s'''))\n" - ) - - ;; For ipython 0.10, uncomment the following: - ;; (setq python-shell-completion-string-code - ;; "';'.join(__IP.complete('''%s'''))\n" - ;; python-shell-completion-module-string-code "" - ;; ) + )) + (defun ravi/ipython-5p4plus-setup () + "Set up ipython interpreter for version 5.4+ which requires rlipython to be installed" + (setq python-shell-interpreter "ipython" + python-shell-interpreter-args "--pylab --TerminalIPythonApp.interactive_shell_class=rlipython.TerminalInteractiveShell" + python-shell-prompt-regexp "In \\[[0-9]+\\]: " + python-shell-prompt-output-regexp "Out\\[[0-9]+\\]: " + python-shell-completion-setup-code + "from IPython.core.completerlib import module_completion" + python-shell-completion-module-string-code + "';'.join(module_completion('''%s'''))\n" + python-shell-completion-string-code + "';'.join(get_ipython().Completer.all_completions('''%s'''))\n" + )) + (defun ravi/python-mode-hook() + ;; Set ipython as our interpreter + (ravi/old-ipython-setup) (when (functionp 'helm-dash) (setq-local helm-dash-docsets '("Python 2" "NumPy"))) diff --git a/snippets/org-mode/ipython_block.snippet b/snippets/org-mode/ipython_block.snippet new file mode 100644 index 0000000..8d4d4dc --- /dev/null +++ b/snippets/org-mode/ipython_block.snippet @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: ipython block +# key: ipy +# -- +#+BEGIN_SRC ipython :session ${1::file ${2:$$(let ((temporary-file-directory "./")) (make-temp-file "py" nil ".png"))} }:exports ${3:both} +$0 +#+END_SRC |
