-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.emacs
277 lines (241 loc) · 10.7 KB
/
.emacs
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
;; emacs startup file.
(setq backup-directory-alist '((".*" . "~/.trash")))
;; uncomment next line to disable loading of "default.el" at startup
;; (setq inhibit-default-init t)
;; add personal load path
(push "~/.emacs.d/lisp" load-path)
(require 'package)
;; Any add to list for package-archives (to add marmalade or melpa) goes here
(add-to-list 'package-archives
'("MELPA" .
"http://melpa.org/packages/"))
(package-initialize)
(load-theme 'atom-dark t)
;;;
;;; global key bindings.
;;;
(define-key global-map "\C-ci" 'insert-buffer)
(define-key global-map [f11] 'beginning-of-buffer)
(define-key global-map [f12] 'end-of-buffer)
(define-key global-map [f4] 'manual-entry)
(define-key global-map [f5] 'dabbrev-expand)
(define-key global-map [f9] 'other-window)
(define-key global-map [f10] 'shell-next-window)
(define-key global-map [print] 'execute-extended-command)
(define-key global-map [pause] 'iconify-or-deiconify-frame)
(define-key global-map [break] 'iconify-or-deiconify-frame)
(define-key global-map [\C-backspace] 'delete-indentation)
;; mouse-4 and mouse-5 are the scroll wheel
(define-key global-map [mouse-4] (lambda () (interactive) (scroll-down 3)))
(define-key global-map [mouse-5] (lambda () (interactive) (scroll-up 3)))
(define-key global-map [\S-down-mouse-1] 'mouse-set-font) ; brings up a font menu
(global-set-key "\C-s" 'isearch-forward-regexp) ; replaces isearch-forward in default binding
(global-set-key "\C-\M-s" isearch-forward)
(global-set-key "\C-r" 'isearch-backward-regexp)
(global-set-key "\C-\M-r" 'isearch-backward)
(global-set-key "\M-%" 'query-replace-regexp)
;; Generally you should set up mode-specific key bindings in hooks,
;; but if you can be certain that the mode will have been initialized
;; already, it's ok to do it here.
(define-key lisp-interaction-mode-map "\C-m" 'newline-and-indent)
(define-key lisp-interaction-mode-map [kp-enter] 'eval-print-last-sexp)
(define-key lisp-interaction-mode-map "<C-return>" 'eval-print-last-sexp)
;;;
;;; Path to ispell on mac
(setq ispell-program-name "/usr/local/bin/ispell")
;;;
;;; Some useful (?) interactive functions
;;;
(defun word-count-region (start stop)
"Count the words in the region. This function calls count-matches with an
appropriate regexp."
(interactive "d\nm")
(count-matches "\\b\\w+\\b" start stop t))
(global-set-key "\C-cw" 'word-count-region)
(defun shell-next-window ()
"Spawn a shell in another window, or switch to the shell buffer if one already exists."
(interactive)
(let ((buf (get-buffer "*shell*")))
(if buf ;check for existence of shell buffer
(if (not (equal (current-buffer) buf))
(progn
(pop-to-buffer "*shell*" t))
nil)
;;if no shell:
(if (one-window-p t) ;Make a new window, if we have
(split-window)) ; only one
(select-window (next-window (selected-window) 666)) ; go to other window
(shell)))) ;execute the shell
;;;
;;; hooks: these functions will be run in a buffer whenever the
;;; corresponding mode is started. Setting mode options and defining
;;; mode-specific key bindings should usually happen here.
;;;
(add-hook 'text-mode-hook
(function
(lambda () (auto-fill-mode t))))
(add-hook 'dired-mode-hook
(function
(lambda ()
(define-key dired-mode-map "\C-c\C-f" 'find-name-dired)
(define-key dired-mode-map "\C-cg" 'find-grep-dired))))
(add-hook 'latex-mode-hook
(function
(lambda ()
(define-key latex-mode-map "\C-c;" 'comment-region))))
(add-hook 'perl-mode-hook
(function
(lambda ()
;;(define-key perl-mode-map "\C-c\C-c" 'compile)
(define-key perl-mode-map "\C-cl" 'goto-line)
(define-key perl-mode-map "\C-m" 'reindent-then-newline-and-indent)
(font-lock-mode 1))))
(add-hook 'python-mode-hook
(function
(lambda ()
(make-local-variable 'line-number-mode)
(line-number-mode t)
(define-key python-mode-map "\C-cl" 'goto-line)
(define-key python-mode-map "\C-c;" 'comment-region)
(define-key python-mode-map "\C-c[" 'python-beginning-of-block)
(define-key python-mode-map "\C-c]" 'python-end-of-block)
(define-key python-mode-map "\C-c{" 'python-beginning-of-defun)
(define-key python-mode-map "\C-c}" 'python-end-of-defun)
(font-lock-mode 1))))
(add-hook 'c-mode-hook
(function
(lambda ()
(make-local-variable 'line-number-mode)
(line-number-mode t)
(font-lock-mode 1)
(setq indent-tabs-mode nil)
(define-key c-mode-map "\M-q" 'c-fill-paragraph)
(define-key c-mode-map "\C-cl" 'goto-line)
(define-key c-mode-map "\C-m" 'reindent-then-newline-and-indent)
(define-key c-mode-map "\C-c\C-c" 'compile)
(define-key c-mode-map "\C-c;" 'comment-region)
(define-key c-mode-map "\C-cb" 'c-beginning-of-defun)
(setq c-auto-newline nil)
(if (string-match "test" buffer-file-name)
(setq default-make-rule "test")
(setq default-make-rule "all"))
(setq c-brace-offset -1)
(make-local-variable 'compile-command)
(setq compile-command (concat "make -k " default-make-rule)))))
(add-hook 'c++-mode-hook
(function
(lambda ()
(make-local-variable 'line-number-mode)
(line-number-mode t)
(font-lock-mode 1)
(setq indent-tabs-mode nil)
(define-key c++-mode-map "\M-q" 'c-fill-paragraph)
(define-key c++-mode-map "\C-cl" 'goto-line)
(define-key c++-mode-map "\C-m" 'reindent-then-newline-and-indent)
(define-key c++-mode-map "\C-c\C-c" 'compile)
(define-key c++-mode-map "\C-c;" 'comment-region)
(define-key c++-mode-map "\C-cb" 'c-beginning-of-defun)
(define-key c++-mode-map (kbd "C-`") 'next-error)
;(define-key c++-mode-map ":" 'self-insert-command)
(setq c-auto-newline nil)
(if (string-match "test" buffer-file-name)
(setq default-make-rule "test")
(setq default-make-rule "all"))
(c-guess)
(make-local-variable 'compile-command)
(setq compile-command (concat "make -k " default-make-rule)))))
(add-hook 'java-mode-hook
(function
(lambda ()
(make-local-variable 'line-number-mode)
(line-number-mode t)
(font-lock-mode 1)
(setq indent-tabs-mode nil)
(define-key java-mode-map "\C-cl" 'goto-line)
(define-key java-mode-map "\C-m" 'reindent-then-newline-and-indent)
(define-key java-mode-map "\C-c\C-c" 'compile)
(define-key java-mode-map "\C-c;" 'comment-region)
(make-local-variable 'compile-command)
(setq compile-command (concat "javac " buffer-file-name)))))
(add-hook 'lisp-mode-hook
(function
(lambda ()
(font-lock-mode 1)
(setq lisp-indent-offset 2)
(define-key lisp-mode-map "\C-m" 'reindent-then-newline-and-indent)
(define-key lisp-mode-map "\C-c;" 'comment-region)
(define-key lisp-mode-map "\C-cl" 'goto-line))))
(add-hook 'octave-mode-hook
(function
(lambda ()
(make-local-variable 'line-number-mode) ; turn on line number mode locally
(line-number-mode t)
(font-lock-mode 1) ;turn on font lock
(define-key octave-mode-map "\C-cl" 'goto-line)
(define-key octave-mode-map "\C-m" 'reindent-then-newline-and-indent))))
;;;
;;; Add entries to auto-mode alist. Determines which mode to start up
;;; when a file is visited based on the filename.
;;;
(setq auto-mode-alist (cons '("\\.m\\'" . octave-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\\.F90\\'" . f90-mode) auto-mode-alist))
;; commit log messages in text mode
(setq auto-mode-alist (cons '("COMMIT_EDITMSG" . text-mode) auto-mode-alist))
;; related: determine whether a file is a temp file
(setq server-temp-file-regexp
"^/tmp/Re\\|/draft$\\|/.letter\\|/.article\\|\\<foo\\|\\<KILL\\>")
;; settings for character terminals. I'll probably never use them again, but whatever
(setq enable-flow-control-on "vt220")
(setq visible-bell t)
;;;
;;; Miscellaneous interface customization
;;;
;; transient mark options -- obviously you should pick only one
;;(setq transient-mark-mode t) ; enable visual feedback on selections
(setq transient-mark-mode nil) ; disable visual feedback on selections
;; default to better frame titles
(setq frame-title-format
(concat "%b - emacs@" (system-name)))
;; default to unified diffs, if that's how you roll
;;(setq diff-switches "-u")
;; turn on font-lock mode (i.e., syntax highlighting)
(when (fboundp 'global-font-lock-mode)
(global-font-lock-mode t))
;; set up the fortune program. Everybody likes fortunes.
(set-variable 'fortune-file "/usr/share/games/fortunes") ; replace with system-appropriate location
(set-variable 'fortune-program "/usr/games/fortune") ; likewise
(global-set-key "\C-x\C-m" 'fortune) ; control-x return
;; always end a file with a newline. Choices are
;; nil - don't require final newline
;; t - add when about to save (if necessary)
;; "visit" - add newline when the file is visited
;; "visit-save" - add both on visit and save
;; anything else - ask on save
(setq require-final-newline "visit-save")
;; for files with multiple names, make the backup file by copying
;; (instead of renaming), even if the normal setting is to rename
(setq backup-by-copying-when-linked t)
;; change the amount by which the display scrolls when the point moves
;; just off screen (default is to recenter)
(setq scroll-step 5)
;; Thes interactive commands are normally disabled. The following enables them.
(put 'narrow-to-region 'disabled nil)
(put 'eval-expression 'disabled nil)
(server-start) ; for using emacsclient as your editor
(display-time)
(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.
'(custom-safe-themes
'("4eb9462a8fff9153bfe88a9ef53aa043aec8b79c5298d2873e887e0c3a8b03de" default))
'(inhibit-startup-screen t)
'(package-selected-packages
'(rust-auto-use python-mode auto-dark atom-one-dark-theme atom-dark-theme nano-theme ## yaml-mode yaml ws-butler wgrep web-mode visual-regexp use-package tabbar smart-mode-line session rust-mode pyvenv python-environment protobuf-mode pod-mode pkg-info pcre2el muttrc-mode mutt-alias markdown-toc initsplit htmlize graphviz-dot-mode graphql go-mode gitignore-mode gitconfig-mode gitattributes-mode git-timemachine git-modes git-commit ghub folding eproject editorconfig dockerfile-mode diminish csv-mode company color-theme-modern browse-kill-ring boxquote bm bar-cursor auto-complete apache-mode)))
(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.
)