summaryrefslogtreecommitdiff
path: root/init/km-python.el
blob: ce7aa53e74b2d9a6999c6780c2363980732271fd (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-sysexit ()
  (interactive)
  (insert "sys.exit()"))

(defun km/python-random-assignment ()
  (interactive)
  (km/insert-random-string 10)
  (insert " = None"))

(defun km/python-shebang ()
  (interactive)
  (km/shebang "python"))

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

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 r") 'km/python-random-assignment)
  (local-set-key (kbd "C-c p e") 'km/python-sysexit)
  (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)