-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.emacs-macosx
439 lines (368 loc) · 16.4 KB
/
.emacs-macosx
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
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
;include all the scripts in the .site-lisp diretory.
(add-to-list 'load-path "~/.site-lisp/")
;(add-to-list 'load-path "~/.site-lisp/emacs-goodies-el/")
;(add-to-list 'vc-handled-backends 'SVN)
;color theme
(require 'color-theme)
(color-theme-initialize)
(color-theme-twilight)
(require 'tramp)
;A reload method to easily reload this file in a live emacs session.
(defun reload () "Reloads .emacs interactively."
(interactive)
(load "~/.emacs"))
(defun camel-case () "Converts symbol at current marker to camcel case"
(interactive)
(message "This is a message!")
(message "You are at point %i" (point))
)
;What does auto-fill-mode do anyways?
(setq auto-fill-mode t)
;What does this stuff do? Do I really care about where the top stuff is?
(setq initial-frame-alist
'((top . 40) (left . -15)
(width . 96) (height . 40)
(cursor-color . "blue")
(user-position t)
(font . "-*-courier-*-r-*-*-12-*-*-*-*-*-*-*")
))
(column-number-mode t) ;show column number
(windmove-default-keybindings) ;move between windows with Shift+arrow
(global-set-key "\C-cg" 'goto-line) ;Use Ctrl-c g to go to a line
(setq delete-auto-save-files t) ;This is self explanatory
(setq-default case-fold-search nil) ;case sensitive searches
;(highlight-beyond-fill-column) ;hilight text beyond the fill column?
;yaml mode
(require 'yaml-mode)
(add-to-list 'auto-mode-alist '("\\.\\(yml\\|yaml\\)\\'" . yaml-mode))
(require 'django-html-mode)
;set some default modes for certain file types.
(add-to-list 'auto-mode-alist '("\\.\\(zcml\\|pt\\|lore\\)\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.\\(txt\\|rst\\)\\'" . rst-mode))
(add-to-list 'auto-mode-alist '("\\.\\(js\\|c\\)\\'" . c-mode))
(add-to-list 'auto-mode-alist '("\\.\\(py\\|pyt\\)\\'" . python-mode))
;set up web-mode
(require 'web-mode)
;(add-to-list 'auto-mode-alist '("\\.html\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.js\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.jsx\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.gsp\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.jsp\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.es6\\'" . web-mode))
(setq web-mode-content-types-alist
'(("jsx" . "\\.js[x]?\\'")
("jsx" . "\\.es6\\'")))
(defun my-web-mode-hook ()
"Hooks for Web mode."
(setq web-mode-markup-indent-offset 2)
(setq web-mode-css-indent-offset 2)
(setq web-mode-code-indent-offset 2)
(when (string-suffix-p ".gsp" buffer-file-name)
(setq web-mode-code-indent-offset 4)
(setq web-mode-markup-indent-offset 4))
(when (>= (string-match "doorsystem" buffer-file-name) 0)
(setq web-mode-code-indent-offset 4)
(setq web-mode-markup-indent-offset 4))
)
(add-hook 'web-mode-hook 'my-web-mode-hook)
(define-derived-mode my-html-mode web-mode "My HTML mode"
"A mode for my html files."
)
(add-to-list 'auto-mode-alist '("\\.html\\'" . my-html-mode))
(add-to-list 'auto-mode-alist '("\\.erb\\'" . my-html-mode))
(add-to-list 'auto-mode-alist '("\\.handlebars\\'" . handlebars-mode))
; jsx-mode
(require 'jsx-mode)
; (add-to-list 'auto-mode-alist '("\\.jsx\\'" . jsx-mode))
; (add-to-list 'auto-mode-alist '("\\.js$" . jsx-mode))
(autoload 'jsx-mode "jsx-mode" "JSX mode" t)
(setq jsx-indent-level 2)
;pyflakes!
(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 "/opt/local/bin/pyflakes-2.5" (list local-file))))
(add-to-list 'flymake-allowed-file-name-masks
'("\\.py\\'" flymake-pyflakes-init)))
;(add-hook 'find-file-hook 'flymake-find-file-hook)
;; JAVASCRIPT MODE SETUP ------------------------------
;js2-mode by steve yegge for javascript parsing
(autoload 'js2-mode "js2" nil t)
; (add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))
; another javascript mode that has better indentation
(autoload 'espresso-mode "espresso" nil t)
; and here is a bunch of stuff from
; http://mihai.bazon.net/projects/editing-javascript-with-emacs-js2-mode
; that makes indentation in js2-mode sane... by using espresso's indentation
(defun my-js2-indent-function ()
(interactive)
(save-restriction
(widen)
(let* ((inhibit-point-motion-hooks t)
(parse-status (save-excursion (syntax-ppss (point-at-bol))))
(offset (- (current-column) (current-indentation)))
(indentation (espresso--proper-indentation parse-status))
node)
(save-excursion
;; I like to indent case and labels to half of the tab width
(back-to-indentation)
(if (looking-at "case\\s-")
(setq indentation (+ indentation (/ espresso-indent-level 2))))
;; consecutive declarations in a var statement are nice if
;; properly aligned, i.e:
;;
;; var foo = "bar",
;; bar = "foo";
(setq node (js2-node-at-point))
(when (and node
(= js2-NAME (js2-node-type node))
(= js2-VAR (js2-node-type (js2-node-parent node))))
(setq indentation (+ 4 indentation))))
(indent-line-to indentation)
(when (> offset 0) (forward-char offset)))))
(defun my-indent-sexp ()
(interactive)
(save-restriction
(save-excursion
(widen)
(let* ((inhibit-point-motion-hooks t)
(parse-status (syntax-ppss (point)))
(beg (nth 1 parse-status))
(end-marker (make-marker))
(end (progn (goto-char beg) (forward-list) (point)))
(ovl (make-overlay beg end)))
(set-marker end-marker end)
(overlay-put ovl 'face 'highlight)
(goto-char beg)
(while (< (point) (marker-position end-marker))
;; don't reindent blank lines so we don't set the "buffer
;; modified" property for nothing
(beginning-of-line)
(unless (looking-at "\\s-*$")
(indent-according-to-mode))
(forward-line))
(run-with-timer 0.5 nil '(lambda(ovl)
(delete-overlay ovl)) ovl)))))
(defun my-js2-mode-hook ()
(require 'espresso)
(setq espresso-indent-level 2
indent-tabs-mode nil
c-basic-offset 2)
(c-toggle-auto-state 0)
(c-toggle-hungry-state 1)
(set (make-local-variable 'indent-line-function) 'my-js2-indent-function)
(define-key js2-mode-map [(meta control |)] 'cperl-lineup)
(define-key js2-mode-map [(meta control \;)]
'(lambda()
(interactive)
(insert "/* -----[ ")
(save-excursion
(insert " ]----- */"))
))
(define-key js2-mode-map [(return)] 'newline-and-indent)
(define-key js2-mode-map [(backspace)] 'c-electric-backspace)
(define-key js2-mode-map [(control d)] 'c-electric-delete-forward)
(define-key js2-mode-map [(control meta q)] 'my-indent-sexp)
(if (featurep 'js2-highlight-vars)
(js2-highlight-vars-mode))
(message "My JS2 hook"))
(add-hook 'js2-mode-hook 'my-js2-mode-hook)
;; END JAVASCRIPT MODE SETUP --------------------------
;enable glasses-mode without a separator and with bold capitals.
;(add-to-list 'auto-mode-alist '("\\.\\(zcml\\|py\\)\\'" . glasses-mode))
;(setq glasses-separator "")
;'(glasses-face (quote bold))
;enable kill ring
;(browse-kill-ring-default-keybindings)
;get rid of those nasty backup files.
(add-to-list 'backup-directory-alist (cons "." "~/.emacs.d/backups"))
;Setup for Ignas's py-imports script.
(require 'py-imports)
(setq py-import-interactive-select-tag nil)
(global-set-key [f5] 'select-tag-to-import)
(global-set-key [C-f5] 'select-tag-to-import-in-place)
;key binding for upper casing things.
(put 'upcase-region 'disabled nil)
;make scroll margin 5 lines
(setq scroll-margin 2)
;enable tabbar mode
;(require 'tabbar)
;(setq tabbar-mode t)
(require 'highlight-80+)
(setq highlight-80+-mode t)
;make selection be highlighted.
(setq transient-mark-mode t)
;be able to cut and copy things to the global paste buffer in linux.
(setq mouse-drag-copy-region nil)
(setq x-select-enable-primary nil)
(setq x-select-enable-clipboard t)
(setq inhibit-startup-message t); Do without annoying startup msg.
(require 'show-wspace) ; Load the show whitespace library.
(add-hook 'font-lock-mode-hook 'highlight-tabs)
;(add-hook 'font-lock-mode-hook 'highlight-trailing-whitespace)
;;;(require 'rst) ;; get rst-mode for emacs (restructured text editing)
;(add-to-list 'load-path "~/.site-lisp/ruby-mode")
;(require 'ruby-mode)
;(require 'ruby-electric)
;(setq auto-mode-alist (cons '("\\.rb\\'" . rhtml-mode) auto-mode-alist))
;;;;;;;Latex help with AuxTex;;;;;;;;;;;;
;(load "auctex.el" nil t t)
;(load "preview-latex.el" nil t t)
;(setq TeX-auto-save t)
;(setq TeX-parse-self t)
;(setq-default TeX-master nil)
; set up trac
(load-library "trac-wiki")
(autoload 'trac-wiki "trac-wiki"
"Trac wiki editing entry-point." t)
;; WikiCreole mode (wiki-mode)
;; Thanks to Alex Schroeder of www.emacswiki.org
;; And Jason Blevins for his inspiring Markdown Mode
;; http://jblevins.org/projects/markdown-mode/
(define-generic-mode 'wiki-mode
nil ; comments
nil; keywords
'(("^\\(= \\)\\(.*?\\)\\($\\| =$\\)" . 'info-title-1)
("^\\(== \\)\\(.*?\\)\\($\\| ==$\\)" . 'info-title-2)
("^\\(=== \\)\\(.*?\\)\\($\\| ===$\\)" . 'info-title-3)
("^\\(====+ \\)\\(.*?\\)\\($\\| ====+$\\)" . 'info-title-4)
("\\[\\[.*?\\]\\]" . 'link)
("\\[.*\\]" . 'link)
("\\[b\\].*?\\[/b\\]" . 'bold)
("\\[i\\].*?\\[/i\\]" . 'italic)
("\\*\\*.*?\\*\\*" . 'bold)
("\\*.*?\\*" . 'bold)
("\\_<//.*?//" . 'italic)
("\\_</.*?/" . 'italic)
("__.*?__" . 'italic)
("_.*?_" . 'underline)
("|+=?" . font-lock-string-face)
("\\\\\\\\[ \t]+" . font-lock-warning-face)) ; font-lock list
'(".wiki\\'"); auto-mode-alist
'((lambda () (require 'info) (require 'goto-addr))); function-list
"Wiki stuff including Creole Markup and BBCode.")
; markdown mode!
(autoload 'markdown-mode "markdown-mode.el"
"Major mode for editing Markdown files" t)
(setq auto-mode-alist
(cons '("\\.md" . markdown-mode) auto-mode-alist))
;(setq grep-find-command
; '("find . -name '.svn' -prune -name \"*\" -o -print0 | xargs -0 grep -in -e " . 75))
;(setq grep-find-command
; '("find . -name '.svn' -prune -name \"*\" -o -print0 | xargs -0 grep -in -e " . 74))
;(setq grep-find-command '("find . -name '.svn' -prune -o -exec grep -nH -e {} /dev/null \;" . 54))
; add a pdb trace line when you hit C-c p
(define-key global-map "\C-cp" '(lambda() (interactive) (insert "import pdb; pdb.set_trace()")))
; shortcut to svn-status
(require 'psvn)
(defalias 's 'svn-status)
(require 'git)
(setenv "PAGER" "cat") ; because git likes to use the pager when it shouldn't
; awesome buffer switching. C-x b and start typing! use C-s and C-r to navigate in the set
; !! iswitchb was deprecated in favor of icomple-mode
; (require 'iswitchb)
; (iswitchb-default-keybindings)
(icomplete-mode 99)
; set tab width to 4
(setq tab-width 4)
; always get rid of trailing whitespace on save.
(load-library "nuke-trailing-whitespace")
(autoload 'nuke-trailing-whitespace "whitespace" nil t)
(add-hook 'write-file-hooks 'nuke-trailing-whitespace)
; highlight beyond 80 characters
(load-library "highlight-80+")
;bunch of custom stuff down here!
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(auto-save-file-name-transforms
(quote
(("/Volumes/ps-dev/*" "/tmp" t)
("\\`/[^/]*:\\([^/]*/\\)*\\([^/]*\\)\\'" "/var/folders/R8/R86MaxmlEQqTWfkQVWwUerGW47g/-Tmp-/\\2" t))))
'(bmkp-desktop-jump-save-before-flag t)
'(bmkp-last-as-first-bookmark-file "/Users/pcardune/.emacs.d/bookmarks")
'(c-basic-offset 4)
'(column-number-mode t)
'(css-indent-offset 2)
'(espresso-indent-level 2)
'(exec-path
(quote
("/Users/pcardune/.sdkman/candidates/grails/current/bin" "./node_modules/.bin" "/usr/local/bin" "/usr/bin" "/bin" "/usr/sbin" "/sbin" "/usr/local/git/bin" "/Applications/Postgres.app/Contents/Versions/9.4/bin" "/usr/local/Cellar/emacs-mac/emacs-24.5-z-mac-5.13/libexec/emacs/24.5/x86_64-apple-darwin15.0.0" "/Users/pcardune/.nvm/versions/node/v5.0.0/bin")))
'(fill-column 80)
'(grep-find-ignored-directories
(quote
("SCCS" "RCS" "CVS" "MCVS" ".svn" ".git" ".hg" ".bzr" "_MTN" "_darcs" "{arch}" "node_modules" "bower_components" "src-min" "src-min-noconflict")))
'(grep-find-ignored-files
(quote
(".#*" "*.o" "*~" "*.bin" "*.lbin" "*.so" "*.a" "*.ln" "*.blg" "*.bbl" "*.elc" "*.lof" "*.glo" "*.idx" "*.lot" "*.fmt" "*.tfm" "*.class" "*.fas" "*.lib" "*.mem" "*.x86f" "*.sparcf" "*.dfsl" "*.pfsl" "*.d64fsl" "*.p64fsl" "*.lx64fsl" "*.lx32fsl" "*.dx64fsl" "*.dx32fsl" "*.fx64fsl" "*.fx32fsl" "*.sx64fsl" "*.sx32fsl" "*.wx64fsl" "*.wx32fsl" "*.fasl" "*.ufsl" "*.fsl" "*.dxl" "*.lo" "*.la" "*.gmo" "*.mo" "*.toc" "*.aux" "*.cp" "*.fn" "*.ky" "*.pg" "*.tp" "*.vr" "*.cps" "*.fns" "*.kys" "*.pgs" "*.tps" "*.vrs" "*.pyc" "*.pyo" "*.min.js" "*.js.map" "*.min.css")))
'(indent-tabs-mode nil)
'(js-indent-level 2)
'(js2-auto-indent-flag nil)
'(js2-basic-offset 2)
'(js2-enter-indents-newline nil)
'(js2-rebind-eol-bol-keys nil)
'(longlines-wrap-follows-window-size t)
'(menu-bar-mode nil)
'(nuke-trailing-whitespace-always-major-modes
(quote
(web-mode jsx-mode js2-mode html-mode objc-mode ada-mode c++-mode c-mode change-log-mode emacs-lisp-mode fortran-mode latex-mode lisp-interaction-mode lisp-mode makefile-mode nroff-mode perl-mode plain-tex-mode prolog-mode scheme-mode sgml-mode tcl-mode slitex-mode sml-mode texinfo-mode python-mode)) t)
'(rst-level-face-base-color "grey")
'(rst-level-face-base-light 35)
'(safe-local-variable-values (quote ((Encoding . utf-8))))
'(save-place t nil (saveplace))
'(savehist-mode t)
'(show-trailing-whitespace nil)
'(tab-width 2)
'(text-mode-hook (quote (turn-on-auto-fill text-mode-hook-identify)))
'(tool-bar-mode nil)
'(typescript-indent-level 2)
'(uniquify-buffer-name-style (quote forward) nil (uniquify)))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(font-lock-string-face ((nil (:foreground "Green"))))
'(highlight-current-line-face ((t (:background "ivory1"))))
'(pesche-space ((t (:background "light cyan" :foreground "red" :strike-through t))))
'(pesche-tab ((t (:background "Black"))))
'(rst-level-1-face ((t (:background "grey35"))) t)
'(rst-level-2-face ((t (:background "grey28" :overline t :underline t :weight ultra-bold))) t)
'(rst-level-4-face ((t (:background "grey14" :underline t :weight bold))) t))
(put 'erase-buffer 'disabled nil)
(put 'narrow-to-region 'disabled nil)
(put 'downcase-region 'disabled nil)
(require 'cask "/usr/local/share/emacs/site-lisp/cask/cask.el")
(cask-initialize)
(add-hook 'after-init-hook #'global-flycheck-mode)
(load-library "bookmark+")
(add-hook 'kill-emacs-hook 'bmkp-desktop-save-as-last)
(require 'flycheck)
(flycheck-add-mode 'javascript-eslint 'jsx-mode)
(flycheck-add-mode 'javascript-eslint 'web-mode)
(flycheck-add-mode 'javascript-eslint 'js2-mode)
;; https://github.com/purcell/exec-path-from-shell
;; only need exec-path-from-shell on OSX
;; this hopefully sets up path and other vars better
(when (memq window-system '(mac ns))
(exec-path-from-shell-initialize))
(defun save-macro (name)
"save a macro. Take a name as argument
and save the last defined macro under
this name at the end of your .emacs"
(interactive "SName of the macro :") ; ask for the name of the macro
(kmacro-name-last-macro name) ; use this name for the macro
(find-file user-init-file) ; open ~/.emacs or other user init file
(goto-char (point-max)) ; go to the end of the .emacs
(newline) ; insert a newline
(insert-kbd-macro name) ; copy the macro
(newline) ; insert a newline
(switch-to-buffer nil)) ; return to the initial buffer
(fset 'es6-import
(lambda (&optional arg) "Keyboard macro." (interactive "p") (kmacro-exec-ring-item (quote ([1 M-right M-backspace 105 109 112 111 114 116 M-right 67108896 19 40 return 23 32 102 114 111 109 32 19 41 return left 11] 0 "%d")) arg)))