-
Notifications
You must be signed in to change notification settings - Fork 2
/
spa_vanilla_settings.el
382 lines (333 loc) · 13.1 KB
/
spa_vanilla_settings.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
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
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; spa_vanilla_settings.el ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Aesthetics
(set-face-attribute 'default nil :inherit nil :stipple nil :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant 'normal :weight 'normal :height 160 :width 'normal :foundry "nil" :family "Hack")
(set-face-attribute 'secondary-selection nil :background "PaleTurquoise2")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Built-in Modes ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Ask before killing Emacs because sometimes I close it by accident
(setq confirm-kill-emacs 'y-or-n-p)
;; Show matching parentheses
(show-paren-mode 1)
;; overwrite selected text
(delete-selection-mode t)
;; column-number-mode
;; show row and column in status bar
(column-number-mode 1)
;; Count from 1 instead of 0
(setq column-number-indicator-zero-based nil)
(use-package ls-lisp
:init
(setq ls-lisp-use-insert-directory-program nil))
;; Add another prompt format to prevent entering passwords in plain text
(use-package comint
:config
(setq comint-password-prompt-regexp
(concat comint-password-prompt-regexp
"\\|^Password for .*:\\s *\\'")))
(use-package abbrev
:defer 5
:diminish
:config
(setq abbrev-file-name "~/.emacs.d/abbrev_defs")
(setq default-abbrev-mode t))
(use-package prog-mode
:after (auto-complete)
:config
(add-hook 'prog-mode-hook
(lambda ()
(font-lock-add-keywords nil
'(("\\<\\(FIXME\\|TODO\\|BUG\\):" 1 font-lock-warning-face t)))))
(add-hook 'prog-mode-hook
'(lambda ()
(local-set-key (kbd "C-c C-u") 'string-inflection-cycle))))
(use-package dired
:diminish dired-omit-mode
:preface
(defun spa/dired-find-file-follow-symlinks ()
"In Dired, visit the file or directory on the line, following symlinks
Source: `https://emacs.stackexchange.com/questions/41286/follow-symlinked-directories-in-dired'"
(interactive)
(let ((find-file-visit-truename t))
(dired-find-file)))
(defun dired-do-ispell (&optional arg)
"Check multiple buffers or files marked in dired for spelling with ispell"
(interactive "P")
(dolist (file (dired-get-marked-files
nil arg
#'(lambda (f)
(not (file-directory-p f)))))
(save-window-excursion
(with-current-buffer (find-file file)
(ispell-buffer)))
(message nil)))
(defun spa/dired-open-externally ()
"Run `open` on Mac OS X to open the file externally (e)."
(interactive)
(dired-do-shell-command "open" nil (dired-get-marked-files)))
(defun spa/tags-query-replace (from to &optional delimited file-list-form)
"Do `query-replace' of FROM with TO on all files listed in tags table.
Third arg DELIMITED (prefix arg) means replace only word-delimited matches.
If you exit (\\[keyboard-quit], RET or q), you can resume the query replace
with the command \\[tags-loop-continue].
Fourth arg FILE-LIST-FORM non-nil means initialize the replacement loop.
Fifth and sixth arguments START and END are accepted, for compatibility
with `query-replace', and ignored.
If FILE-LIST-FORM is non-nil, it is a form to evaluate to
produce the list of files to search.
See also the documentation of the variable `tags-file-name'.
Source: `http://stackoverflow.com/questions/15038277/find-and-replace-without-regexp-in-dired'"
(interactive (query-replace-read-args "Tags query replace" nil t))
(require 'etags)
(setq tags-loop-scan `(let ,(unless (equal from (downcase from))
'((case-fold-search nil)))
(if (search-forward ',from nil t)
;; When we find a match, move back
;; to the beginning of it so perform-replace
;; will see it.
(goto-char (match-beginning 0))))
tags-loop-operate `(perform-replace ',from ',to t nil ',delimited
nil multi-query-replace-map))
(tags-loop-continue (or file-list-form t)))
(defun spa/dired-do-query-replace (from to &optional delimited)
"Do `query-replace' of FROM with TO, on all marked files (no regexp).
Third arg DELIMITED (prefix arg) means replace only word-delimited matches.
If you exit (\\[keyboard-quit], RET or q), you can resume the query replace
with the command \\[tags-loop-continue].
Source: `http://stackoverflow.com/questions/15038277/find-and-replace-without-regexp-in-dired'"
(interactive
(let ((common
(query-replace-read-args
"Query replace in marked files" nil t)))
(list (nth 0 common) (nth 1 common) (nth 2 common))))
(require 'dired-aux)
(dolist (file (dired-get-marked-files nil nil 'dired-nondirectory-p))
(let ((buffer (get-file-buffer file)))
(if (and buffer (with-current-buffer buffer
buffer-read-only))
(error "File `%s' is visited read-only" file))))
(spa/tags-query-replace
from to delimited '(dired-get-marked-files nil nil 'dired-nondirectory-p)))
:config
;; To copy from one dired dir to another shown in split window
(setq dired-dwim-target t)
(setq delete-by-moving-to-trash t)
;; Can use `C-u s` in dired to modify switches
;; -S option to sort by file size, largest first
;; -X option to sort alphabetically by extension
(setq dired-listing-switches "-AlhG")
:bind (:map dired-mode-map
("<C-return>" . spa/dired-find-file-follow-symlinks)
("C-c s" . dired-do-ispell)
("e" . spa/dired-open-externally)
("C-c Q" . spa/dired-do-query-replace)))
(use-package auto-revert
:no-require t
:diminish
:hook ((dired-mode doc-view-mode) . auto-revert-mode)
:config
(setq auto-revert-verbose nil))
(setq auto-revert-verbose nil)
(use-package winner
:unless noninteractive
:defer 5
:bind (("M-N" . winner-redo)
("M-P" . winner-undo))
:config
(winner-mode 1))
(use-package ediff
:config
(setq ediff-split-window-function 'split-window-horizontally)
:bind (("C-c C-v" . ediff-revision)))
(use-package tramp
:defer 5
:preface
(defun spa/find-file-biostat ()
"Calls find-file on filename on remove server using TRAMP.
Requires a password"
(interactive)
(find-file (read-file-name
"Find File on BiostatShiny: "
"/ssh:[email protected]:~")))
:config
(setq password-cache-expiry 28800)
;; Originally set Bash explicitly to /bin/bash but now using default (e.g. zsh
;; on newer macs
;; (setq explicit-shell-file-name "/bin/bash")
(add-to-list 'tramp-remote-path 'tramp-own-remote-path)
:bind (("C-x C-g" . spa/find-file-biostat)))
(use-package ispell
:if (not (bound-and-true-p disable-pkg-ispell))
:defer 15
:config
(progn
(cond
((executable-find "aspell")
(setq ispell-program-name "aspell")
(setq ispell-extra-args '("--sug-mode=ultra"
"--lang=en_US")))
((executable-find "hunspell")
(setq ispell-program-name "hunspell")
(setq ispell-extra-args '("-d en_US"))))
;; Save a new word to personal dictionary without asking
(setq ispell-silently-savep t))
:bind
;; Similar binding to flyspell's C-. to make it easy to remember
;; even though this overwrites a global binding
("C-M-." . ispell-word))
(use-package flyspell
:diminish (flyspell-mode . "φ")
:after auto-complete
:defer t
:preface
;; Flyspell signals an error if there is no spell-checking tool is
;; installed. We can advice `turn-on-flyspell' and `flyspell-prog-mode'
;; to try to enable flyspell only if a spell-checking tool is available.
(defun modi/ispell-not-avail-p (&rest args)
"Return `nil' if `ispell-program-name' is available; `t' otherwise."
(not (executable-find ispell-program-name)))
:hook
((text-mode org-mode) . turn-on-flyspell)
((prog-mode) . flyspell-prog-mode)
:config
(ac-flyspell-workaround)
(advice-add 'turn-on-flyspell :before-until #'modi/ispell-not-avail-p)
(advice-add 'flyspell-prog-mode :before-until #'modi/ispell-not-avail-p))
(use-package prettify-symbols-mode
;; Can modify `ess-r-prettify-symbols` to add additional symbols
:hook
((prog-mode ess-mode inferior-ess-mode) . prettify-symbols-mode))
(use-package calendar
:init
;; (setq calendar-latitude 40.231846)
;; (setq calendar-longitude -75.252461)
;; (setq calendar-location-name "North Wales, PA")
(setq calendar-latitude 30.3322)
(setq calendar-longitude -81.6557)
(setq calendar-location-name "Jacksonville, FL")
(setq calendar-time-zone -300)
(setq calendar-standard-time-zone-name "EST")
(setq calendar-daylight-time-zone-name "EDT"))
(use-package auto-complete
:defer 15
:diminish
:preface
(defun my-auto-hook ()
(auto-complete-mode 1)
(define-key ac-completing-map [return] nil)
(define-key ac-completing-map "\r" nil))
:hook
((prog-mode ess-mode inferior-ess-mode) . (my-auto-hook)))
(use-package subword-mode
:diminish
:hook
((ess-mode inferior-ess-mode) . subword-mode))
(use-package ibuffer
:ensure t
:init
(setq ibuffer-expert t)
(setq ibuffer-show-empty-filter-groups nil)
(setq ibuffer-saved-filter-groups
'(("work"
("emacs-config" (or (filename . ".emacs.d")
(filename . ".emacs")))
("R Code" (or (name . "\\.R$")
(name . "\\.Rmd$")))
("Python Code" (name . "\\.py$"))
("Julia Code" (name . "\\.jl$"))
("Process" (or (mode . inferior-ess-mode)
(mode . inferior-python-mode)
(mode . shell-mode)
(mode . term-mode)))
("Org" (mode . org-mode))
("Dired" (mode . dired-mode))
("Magit" (name . "\*magit"))
("Help" (or (name . "\*Help\*")
(name . "\*Apropos\*")
(name . "\*info\*"))))))
:preface
(defun spa/ibuffer-vc-or-projectile-filter-groups (arg)
"ibuffer Filter by VC Repos or Projectile
'/ V' to view by version control git repositories
'C-u / V' to view by projectile projects"
(interactive "P")
(setq ibuffer-formats
'((mark modified read-only vc-status-mini " "
(name 18 18 :left :elide)
" "
(size 9 -1 :right)
" "
(mode 16 16 :left :elide)
" "
(vc-status 16 16 :left)
" "
filename-and-process)))
(if arg
(ibuffer-projectile-set-filter-groups)
(ibuffer-vc-set-filter-groups-by-vc-root))
(unless (eq ibuffer-sorting-mode 'alphabetic)
(ibuffer-do-sort-by-alphabetic))
(ibuffer-filter-by-filename ".*[.].*")
)
:config
(add-hook 'ibuffer-mode-hook
'(lambda ()
(ibuffer-auto-mode 1)
(ibuffer-switch-to-saved-filter-groups "work")))
:bind (:map global-map
("C-x C-b" . ibuffer))
:bind (:map ibuffer-mode-map
("/ V" . spa/ibuffer-vc-or-projectile-filter-groups)))
(use-package warnings
:config
(add-to-list 'warning-suppress-types '(yasnippet backquote-change)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Miscellaneous ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Skip splash screen
(setq inhibit-splash-screen t
initial-scratch-message nil)
;; Turn off tool bar mode
(if (fboundp 'tool-bar-mode) (tool-bar-mode -1))
;; disable scroll bars in GUI and menu in terminal
(if window-system
(scroll-bar-mode -1)
(progn
(tool-bar-mode -1)
(menu-bar-mode -1)
)
)
;; Sort results from apropos by relevance
(setq apropos-sort-by-scores t)
;; Don't warn about opening large files! I know they are large, yes I want you
;; to open them, that is why I asked you to open it.
(setq large-file-warning-threshold nil)
;; use hippie-expand instead of dabbrev
(global-set-key [remap dabbrev-expand] 'hippie-expand)
;; Set the fill column to be 80 by default
(setq-default fill-column 80)
;; Better wild cards in search
(setq search-whitespace-regexp ".*?")
;; NOTE: Now using zsh shell
;; Originally set these so that `shell-command` and `compile` understand aliases in .bashrc
;; (setq shell-file-name "bash")
(setq shell-command-switch "-ic")
;; Location Settings
(setq display-time-world-list (quote
(("America/Los_Angeles" "La Jolla, US")
("America/New_York" "Spring House, US")
("Europe/London" "London, UK")
("Europe/Brussels" "Beerse, BE")
("Asia/Shanghai" "Shanghai, CN")
("Asia/Tokyo" "Tokyo, JP"))))
;; Add the system clipboard to the Emacs kill-ring
;; (setq save-interprogram-paste-before-kill t)
;; compilation
(setq compilation-scroll-output 'first-error)
(setq trash-directory "~/.Trash")
(setq sentence-end-double-space nil)
;; Use the default mail program to open mailto: links
(setq browse-url-mailto-function 'browse-url-generic)
(setq browse-url-generic-program "open")