diff options
author | Kyle Meyer <meyerkya@gmail.com> | 2013-01-09 11:43:10 -0500 |
---|---|---|
committer | Kyle Meyer <meyerkya@gmail.com> | 2013-01-09 12:06:26 -0500 |
commit | f5238f044d2f142f1940b93e3761e1f5bfd7ef7c (patch) | |
tree | f8891973414827fcd50768c7eefd425f2ac8fae7 | |
parent | e4028f83dab75489a0bd8fe0e2a8fa4abf2a95ee (diff) | |
download | emacs.d-f5238f044d2f142f1940b93e3761e1f5bfd7ef7c.tar.gz |
py functions: random assingment, shebang, exit
-rw-r--r-- | conf/km-func.el | 20 | ||||
-rw-r--r-- | conf/km-python.el | 18 | ||||
-rw-r--r-- | init.el | 1 |
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) @@ -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") |