/
my-programming.el
310 lines (286 loc) · 8.98 KB
/
my-programming.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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
;; -*- coding:utf-8 -*-
;; dsvn(equivalent to tortoisesvn)
;;
;; (require 'vc-svn)
;;
;; magit
;;
(when (my-try-require 'magit)
(global-set-key (kbd "C-x C-g") 'magit-status)
;; unable to detect end of process in magit process buffer?!
;; discussion found https://github.com/magit/magit/issues/18
;; but no help. :(
;; (setq magit-process-connection-type nil)
)
;;
;; nXML mode
;;
;; (progn
;; (add-to-list 'load-path "~/elisp/nxml")
;; (load "rng-auto")
;; (add-to-list 'auto-mode-alist '("\\.\\(xml\\|xsl\\|rng\\|xhtml\\)\\'" . nxml-mode) nil)
;; (setq nxml-child-indent 4))))
;;
;; emacs lisp
;;
;; (require 'rainbow-delimiters)
;; (add-hook 'emacs-lisp-mode-hook
;; '(lambda ()
;; (interactive)
;; ;; (require 'eldoc)
;; ;; (turn-on-eldoc-mode)
;; (rainbow-delimiters-mode t)
;; ))
;;
;; ruby mode
;;
(autoload 'ruby-mode "ruby-mode" "Major mode for ruby files" t)
(add-to-list 'auto-mode-alist '("\\.rb$" . ruby-mode))
(add-to-list 'interpreter-mode-alist '("ruby" . ruby-mode))
;;
;; qml-mode
;;
(when (my-try-require 'qml-mode)
(add-to-list 'auto-mode-alist '("\\.qml$" . qml-mode))
(modify-coding-system-alist 'file "\\.qml$" 'utf-8)
)
;;
;; markdown
;;
(unless macp
(progn
(autoload 'markdown-mode "markdown-mode.el"
"Major mode for editing Markdown files" t)
(setq auto-mode-alist
(cons '("README" . markdown-mode) auto-mode-alist))
(setq auto-mode-alist
(cons '("\\.text" . markdown-mode) auto-mode-alist))))
;;
;; Visual-Basic-Mode
;;
;; (if (and win32p officep)
;; (progn
;; (autoload 'visual-basic-mode "visual-basic-mode" "Visual Basic mode." t)
;; (add-to-list 'auto-mode-alist '("\\.\\(vbs\\|frm\\|bas\\|cls\\)$" . visual-basic-mode) nil)
;; (setq-default visual-basic-allow-single-line-if nil
;; visual-basic-capitalize-keywords-p t
;; visual-basic-fontify-p t
;; visual-basic-ide-pathname (quote c:devvs6vb98vb6\.exe)
;; visual-basic-mode-indent 4
;; visual-basic-wild-files "*.frm *.bas *.cls *.vbs *.wsf *.wsc")))
;; ;;
;; ;; Lua Mode
;; ;;
;; (defun my-lua-mode-hook ()
;; (setq indent-tabs-mode nil)
;; (if (string= (file-name-extension (buffer-file-name)) "wlua")
;; (set (make-local-variable 'lua-default-application) "c:\\dev\\lua\\wlua.exe")))
;; (setq my-lua-file-ext-regexp (regexp-opt '("wlua" "lua")))
;; (if t ;;(and win32p officep)
;; (progn
;; (autoload 'lua-mode "lua-mode" "Lua mode." t)
;; (setq-default lua-default-command-switches '("-i"))
;; (add-to-list 'auto-mode-alist `'(,my-lua-file-ext-regexp . lua-mode) nil)
;; (setq-default lua-default-application "c:\\dev\\lua\\lua.exe")))
;; ;;(setq-default lua-default-application (if win32p "c:/msys/1.0/local/bin/lua" "/home/rp)
;; ;;(add-hook 'lua-mode-hook (lambda () ))
;; ediff
(eval-after-load "ediff"
'(progn
(setq
;; ediff-window-setup-function 'ediff-setup-windows-plain
ediff-window-setup-function 'ediff-setup-windows-multiframe
ediff-split-window-function 'split-window-horizontally
ediff-make-buffers-readonly-at-startup t
)
(cond
(win32p
(setq ediff-diff-program "c:/dev/gnuwin32/bin/diff.exe")))
))
;; compilation-mode
(eval-after-load "compile"
'(progn
(defun my-compilation-setup()
(setq
truncate-lines t
compilation-scroll-output t
compilation-window-height 15)
)
(add-hook 'compilation-mode-hook 'my-compilation-setup)
))
;;
;; cmake
;;
(when (my-try-require 'cmake-mode)
(require 'cmake-mode)
(setq auto-mode-alist
(append '(
("CMakeLists\\.txt\\'" . cmake-mode)
("\\.cmake\\'" . cmake-mode)
)
auto-mode-alist))
)
;;
;; eshell
;;
(if win32p
(defun eshell/op (FILE)
"Invoke (w32-shell-execute \"Open\" FILE) and substitute slashes for backslashes.
i.e: c:/home $ op test.xls ==> open test.xls in excel!!!"
(w32-shell-execute "Open" (substitute ?\\ ?/ (expand-file-name FILE)))))
;;
;; graphviz
;;
(eval-after-load "graphviz-dot-mode"
'(progn
(cond
((and win32p officep)
(progn
(setq
graphviz-dot-dot-program "c:\\dev\\graphviz\\bin\\dot.exe"
graphviz-dot-indent-width 4
graphviz-dot-preview-extension "gif"
))))))
;;
;; python
;;
(eval-after-load "python"
'(progn
;; hint from http://www.saltycrane.com/blog/2010/05/my-emacs-python-environment/
(require 'pymacs)
(pymacs-load "ropemacs" "rope-")
(setq ropemacs-enable-autoimport t)
(add-to-list 'load-path "~/.emacs.d/vendor/auto-complete-1.2")
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories "~/.emacs.d/vendor/auto-complete-1.2/dict")
(ac-config-default)
(add-hook 'find-file-hook 'flymake-find-file-hook)
(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 "pycheckers" (list local-file))))
(add-to-list 'flymake-allowed-file-name-masks
'("\\.py\\'" flymake-pyflakes-init)))
;; (load-library "flymake-fringe-icons")
(global-set-key (kbd "C-c C-p") 'flymake-goto-prev-error)
(global-set-key (kbd "C-c C-n") 'flymake-goto-next-error)
(defun my-electric-pair ()
"Insert character pair without sournding spaces"
(interactive)
(let (parens-require-spaces)
(insert-pair)))
(defun my-python-display-shell ()
(interactive)
(if (featurep 'popwin)
(popwin:display-buffer "*Python*")
(display-buffer "*Python*")))
(defun my-python-send-buffer ()
(interactive)
(python-send-buffer)
(when (featurep 'popwin)
(popwin:display-buffer "*Python*")))
(define-key python-mode-map (kbd "\C-c\C-c") 'my-python-send-buffer)
(define-key python-mode-map (kbd "\C-c!") 'my-python-display-shell)
(defun my-python-mode-hook ()
;; (define-key python-mode-map "\"" 'my-electric-pair)
;; (define-key python-mode-map "\'" 'my-electric-pair)
;; (define-key python-mode-map "(" 'my-electric-pair)
;; (define-key python-mode-map "[" 'my-electric-pair)
;; (define-key python-mode-map "{" 'my-electric-pair)
(setq
indent-tabs-mode nil
tab-width 4
python-remove-cwd-from-path nil
)
(flymake-mode 1)
(eldoc-mode 1)
)
(add-hook 'python-mode-hook 'my-python-mode-hook)
)
)
;; (defun my-py-execute-buffer (&optional shell dedicated switch)
;; (interactive)
;; (sit-for 1.)
;; (py-execute-buffer shell dedicated switch)
;; (popwin:display-buffer "*Python*")
;; )
;; (defun my-py-shell (&optional argprompt dedicated pyshellname switch sepchar)
;; (interactive "P")
;; (let ((py-shell-process (py-shell argprompt dedicated pyshellname switch sepchar)))
;; (when (functionp 'popwin:display-buffer)
;; (popwin:display-buffer (process-buffer py-shell-process)))
;; ))
;; (define-key python-mode-map (kbd "\C-c\C-c") 'my-py-execute-buffer)
;; (define-key python-mode-map (kbd "\C-c!") 'my-py-shell)
;; (define-key python-mode-map (kbd "\C-c\C-z") 'my-py-shell)
;; (eval-after-load "python-mode"
;; '(progn
;; (setq
;; ;; disable python-mode to pop up buffer
;; py-split-windows-on-execute-p nil
;; py-shell-switch-buffers-on-execute-p nil
;; )
;; (cond
;; (macp
;; (setq python-python-command "python")
;; )
;; (t
;; (setq python-python-command "c:/dev/python26/python.exe")
;; )
;; )
;; (defun my-python-mode-hook ()
;; (setq
;; py-shell-name "python"
;; py-shell-toggle-1 "python3"
;; py-shell-toggle-2 "python"
;; )
;; (call-interactively 'py-switch-shell)
;; )
;; (add-hook 'python-mode-hook 'my-python-mode-hook)
;; ))
;;;; flymake
;;
(eval-after-load "flymake"
'(progn
(setq
;; i hate gui style warning
flymake-gui-warnings-enabled nil
;; -1 = NONE, 0 = ERROR, 1 = WARNING, 2 = INFO, 3 = DEBUG
flymake-log-level 0
flymake-allowed-file-name-masks '(;; ("^\\.emacs$" flymake-for-el-init)
;; (".+\\.el$" flymake-for-el-init)
;; ("\\.py\\'" flymake-pyflakes-init)
;; (".+\\.scss$" flymake-scss-init)
;; ("\\.\\(?:c\\(?:pp\\|xx\\|\\+\\+\\)?\\|CC\\)\\'" flymake-simple-make-init)
;; ("\\.xml\\'" flymake-xml-init)
;; ("\\.html?\\'" flymake-xml-init)
;; ("\\.cs\\'" flymake-simple-make-init)
;; ("\\.p[ml]\\'" flymake-perl-init)
;; ("\\.php[345]?\\'" flymake-php-init)
;; ("\\.h\\'" flymake-master-make-header-init flymake-master-cleanup)
;; ("\\.java\\'" flymake-simple-make-java-init flymake-simple-java-cleanup)
;; ("[0-9]+\\.tex\\'" flymake-master-tex-init flymake-master-cleanup)
;; ("\\.tex\\'" flymake-simple-tex-init)
;; ("\\.idl\\'" flymake-simple-make-init)
)
)))
;;
;; plantuml
;;
(eval-after-load "plantuml"
(progn
(setq plantuml-jar-path (cond
(win32p "c:/dev/plantuml/plantuml.jar")
(t "~/scripts/plantuml.jar"))
)
)
)
;; (require 'csharp-mode)
(when (and (my-try-require 'eproject)
(boundp 'prj-groups))
)
(provide 'my-programming)