This repository has been archived by the owner on Aug 6, 2021. It is now read-only.
forked from technomancy/emacs-starter-kit
-
Notifications
You must be signed in to change notification settings - Fork 1
/
starter-kit-python.el
85 lines (69 loc) · 2.78 KB
/
starter-kit-python.el
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
;;; starter-kit-python.el --- Some helpful Python code
;;
;; Maybe part of the Emacs Starter Kit ?
(eval-after-load 'python
'(progn
(define-key python-mode-map (kbd "C-m") 'newline-and-indent)
(define-key python-mode-map (kbd "C-M-h") 'backward-kill-word)
(define-key python-mode-map (kbd "C-c l") "lambda")))
;; We never want to edit compiled filed in python mode
(add-to-list 'completion-ignored-extensions ".pyc")
(defun ac-python-mode-setup ()
(setq ac-sources (append '(ac-source-yasnippet) ac-sources)))
(add-hook 'python-mode-hook 'run-coding-hook)
(add-hook 'python-mode-hook 'idle-highlight)
(add-hook 'python-mode-hook 'ac-python-mode-setup)
;; Pymacs (http://pymacs.progiciels-bpi.ca/index.html)
;; Makes it possible to interface emacs lisp with some python code.
(autoload 'pymacs-apply "pymacs")
(autoload 'pymacs-call "pymacs")
(autoload 'pymacs-eval "pymacs" nil t)
(autoload 'pymacs-exec "pymacs" nil t)
(autoload 'pymacs-load "pymacs" nil t)
(eval-after-load 'pymacs
'(progn
(add-to-list 'pymacs-load-path
(concat dotfiles-dir "/elpa-to-submit/pymacs/lib"))
(add-to-list 'load-path
(concat dotfiles-dir "/elpa-to-submit/pymacs/lib"))
))
;; Ropemacs (http://rope.sourceforge.net/ropemacs.html)
;; To get some live (intelligent) completion, documentation and
;; refactoring function.
(eval-after-load 'python
'(progn
;; Setup auto-complete to use Rope
(ac-ropemacs-enable)
(setq ropemacs-enable-autoimport t)
(setq ropemacs-enable-shortcuts nil)
(setq ropemacs-guess-project t)
(add-hook 'python-mode-hook 'ropemacs-mode)
(define-key python-mode-map "\C-cds" 'rope-show-doc)
))
;;; Flymake
;; ~Static code checking
(eval-after-load 'python
'(progn
(require 'flymake)
;; Taken from http://plope.com/Members/chrism/flymake-mode
;;
;; works with http://pypi.python.org/pypi/pyflakes (v>3.0)
;;
;; The first stanza tells flymake to use pyflakes on .py files
;; when in flymake-mode. The second tells emacs to always use
;; flymake as a minor mode when loading buffers so I don't have
;; to type "M-x flymake-mode" to get syntax checking when I load
;; a buffer.
(defun flymake-pyflakes-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name))))
(list "pyflakes" (list local-file))))
(add-to-list 'flymake-allowed-file-name-masks
'("\\.py\\'" flymake-pyflakes-init))
))
(add-hook 'python-mode-hook 'flymake-mode)
(provide 'starter-kit-python)
;; starter-kit-python.el ends here