summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--conf/km-func.el20
-rw-r--r--conf/km-python.el18
-rw-r--r--init.el1
3 files changed, 39 insertions, 0 deletions
diff --git a/conf/km-func.el b/conf/km-func.el
index 48a2f35..3366363 100644
--- a/conf/km-func.el
+++ b/conf/km-func.el
@@ -25,3 +25,23 @@
name (file-name-nondirectory new-name)))))))
(global-set-key (kbd "C-x C-r") 'km/rename-current-buffer-file)
+
+(defun km/shebang (&optional lang)
+ (interactive "s\language (default python):")
+ (if (= (length lang) 0)
+ (setq lang "python"))
+ (insert "#!/usr/bin/env " lang "\n"))
+(global-set-key (kbd "C-c s") 'km/shebang)
+
+(defun km/insert-random-string (&optional strlen)
+ "Insert a random string (default length: 5)"
+ (interactive)
+ (unless strlen
+ (setq strlen 5))
+ (let (mycharset (ii 0) )
+ (setq mycharset ["a" "b" "c" "d" "e" "f" "g" "h" "i"
+ "j" "k" "l" "m" "n" "o" "p" "q" "r"
+ "s" "t" "u" "v" "w" "x" "y" "z"])
+ (while (< ii strlen)
+ (insert (elt mycharset (random (length mycharset))))
+ (setq ii (1+ ii)))))
diff --git a/conf/km-python.el b/conf/km-python.el
new file mode 100644
index 0000000..f3d1b08
--- /dev/null
+++ b/conf/km-python.el
@@ -0,0 +1,18 @@
+(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"))
+
+(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))
+(add-hook 'python-mode-hook 'km/python-hook)
diff --git a/init.el b/init.el
index 1fadcb6..cf2cfe2 100644
--- a/init.el
+++ b/init.el
@@ -12,6 +12,7 @@
(load "km-evil.el")
(load "km-ibuffer.el")
(load "km-ido.el")
+(load "km-python.el")
(load "km-haskell.el")
(load "km-tex.el")
(message ":: Init complete")