summaryrefslogtreecommitdiff
path: root/init/km-python.el
blob: 9940611186ba844bff58f13a97e52042ff6ae383 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
(defun km/python-shebang ()
  (interactive)
  (km/shebang "python"))

(defconst km/python-analysis-imports
  "import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib import ticker

from colors import brew, fgry, bgry")

(defun km/python-insert-analysis-imports ()
  "Common imports for analysis scripts"
  (interactive)
  (insert km/python-analysis-imports))

(defun km/python-hook ()
  (local-set-key (kbd "C-c p s") 'km/python-shebang)
  (local-set-key (kbd "C-c p a") 'km/python-insert-analysis-imports))
(add-hook 'python-mode-hook 'km/python-hook)

;; http://www.emacswiki.org/emacs/PythonProgrammingInEmacs#toc5
(setq
 python-shell-interpreter "ipython"
 python-shell-interpreter-args ""
 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")