forked from purcell/emacs.d
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinit-python-mode.el
141 lines (130 loc) · 5.29 KB
/
init-python-mode.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
(require 'python)
(autoload 'doctest-mode "doctest-mode" "Python doctest editing mode." t)
(setq auto-mode-alist
(append '(("\\.py$" . python-mode)
("SConstruct$" . python-mode)
("SConscript$" . python-mode))
auto-mode-alist))
(setq interpreter-mode-alist
(cons '("python" . python-mode) interpreter-mode-alist))
(add-hook 'python-mode-hook
(lambda ()
(make-variable-buffer-local 'tab-width)
(make-variable-buffer-local 'indent-tabs-mode)
(make-variable-buffer-local 'whitespace-style)
(add-hook 'before-save-hook 'whitespace-cleanup nil 'local)
(imenu-add-menubar-index)
(hs-minor-mode t)
(setq
tab-width 2
python-indent 2
indent-tabs-mode t
python-guess-indent nil
whitespace-style '(face
tabs
spaces
trailing
lines
space-before-tab::tab
newline
indentation::tab
empty
space-after-tab::tab
space-mark
tab-mark
newline-mark))))
(defun flymake-python-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 "pycheckers" (list local-file))))
(add-to-list 'flymake-allowed-file-name-masks
'("\\.py\\'" flymake-python-init))
(add-hook 'python-mode-hook
(lambda () (unless (eq buffer-file-name nil) (flymake-mode 1))))
;; Initialize Pymacs
;; (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)
;; Initialize Rope
;; (pymacs-load "ropemacs" "rope-")
;; (setq ropemacs-enable-autoimport t)
;; (ac-ropemacs-initialize)
;; http://gunnarwrobel.de/wiki/Python.html
;; (setq pdb-path '/usr/lib/python2.7/pdb.py
;; gud-pdb-command-name 'pdb)
;; http://lists.gnu.org/archive/html/help-gnu-emacs/2003-10/msg00577.html
;; (defadvice pdb (before gud-query-cmdline activate)
;; "Provide a better default command line when called interactively."
;; (interactive
;; (list (gud-query-cmdline pdb-path
;; (file-name-nondirectory buffer-file-name)))))
;; (add-hook 'python-mode-hook
;; (lambda ()
;; ;; (setq ac-sources (add-to-list 'ac-sources 'ac-source-ropemacs))))
;; (setq ac-sources (add-to-list 'ac-sources))))
;; (add-hook 'python-mode-hook
;; (lambda () (unless (eq buffer-file-name nil) (flymake-mode 1))))
;; http://code.google.com/p/autopair/
;; (add-hook 'python-mode-hook
;; #'(lambda ()
;; (setq autopair-handle-action-fns
;; (list #'autopair-default-handle-action
;; #'autopair-python-triple-quote-action))))
;; python
;; (require 'python)
;; Initialize Pymacs
;; (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)
;; Initialize Rope
;; (pymacs-load "ropemacs" "rope-")
;; (setq ropemacs-enable-autoimport t)
;; (ac-ropemacs-initialize)
;; http://gunnarwrobel.de/wiki/Python.html
;; (setq pdb-path '/usr/lib/python2.7/pdb.py
;; gud-pdb-command-name 'pdb)
;; http://lists.gnu.org/archive/html/help-gnu-emacs/2003-10/msg00577.html
;; (defadvice pdb (before gud-query-cmdline activate)
;; "Provide a better default command line when called interactively."
;; (interactive
;; (list (gud-query-cmdline pdb-path
;; (file-name-nondirectory buffer-file-name)))))
;; (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 "pycheckers" (list local-file))))
;; (add-to-list 'flymake-allowed-file-name-masks
;; '("\\.py\\'" flymake-pyflakes-init))
;; Hooks
;; (add-hook 'python-mode-hook
;; (lambda ()
;; (setq tab-width 4)
;; (setq indent-tabs-mode t)))
;; (add-hook 'python-mode-hook
;; (lambda ()
;; ;; (setq ac-sources (add-to-list 'ac-sources 'ac-source-ropemacs))))
;; (setq ac-sources (add-to-list 'ac-sources))))
;; (add-hook 'python-mode-hook
;; (lambda () (unless (eq buffer-file-name nil) (flymake-mode 1))))
;; http://code.google.com/p/autopair/
;; (add-hook 'python-mode-hook
;; #'(lambda ()
;; (setq autopair-handle-action-fns
;; (list #'autopair-default-handle-action
;; #'autopair-python-triple-quote-action))))
;; (add-hook 'python-mode-hook
;; (lambda ()
;; ;; Scan the file for nested code blocks
;; (imenu-add-menubar-index)
;; (hs-minor-mode t)))
(provide 'init-python-mode)