-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathemacs-common.el
More file actions
373 lines (321 loc) · 11.9 KB
/
emacs-common.el
File metadata and controls
373 lines (321 loc) · 11.9 KB
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
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; global variable definition
;; additional .el load path
(setq elisp_path "~/CodeBase/emacs_dev")
(add-to-list 'load-path elisp_path)
(dolist (pkg_dir '("use-package"
"xterm-color"
"emacs-async"
"emacs-sbt-mode"
"scala-mode2"))
(add-to-list 'load-path (concat elisp_path "/" pkg_dir)))
;; Very basic key modifications for OSX
;; Duplicated at the end of the file for fear that some mode might modify them
(setq mac-option-key-is-meta t)
(setq mac-command-key-is-meta t)
(setq mac-command-modifier 'meta)
(setq mac-option-modifier 'meta)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Emacs server
(server-start)
;;--------------------------------------------------------------------
;; Package managing
;; (eval-when-compile
;; (require 'use-package))
;; (require 'diminish) ;; if you use :diminish
;; (require 'bind-key) ;; if you use any :bind variant
(require 'package)
(add-to-list 'load-path (concat elisp_path "/use-package"))
(setq
use-package-always-ensure t
package-archives '(("gnu" . "http://elpa.gnu.org/packages/")
("org" . "http://orgmode.org/elpa/")
("melpa" . "http://melpa.org/packages/")
("milkbox" . "http://melpa.milkbox.net/packages/")
("elpy" . "http://jorgenschaefer.github.io/packages/")))
(package-initialize)
(when (not package-archive-contents)
(package-refresh-contents)
(package-install 'use-package)
(package-install 'async))
(require 'use-package) ;; get the dependencies
(dired-async-mode 1) ;;
(defvar package-depslist
'(helm s company magit projectile dash async
use-package evil helm-flx swiper-helm
web-mode ess lua-mode z3-mode
flycheck
markdown-mode
ensime sbt-mode elpy
solarized-theme)
"A list of dependencies to be installed")
(require 'cl) ;; use the common-lisp extension
(defun package-deps-installed-p ()
"Return true if the dependencies are all installed"
(loop for pkg in package-depslist
when (not (package-installed-p pkg)) do (return nil)
finally (return t)))
(unless (package-deps-installed-p)
(package-refresh-contents)
(dolist (pkg package-depslist)
(when (not (package-installed-p pkg))
(package-install pkg))))
(use-package helm
:commands helm-config
:init (setq
helm-apropos-fuzzy-match t
helm-split-window-in-side-p t
helm-move-to-line-cycle-in-source t
helm-ff-search-library-in-sexp t
helm-scroll-amount 8
helm-ff-file-name-history-use-recentf t
helm-buffers-fuzzy-matching t
helm-recentf-fuzzy-match t
helm-semantic-or-imenu t)
:config (helm-mode 1)
:bind (("M-x" . helm-M-x)
("C-x C-m" . helm-M-x)
("C-c C-m" . helm-M-x)
("C-x b" . helm-mini)
("C-x C-f" . helm-find-files)
("C-x c a" . helm-apropos)
("C-c h" . helm-apropos)
:map helm-map
("<tab>" . helm-execute-persistent-action)
("C-i" . helm-execute-persistent-action)
("C-z" . helm-select-action))
)
(use-package company
:init
(add-hook 'after-init-hook 'global-company-mode)
;;(add-hook 'after-init-hook 'company-statistics-mode t)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;--------------------------------------------------------------------
;; ANSI color
;; comint install
;; Also remember to set TERM accordingly (xterm-256color)
;; Keep up-to-date https://github.com/atomontage/xterm-color
(use-package xterm-color
:load-path "xterm-color/"
:config
(add-hook 'comint-preoutput-filter-functions 'xterm-color-filter)
(setq comint-output-filter-functions (remove 'ansi-color-process-output comint-output-filter-functions))
)
;; You can also use it with eshell (and thus get color output from system ls):
(use-package eshell
:init
(add-hook 'eshell-mode-hook
(lambda () (setq xterm-color-preserve-properties t)))
:config
(add-to-list 'eshell-preoutput-filter-functions 'xterm-color-filter)
(setq eshell-output-filter-functions (remove 'eshell-handle-ansi-color eshell-output-filter-functions))
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;--------------------------------------------------------------------
;; Document Editing
(use-package markdown-mode
:ensure t
:commands (markdown-mode gfm-mode)
:mode (("README\\.md\\'" . gfm-mode)
("\\.md\\'" . markdown-mode)
("\\.markdown\\'" . markdown-mode))
:init (setq markdown-command "multimarkdown"))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;--------------------------------------------------------------------
;; Programming Language Environment
;;
;;--------------------------------------------------------------------
;; Python
(elpy-enable)
(setq elpy-rpc-python-command "python3") ;; use a default python
(setq elpy-rpc-backend "jedi")
(elpy-use-ipython "ipython3")
(setq elpy-syntax-check-command "pylint")
(setq python-shell-interpreter "ipython3")
(setq python-shell-interpreter-args "--simple-prompt --pprint")
(setq python-shell-prompt-detect-enabled nil)
(setq python-shell-prompt-detect-failure-warning nil)
(add-to-list 'auto-mode-alist '("BUILD\\'" . python-mode))
;; Configure flymake for python
(when (load "flymake" t)
(defun flymake-pylint-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 "epylint" (list local-file))))
(add-to-list 'flymake-allowed-file-name-masks
'("\\.py\\'" flymake-pylint-init)))
;; Set as a minor mode for python
(add-hook 'python-mode-hook '(lambda () (flymake-mode)))
;; https://github.com/emacs-mirror/emacs/commit/dbb341022870ecad4c9177485a6770a355633cc0
(defun python-shell-completion-native-try ()
"Return non-nil if can trigger native completion."
(let ((python-shell-completion-native-enable t)
(python-shell-completion-native-output-timeout
python-shell-completion-native-try-output-timeout))
(python-shell-completion-native-get-completions
(get-buffer-process (current-buffer))
nil "_")))
;;(setq elpy-interactive-python-command "ipython3 --simple-prompt -i")
;; (use-package python
;; :mode ("\\.py\\'" . python-mode)
;; :init
;; (setq
;; python-shell-interpreter "ipython3"
;; python-shell-interpreter-args "--simple-prompt -i"
;; )
;; )
;;--------------------------------------------------------------------
;; C++
(load "cern-root-help.el")
(require 'root-help)
(defun root-c++-mode-hook ()
"Hook for C++ mode - binding ROOT functions"
(define-key c++-mode-map "\C-crc" 'root-class)
(define-key c++-mode-map "\C-crh" 'root-header-skel)
(define-key c++-mode-map "\C-crs" 'root-source-skel)
(define-key c++-mode-map "\C-cri" 'root-include-header)
(define-key c++-mode-map "\C-crm" 'root-main)
(define-key c++-mode-map "\C-crl" 'root-insert-linkdef)
(define-key c++-mode-map "\C-crp" 'root-insert-pragma)
(define-key c++-mode-map "\C-crx" 'root-shell)
(define-key c++-mode-map "\C-crg" 'root-send-line-to-root)
(define-key c++-mode-map "\C-crr" 'root-send-region-to-root)
(define-key c++-mode-map "\C-crb" 'root-send-buffer-to-root)
(define-key c++-mode-map "\C-crf" 'root-execute-file))
(add-hook 'c++-mode-hook 'root-c++-mode-hook)
;;--------------------------------------------------------------------
;; Scala
(load "scala-custom.el")
;;--------------------------------------------------------------------
;; Lua / Torch7
(require 'torch-mode)
(autoload 'torch-mode "lua-mode" "Lua editing mode." t)
(add-to-list 'auto-mode-alist '("\\.lua$" . torch-mode))
(add-to-list 'interpreter-mode-alist '("th" . torch-mode))
;; (setq
;; torch-default-application "th"
;; torch-default-command-switches '("-i" "-g" "-a" "torch_repl_init.lua")
;; )
;; (use-package torch-mode
;; :load-path elisp_path
;; :pin manual
;; :mode "\\.lua\\'"
;; :interpreter "th"
;; :init
;; (setq
;; torch-default-application "th"
;; torch-default-command-switches '("-i" "-g" "-a" "torch_repl_init.lua")
;; )
;; :bind
;; (:map torch-mode-map
;; ("C-c C-z" . run-torch)
;; ("C-c C-c" . torch-send-defun)
;; ("C-c C-l" . torch-send-current-line)
;; ("C-c C-r" . torch-send-region)
;; )
;; )
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; org-mode (site-lisp is the install location)
(load "orgmode-custom.el")
;;(require 'org2blog-autoloads)
;;(setq org2blog/wp-blog-alist
;; '(("quantipress"
;; :url "http://wordpress.quantifind.com/xmlrpc.php"
;; :username "philip"
;; :default-categories ("data-science" "emacs")
;; :tags-as-categories nil)
;; ))
(use-package markdown-mode
:ensure t
:commands (markdown-mode gfm-mode)
:mode (("README\\.md\\'" . gfm-mode)
("\\.md\\'" . markdown-mode)
("\\.markdown\\'" . markdown-mode))
:init (setq markdown-command "multimarkdown"))
;; web-mode @ http://web-mode.org
(use-package web-mode
:mode ("\\.html?\\'"
"\\.php\\'")
:init (setq
web-mode-markup-indent-offset 2
web-mode-css-indent-offset 2
web-mode-code-indent-offset 2
web-mode-indent-style 2)
:config (setq-default indent-tabs-mode t)
)
;; Coq
(load (concat elisp_path "/prfgnrl/generic/proof-site.el"))
;;(setq auto-mode-alist (cons '("\\.v$" . coq-mode) auto-mode-alist))
;; (autoload 'coq-mode "coq" "Major mode for editing Coq vernacular." t)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Flycheck http://www.flycheck.org/en/latest/
(package-install 'flycheck)
(global-flycheck-mode)
(package-install 'flycheck-color-mode-line)
(eval-after-load "flycheck"
'(add-hook 'flycheck-mode-hook 'flycheck-color-mode-line-mode))
(package-install 'flycheck-pos-tip)
(eval-after-load 'flycheck
(flycheck-pos-tip-mode))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Flyspell for spell checking
;; Ref: http://www.emacswiki.org/emacs/FlySpell
(use-package flyspell
:commands (flyspell-delay-command tex-mode-flyspell-verify)
:config
(add-hook 'LaTeX-mode-hook 'flyspell-mode)
(add-hook 'python-mode-hook 'flyspell-prog-mode)
(setq flyspell-sort-corrections nil)
(setq flyspell-doublon-as-error-flag nil)
(dolist (hook '(text-mode-hook))
(add-hook hook (lambda () (flyspell-mode 1))))
(dolist (hook '(change-log-mode-hook log-edit-mode-hook))
(add-hook hook (lambda () (flyspell-mode nil))))
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Global Settings
;; - in case they are modified by other modes
;; Substitude certain patterns (Greek letters or math symbols)
;; with unicode
(load "emacs-rc-pretty-lambda.el")
;; Removing trailing white spaces when saving
(add-hook 'before-save-hook 'delete-trailing-whitespace)
;; global variables
(setq
inhibit-startup-screen t
create-lockfiles nil
make-backup-files nil
column-number-mode t
scroll-error-top-bottom t
show-paren-delay 0.5
sentence-end-double-space nil)
;; buffer local variables
(setq-default
indent-tabs-mode nil
tab-width 4
c-basic-offset 4)
;; modes
(electric-indent-mode 0)
;; Removing trailing spaces when saved
(add-hook 'before-save-hook 'delete-trailing-whitespace)
;;(tool-bar-mode nil) ;; turning off the tool-bar
(transient-mark-mode t)
;; All about the meta keys
(setq mac-option-key-is-meta t)
(setq mac-command-key-is-meta t)
(setq mac-command-modifier 'meta)
(setq mac-option-modifier 'meta)
;;(setq setq mac-command-key-is-meta t)
;;(setq mac-command-key 'meta)
(setq
ring-bell-function 'ignore
visible-bell nil
global-visual-line-mode t
word-wrap t
ns-pop-up-frames nil)
;; set themes at last
(load-theme 'solarized-dark t)