-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.emacs
More file actions
264 lines (220 loc) · 10.1 KB
/
.emacs
File metadata and controls
264 lines (220 loc) · 10.1 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
;;; package --- foo
;;; Commentary:
;;; Code:
(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-default nil)
'(backup-by-copying t)
'(backup-directory-alist (quote (("." . "~/.emacs.d/backups"))))
'(custom-enabled-themes (quote (wheatgrass)))
'(flycheck-disabled-checkers (quote (javascript-jshint json-jsonlist python-pylint)))
'(flycheck-python-flake8-executable "/Users/alecf/.pyenv/versions/3.6.4/bin/flake8")
'(flycheck-python-pylint-executable "/Users/alecf/.pyenv/versions/3.6.4/bin/pylint")
'(groovy-indent-offset 2)
'(js2-global-externs (list "Footprint" "SC"))
'(js2-highlight-level 3)
'(js2-strict-trailing-comma-warning nil)
'(magit-revision-show-gravatars (quote ("^Author: " . "^Commit: ")))
'(package-archives (quote (("gnu" . "http://elpa.gnu.org/packages/"))))
'(safe-local-variable-values
(quote
((eval setq default-directory
(locate-dominating-file buffer-file-name ".dir-locals.el")))))
'(tool-bar-mode nil)
'(tooltip-mode nil)
'(uniquify-buffer-name-style (quote reverse) nil (uniquify))
'(web-mode-attr-indent-offset 2)
'(web-mode-code-indent-offset 2)
'(web-mode-enable-auto-quoting nil)
'(web-mode-markup-indent-offset 2))
(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.
'(magit-diff-added ((t (:background "#4fc3f7" :foreground "#ddffdd"))))
'(magit-diff-added-highlight ((t (:background "#c8e6c9" :foreground "#ffffff")))))
(add-to-list 'load-path (expand-file-name "~/.elisp"))
(setq x-select-enable-clipboard t)
(setq-default indent-tabs-mode nil)
(when window-system
(global-unset-key "\C-x\C-z")
(global-unset-key "\C-z"))
(desktop-save-mode 1)
(when window-system
(defun dont-kill-emacs ()
(interactive)
(error (substitute-command-keys "To exit emacs: \\[kill-emacs]")))
(global-set-key "\C-x\C-c" 'dont-kill-emacs))
(global-auto-revert-mode 1)
;; MELPA is a nice package repository with newer packages like flycheck
(require 'package)
(add-to-list 'package-archives
'("melpa" . "https://melpa.org/packages/"))
(package-initialize)
;; From http://www.emacswiki.org/emacs/Ack
(defvar ack-history nil
"History for the `ack' command.")
(defun ack (command-args)
(interactive
(let ((ack-command "ack-grep --nogroup --with-filename "))
(list (read-shell-command "Run ack (like this): "
ack-command
'ack-history))))
(let ((compilation-disable-input t))
(compilation-start (concat command-args " < " null-device)
'grep-mode)))
;; end ack
;; web-mode
(require 'web-mode)
(add-to-list 'auto-mode-alist '("\\.phtml\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.tpl\\.php\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.[agj]sp\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.as[cp]x\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.erb\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.mustache\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.djhtml\\'" . 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 '("\\.tsx?\\'" . web-mode))
(setq web-mode-content-types-alist
'(("jsx" . "\\.js[x]?\\'")))
; do NOT line up cascaded-call dots to the first line - instead use
; default indentation rules, which ends up lining up all dots after
; the first line.
(add-to-list 'web-mode-indentation-params '("lineup-calls" . nil))
;; end web-mode
;; js2-mode
;; (autoload 'js2-mode "js2" nil t)
;; (add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))
;;
;; whitespace stuff
(add-hook 'c-mode-hook
(lambda () (add-to-list 'write-file-functions 'delete-trailing-whitespace)))
(add-hook 'python-mode-hook
(lambda () (add-to-list 'write-file-functions 'delete-trailing-whitespace)))
(add-hook 'js2-mode-hook
(lambda () (add-to-list 'write-file-functions 'delete-trailing-whitespace)))
(add-hook 'js2-mode-hook
(lambda() (add-to-list 'exec-path (concat (locate-dominating-file buffer-file-name "node_modules") "node_modules/.bin/"))))
;; (set-fontset-font t 'unicode "Symbola" nil 'prepend)
;; (set-fontset-font t 'cyrillic "Droid Sans Mono")
(put 'downcase-region 'disabled nil)
;; begin flycheck - mostly copied from http://codewinds.com/blog/2015-04-02-emacs-flycheck-eslint-jsx.html
(require 'flycheck)
(setq dotfiles-dir (file-name-directory (or load-file-name (buffer-file-name))))
(add-to-list 'exec-path (concat dotfiles-dir "node_modules/.bin/"))
;; and this from http://emacs.stackexchange.com/questions/21205/flycheck-with-file-relative-eslint-executable
(defun my/use-eslint-from-node-modules ()
(let* ((root (locate-dominating-file
(or (buffer-file-name) default-directory)
"node_modules"))
(eslint (and root
(expand-file-name "node_modules/eslint/bin/eslint.js"
root))))
(when (and eslint (file-executable-p eslint))
(setq-local flycheck-javascript-eslint-executable eslint))))
(add-hook 'flycheck-mode-hook #'my/use-eslint-from-node-modules)
;; turn on flychecking globally
(add-hook 'after-init-hook #'global-flycheck-mode)
;; disable jshint since we prefer eslint checking
;; use eslint with web-mode to get inline JS (also supposedly for jsx..)
(flycheck-add-mode 'javascript-eslint 'web-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))
;; disable json-jsonlist checking for json files
(setq-default flycheck-disabled-checkers
(append flycheck-disabled-checkers
'(json-jsonlist)))
;; end flycheck
;; via http://stackoverflow.com/questions/151945/how-do-i-control-how-emacs-makes-backup-files
; already customized above: (setq backup-directory-alist `(("." . "~/.saves")))
(defvar --backup-directory (concat user-emacs-directory "backups"))
(if (not (file-exists-p --backup-directory))
(make-directory --backup-directory t))
(setq backup-directory-alist `(("." . ,--backup-directory)))
(setq make-backup-files t ; backup of a file the first time it is saved.
backup-by-copying t ; don't clobber symlinks
version-control t ; version numbers for backup files
delete-old-versions t ; delete excess backup files silently
delete-by-moving-to-trash t
kept-old-versions 6 ; oldest versions to keep when a new numbered backup is made (default: 2)
kept-new-versions 9 ; newest versions to keep when a new numbered backup is made (default: 2)
auto-save-default t ; auto-save every buffer that visits a file
auto-save-timeout 20 ; number of seconds idle time before auto-save (default: 30)
auto-save-interval 200 ; number of keystrokes between auto-saves (default: 300)
)
;; Save all tempfiles in $TMPDIR/emacs$UID/
(defconst emacs-tmp-dir (expand-file-name (format "emacs%d" (user-uid)) temporary-file-directory))
(setq backup-directory-alist
`((".*" . ,emacs-tmp-dir)))
(setq auto-save-file-name-transforms
`((".*" ,emacs-tmp-dir t)))
(setq auto-save-list-file-prefix
emacs-tmp-dir)
;; end backups
;; supposedly this will let you use cask? not sure..
;; (source gnu)
;; (source melpa-stable)
;; end MELPA
(put 'upcase-region 'disabled nil)
;; turn off bell completely
(setq ring-bell-function 'ignore)
;; web-mode seems to be better?
;;(require 'handlebars-mode)
(require 'unicode-fonts)
(provide '.emacs)
;;; .emacs ends here
(require 'magit)
(require 'pyenv-mode-auto)
(require 'midnight)
;; Open files in Docker containers like so: /docker:drunk_bardeen:/etc/passwd
;; (push
;; (cons
;; "docker"
;; '((tramp-login-program "docker")
;; (tramp-login-args (("exec" "-it") ("%h") ("/bin/bash")))
;; (tramp-remote-shell "/bin/sh")
;; (tramp-remote-shell-args ("-i") ("-c"))))
;; tramp-methods)
;; (defadvice tramp-completion-handle-file-name-all-completions
;; (around dotemacs-completion-docker activate)
;; "(tramp-completion-handle-file-name-all-completions \"\" \"/docker:\" returns
;; a list of active Docker container names, followed by colons."
;; (if (equal (ad-get-arg 1) "/docker:")
;; (let* ((dockernames-raw (shell-command-to-string "docker ps | perl -we 'use strict; $_ = <>; m/^(.*)NAMES/ or die; my $offset = length($1); while(<>) {substr($_, 0, $offset, q()); chomp; for(split m/\\W+/) {print qq($_:\n)} }'"))
;; (dockernames (cl-remove-if-not
;; #'(lambda (dockerline) (string-match ":$" dockerline))
;; (split-string dockernames-raw "\n"))))
;; (setq ad-return-value dockernames))
;; ad-do-it))
(defun my-insert-file-name (filename &optional args)
"Insert name of file FILENAME into buffer after point.
Prefixed with \\[universal-argument], expand the file name to
its fully canocalized path. See `expand-file-name'.
Prefixed with \\[negative-argument], use relative path to file
name from current directory, `default-directory'. See
`file-relative-name'.
The default with no prefix is to insert the file name exactly as
it appears in the minibuffer prompt."
;; Based on insert-file in Emacs -- ashawley 20080926
(interactive "*fInsert file name: \nP")
(cond ((eq '- args)
(insert (file-relative-name filename)))
((not (null args))
(insert (expand-file-name filename)))
(t
(insert filename))))
(global-set-key "\C-c\C-i" 'my-insert-file-name)
;; auto-complete mode
(ac-config-default)
;; Alt-tab to complete
(define-key ac-mode-map (kbd "M-TAB") 'auto-complete)
;; don't show the autocomplete automatically
(setq ac-auto-start nil)