summaryrefslogtreecommitdiff
path: root/init/km-python.el
diff options
context:
space:
mode:
Diffstat (limited to 'init/km-python.el')
-rw-r--r--init/km-python.el34
1 files changed, 34 insertions, 0 deletions
diff --git a/init/km-python.el b/init/km-python.el
new file mode 100644
index 0000000..ce7aa53
--- /dev/null
+++ b/init/km-python.el
@@ -0,0 +1,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)