Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
marvel
GitHub Repository: marvel/qnf
Path: blob/master/elisp/emacs-for-python/epy-init.el
989 views
1
;; This file initializate all the extensions contained in this package
2
3
;; Trick to get the filename of the installation directory
4
(defconst epy-install-dir
5
(file-name-directory (or load-file-name
6
(when (boundp 'bytecomp-filename) bytecomp-filename)
7
buffer-file-name))
8
"Installation directory of python-collection"
9
)
10
11
;;
12
;; Adjust load path to add the following paths
13
;; yasnippet/
14
;; plugins/
15
;; auto-complete
16
17
(add-to-list 'load-path
18
(concat epy-install-dir "yasnippet"))
19
(add-to-list 'load-path
20
(concat epy-install-dir "plugins"))
21
(add-to-list 'load-path
22
(concat epy-install-dir "auto-complete"))
23
(add-to-list 'load-path
24
(concat epy-install-dir "flymake"))
25
26
;;============
27
;; Extensions
28
;;============
29
30
;(setq pymacs-available
31
; (require 'pymacs "pymacs" t))
32
33
;; Yasnippet
34
(require 'yasnippet)
35
36
(yas/initialize)
37
(yas/load-directory (concat epy-install-dir "yasnippet/snippets"))
38
39
(setq yas/prompt-functions '(yas/ido-prompt yas/dropdown-prompt))
40
41
;; Auto-completion
42
(require 'auto-complete-config)
43
(add-to-list 'ac-dictionary-directories
44
(concat epy-install-dir "auto-complete/ac-dict"))
45
(ac-config-default)
46
(define-key ac-mode-map (kbd "M-TAB") 'auto-complete)
47
48
;; Rope, this one is more contrived, we have to check if we have
49
;; pymacs.
50
51
;; First adding to python path custom rope extensions
52
(setenv "PYTHONPATH"
53
(concat
54
(getenv "PYTHONPATH") ":"
55
(concat epy-install-dir "rope-dist")))
56
57
(when (require 'pymacs)
58
(setq pymacs-load-path
59
(list
60
(concat epy-install-dir "rope-dist/ropemacs/")))
61
(pymacs-load "ropemacs" "rope-")
62
(load (concat epy-install-dir "completion/ac-ropemacs-config.el"))
63
64
;; Pretty custom, I've patched ropemode and ropemacs to add this
65
;; hook.
66
;;
67
;; There is also a custom hook to find if there is a project and if
68
;; there is activate it. In this way the project is automatically opened.
69
(add-hook 'rope-open-project-hook 'ac-nropemacs-setup)
70
(setq ropemacs-guess-project t)
71
(setq ropemacs-enable-autoimport t)
72
)
73
74
;; ibuffer by default
75
(global-set-key (kbd "C-x C-b") 'ibuffer)
76
77
;; Ido mode with fuzzy matching
78
(require 'ido)
79
(ido-mode t)
80
(setq ido-enable-flex-matching t) ;; enable fuzzy matching
81
82
;; Parentheses Pairing
83
(setq skeleton-pair t)
84
85
(global-set-key "(" 'skeleton-pair-insert-maybe)
86
(global-set-key "[" 'skeleton-pair-insert-maybe)
87
(global-set-key "{" 'skeleton-pair-insert-maybe)
88
(global-set-key "\"" 'skeleton-pair-insert-maybe)
89
90
;; Open Next Line
91
(require 'open-next-line)
92
93
;; Eshell tweaks
94
;; Visual commands like ipython
95
(add-hook
96
'eshell-mode-hook
97
(lambda ()
98
(setq
99
eshell-visual-commands
100
(append
101
'("mutt"
102
"vim"
103
"screen"
104
"lftp"
105
"ipython"
106
"telnet"
107
"ssh")
108
eshell-visual-commands))))
109
110
;; Virtualenv workon command
111
(require 'virtualenv)
112
113
;; Flymake for python configuration
114
(require 'python-flymake)
115
116
(require 'smart-operator)
117
;;=====================
118
;; Keybindings Section
119
;;=====================
120
121
;; Copy-Cut-Paste from clipboard with Super-C Super-X Super-V
122
(global-set-key (kbd "s-x") 'clipboard-kill-region) ;;cut
123
(global-set-key (kbd "s-c") 'clipboard-kill-ring-save) ;;copy
124
(global-set-key (kbd "s-v") 'clipboard-yank) ;;paste
125
126
;; calc-mode more comfortable
127
(global-set-key (kbd "M-c") 'calc-dispatch)
128
129
; Ctrl+tab mapped to Alt+tab
130
(define-key function-key-map [(control tab)] [?\M-\t])
131
132
(provide 'epy-init)
133