diff options
Diffstat (limited to 'conf')
-rw-r--r-- | conf/km-func.el | 20 | ||||
-rw-r--r-- | conf/km-python.el | 18 |
2 files changed, 38 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) |