-
Notifications
You must be signed in to change notification settings - Fork 0
/
my-python.el
134 lines (125 loc) · 6.13 KB
/
my-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
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
(autoload 'jedi:setup "jedi" nil t)
(add-hook 'python-mode-hook 'jedi:setup)
(setq jedi:setup-keys t)
g(setq jedi:complete-on-dot t)
;; (autoload 'python-mode "python-mode" "Python Mode." t)
;; (add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode))
;; (add-to-list 'interpreter-mode-alist '("python" . python-mode))
;; (setq interpreter-mode-alist
;; (cons '("python" . python-mode)
;; interpreter-mode-alist)
;; python-mode-hook
;; '(lambda () (progn
;; (set-variable 'py-indent-offset 4)
;; (set-variable 'py-smart-indentation nil)
;; (set-variable 'indent-tabs-mode nil)
;; ;;(highlight-beyond-fill-column)
;; (define-key python-mode-map "\C-m" 'newline-and-indent)
;; (pabbrev-mode)
;; (abbrev-mode))))
;;
;; ;; 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)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Auto-completion
;;; Integrates:
;;; 1) Rope
;;; 2) Yasnippet
;;; all with AutoComplete.el
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; (defun prefix-list-elements (list prefix)
;; (let (value)
;; (nreverse
;; (dolist (element list value)
;; (setq value (cons (format "%s%s" prefix element) value))))))
;; (defvar ac-source-rope
;; '((candidates
;; . (lambda ()
;; (prefix-list-elements (rope-completions) ac-target))))
;; "Source for Rope")
;; (defun ac-python-find ()
;; "Python `ac-find-function'."
;; (require 'thingatpt)
;; (let ((symbol (car-safe (bounds-of-thing-at-point 'symbol))))
;; (if (null symbol)
;; (if (string= "." (buffer-substring (- (point) 1) (point)))
;; (point)
;; nil)
;; symbol)))
;; (defun ac-python-candidate ()
;; "Python `ac-candidates-function'"
;; (let (candidates)
;; (dolist (source ac-sources)
;; (if (symbolp source)
;; (setq source (symbol-value source)))
;; (let* ((ac-limit (or (cdr-safe (assq 'limit source)) ac-limit))
;; (requires (cdr-safe (assq 'requires source)))
;; cand)
;; (if (or (null requires)
;; (>= (length ac-target) requires))
;; (setq cand
;; (delq nil
;; (mapcar (lambda (candidate)
;; (propertize candidate 'source source))
;; (funcall (cdr (assq 'candidates source)))))))
;; (if (and (> ac-limit 1)
;; (> (length cand) ac-limit))
;; (setcdr (nthcdr (1- ac-limit) cand) nil))
;; (setq candidates (append candidates cand))))
;; (delete-dups candidates)))
;; (add-hook 'python-mode-hook
;; (lambda ()
;; (auto-complete-mode 1)
;; (set (make-local-variable 'ac-sources)
;; (append ac-sources '(ac-source-rope) '(ac-source-yasnippet)))
;; (set (make-local-variable 'ac-find-function) 'ac-python-find)
;; (set (make-local-variable 'ac-candidate-function) 'ac-python-candidate;; ;; ;; ;; ;; ;; )
;; (set (make-local-variable 'ac-auto-start) nil)))
;; ;;Ryan's python specific tab completion
;; (defun ryan-python-tab ()
;; ; Try the following: ;; ;;
;; ; 1) Do a yasnippet expansion
;; ; 2) Do a Rope code completion
; 3) Do an indent
;; (interactive)
;; (if (eql (ac-start) 0)
;; (indent-for-tab-command)))
;;
;; (defadvice ac-start (before advice-turn-on-auto-start activate)
;; (set (make-local-variable 'ac-auto-start) t))
;; (defadvice ac-cleanup (after advice-turn-off-auto-start activate)
;; (set (make-local-variable 'ac-auto-start) nil))
;;
;; (define-key python-mode-map "\t" 'ryan-python-tab)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; End Auto Completion
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Python + auto-completion
;(require 'smart-operator)
;; ;; Auto Syntax Error Hightlight
;; (when (load "flymake" t)
;; (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 'find-file-hook 'flymake-find-file-hook)
;;
;;
;; ;(setq ipython-command "/usr/bin/ipython")
;; ;(require 'ipython)
;; ;(setq py-python-command-args '("-colors" "LightBG"))
;; ;(define-key py-mode-map "C-c !" 'py-shell)
;;
(provide 'my-python)