-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.el
executable file
·1474 lines (1207 loc) · 44.3 KB
/
init.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
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
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
(set-language-environment "utf-8")
;; -------------
;; debug config
;; -------------
(setq debug-on-error t)
;; -------------
;; color config
;; -------------
(defvar bjh-color 'dark) ;; light or dark?
;; -----------------
;; package.el config
;; -----------------
(require 'cl)
(require 'package)
(add-to-list 'package-archives
'("melpa" . "http://melpa.milkbox.net/packages/") t)
(setq package-enable-at-startup nil)
(package-initialize)
(defvar bjh-packages
'(ag
ansible
anzu
auto-package-update
autopair
browse-kill-ring
buffer-move
c-eldoc
cider
clojure-mode
color-theme
company
company-go
dash
dired-single
dockerfile-mode
enh-ruby-mode
evil
exec-path-from-shell
expand-region
find-file-in-project
flycheck
flymake
flymake-cursor
flymake-rust
full-ack
gh
ghc
gist
git-timemachine
gitignore-mode
gnuplot-mode
go-eldoc
go-errcheck
go-mode
goto-last-change
haskell-mode
hi2
highlight-parentheses
gitconfig-mode
htmlize
idle-highlight-mode
ido-ubiquitous
js-comint
js2-mode
json-mode
lua-mode
magit
markdown-mode
multi-term
paredit
protobuf-mode
pt
puppet-mode
rainbow-delimiters
rich-minority
rust-mode
sbt-mode
scala-mode2
scpaste
scratch
smex
smooth-scrolling
toml-mode
undo-tree
vcl-mode
xcscope
yaml-mode))
(defun bjh-packages-installed-p ()
(loop for p in bjh-packages
when (not (package-installed-p p)) do (return nil)
finally (return t)))
(unless (bjh-packages-installed-p)
;; check for new packages (package versions)
(message "%s" "Emacs is now refreshing its package database...")
(package-refresh-contents)
(message "%s" " done.")
;; install the missing packages
(dolist (p bjh-packages)
(when (not (package-installed-p p))
(package-install p))))
;; update weekly
(require 'auto-package-update)
(setq auto-package-update-interval 7)
(auto-package-update-maybe)
;; removed from Emacs but still used in some libraries http://repo.or.cz/w/emacs.git/patch/3ffbb1932753854b275cd2be6b8c0009cf3380a5
;(defun ad-advised-definition-p (definition)
; "Return non-nil if DEFINITION was generated from advice information."
; (if (or (ad-lambda-p definition)
; (macrop definition)
; (ad-compiled-p definition))
; (let ((docstring (ad-docstring definition)))
; (and (stringp docstring)
; (get-text-property 0 'dynamic-docstring-function docstring)))))
;; -------------
;; plugin config
;; -------------
;; flycheck
; (global-flycheck-mode)
;; flymake
;(setq-default flymake-gui-warnings-enabled nil)
;(require 'flymake)
;(load-library "flymake-cursor")
;; show total matches in modeline
(global-anzu-mode t)
;; autopair
(require 'autopair)
(autopair-global-mode) ;; enable autopair in all buffers
;; bnf-mode
(define-generic-mode 'bnf-mode
() ;; comment char: inapplicable because # must be at start of line
nil ;; keywords
'(
("^#.*" . 'font-lock-comment-face) ;; comments at start of line
("^<[^ \t\n]*?>" . 'font-lock-function-name-face) ;; LHS nonterminals
("<[^ \T\n]*?>" . 'font-lock-builtin-face) ;; other nonterminals
("::=" . 'font-lock-const-face) ;; "goes-to" symbol
("\|" . 'font-lock-warning-face) ;; "OR" symbol
)
'("\\.bnf\\'") ;; filename suffixes
nil ;; extra function hooks
"Major mode for BNF highlighting.")
;; browse-kill-ring
(require 'browse-kill-ring)
(browse-kill-ring-default-keybindings)
(setq browse-kill-ring-quit-action 'save-and-restore)
;; browse-url
(setq browse-url-browser-function 'browse-url-chromium
browse-url-chromium-program "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome")
;; c-mode
;(add-hook 'c-mode-common-hook '(lambda () (c-toggle-auto-state 1)))
(setq-default c-eldoc-includes "-I./ -I../ ")
(load "c-eldoc")
(add-hook 'c-mode-hook 'c-turn-on-eldoc-mode)
;(add-to-list 'load-path (expand-file-name "~/.emacs.d/irony-mode/elisp/"))
;(require 'irony)
(defun my-c++-hooks ()
"Enable the hooks in the preferred order: 'yas -> auto-complete -> irony'."
;; be cautious, if yas is not enabled before (auto-complete-mode 1), overlays
;; *may* persist after an expansion.
;; (yas/minor-mode-on)
;; (auto-complete-mode 1)
;; avoid enabling irony-mode in modes that inherits c-mode, e.g: php-mode
(when (member major-mode irony-known-modes)
(irony-mode 1)))
(add-hook 'c++-mode-hook 'my-c++-hooks)
(add-hook 'c-mode-hook 'my-c++-hooks)
;; cider
(add-hook 'cider-repl-mode-hook 'paredit-mode)
(add-hook 'cider-mode-hook 'cider-turn-on-eldoc-mode)
(setq cider-repl-pop-to-buffer-on-connect nil)
(setq cider-repl-history-file (expand-file-name "~/.emacs.d/cider-history"))
(add-hook 'cider-mode-hook 'ac-flyspell-workaround)
(setq cider-stacktrace-frames-background-color "#2D2828")
;; clojure-mode
(when (require 'clojure-mode nil t)
(add-hook 'clojure-mode-hook 'pretty-fns))
;; cscope
(require 'xcscope)
(cscope-setup)
;; cua-mode
(setq cua-rectangle-mark-key (kbd "<C-S-M-return>"))
(cua-mode t)
;; only use cua-mode for rectangle-edit
(setq cua-enable-cua-keys nil)
;; shift + click select region
(define-key global-map (kbd "<S-down-mouse-1>") 'ignore) ; turn off font dialog
(define-key global-map (kbd "<S-mouse-1>") 'mouse-set-point)
(put 'mouse-set-point 'CUA 'move)
;; dired
(require 'dired)
(require 'dired-single)
(require 'dired-x)
(setq dired-omit-files-p t)
(defun my-dired-init ()
"Bunch of stuff to run for dired, either immediately or when it's
loaded."
(define-key dired-mode-map [return] 'dired-single-buffer)
(define-key dired-mode-map [mouse-1] 'dired-single-buffer-mouse)
(define-key dired-mode-map "^"
(function
(lambda nil (interactive) (dired-single-buffer ".."))))
(define-key dired-mode-map "-"
(function
(lambda nil (interactive) (dired-single-buffer "..")))))
;; if dired's already loaded, then the keymap will be bound
(if (boundp 'dired-mode-map)
;; we're good to go; just add our bindings
(my-dired-init)
;; it's not loaded yet, so add our bindings to the load-hook
(add-hook 'dired-load-hook 'my-dired-init))
;; elisp
(require 'eldoc)
(setq eldoc-minor-mode-string nil)
(eldoc-add-command
'paredit-backward-delete
'paredit-close-round)
(add-hook 'emacs-lisp-mode-hook 'turn-on-eldoc-mode)
(add-hook 'emacs-lisp-mode-hook 'remove-elc-on-save)
(defun remove-elc-on-save ()
"If you're saving an elisp file, likely the .elc is no longer valid."
(make-local-variable 'after-save-hook)
(add-hook 'after-save-hook
(lambda ()
(if (file-exists-p (concat buffer-file-name "c"))
(delete-file (concat buffer-file-name "c"))))))
(define-key emacs-lisp-mode-map (kbd "M-.") 'find-function-at-point)
;; expand-region
(require 'expand-region)
(global-set-key (kbd "C-@") 'er/expand-region)
;; evil
;; (require 'evil)
;; (setq evil-emacs-state-cursor 'bar)
;; (evil-mode 1)
;; find-file
(global-set-key (kbd "C-x C-o") 'ff-find-other-file)
;; ffap
(when (fboundp 'find-file-at-point)
(global-set-key (kbd "C-c F") 'find-file-at-point))
;; ffip
(require 'find-file-in-project)
(setq ffip-limit 2048
ffip-patterns
'("*.clj" "*.css" "*.el" "*.html" "*.js" "*.py" "*.rb"
"*.txt" "*.dtjs" "*.dtpl" "*.erb" "*.yml" "*.conf"))
;; flyspell-mode
(setq ispell-program-name "aspell"
ispell-extra-args '("--sug-mode=ultra")
flyspell-mode-line-string nil)
;; gist
(require 'gist)
;; go-mode
(require 'go-mode-autoloads)
(require 'company)
(require 'company-go)
;; (add-hook 'before-save-hook 'gofmt-before-save)
(add-hook 'go-mode-hook
(lambda ()
(local-set-key (kbd "C-c C-r") 'go-remove-unused-imports)
(local-set-key (kbd "C-c i") 'go-goto-imports)
(local-set-key (kbd "M-.") 'godef-jump)
(setq-default)
(setq tab-width 2)
(setq standard-indent 2)
(setq indent-tabs-mode nil)
(set (make-local-variable 'company-backends) '(company-go))
(company-mode)))
(require 'go-eldoc)
(add-hook 'go-mode-hook 'go-eldoc-setup)
;; goto-last-change
(require 'goto-last-change)
;; gnuplot
(setq auto-mode-alist (append '(("\\.gp$" . gnuplot-mode)) auto-mode-alist))
;; haskell-mode
;; (add-hook 'haskell-mode-hook 'turn-on-haskell-indentation)
(require 'ghc)
(setq ghc-display-error 'minibuffer)
(require 'hi2)
(setq hi2-show-indentations nil)
(add-hook 'haskell-mode-hook 'turn-on-hi2)
(add-hook 'haskell-mode-hook (lambda () (ghc-init)))
;; highlight-parentheses
(require 'highlight-parentheses)
(setq hl-paren-minor-mode-string nil
hl-paren-colors
'("orange1" "yellow1" "greenyellow" "green1"
"springgreen1" "cyan1" "slateblue1" "magenta1" "purple"))
(defun enable-highlight-parentheses-mode ()
(highlight-parentheses-mode t))
;; ibuffer
(require 'ibuffer)
;; Use human readable Size column instead of original one
(define-ibuffer-column size-h
(:name "Size" :inline t)
(cond
((> (buffer-size) 1000) (format "%7.1fk" (/ (buffer-size) 1000.0)))
((> (buffer-size) 1000000) (format "%7.1fM" (/ (buffer-size) 1000000.0)))
(t (format "%8d" (buffer-size)))))
;; Modify the default ibuffer-formats
(setq ibuffer-formats
'((mark modified read-only " "
(name 18 18 :left :elide)
" "
(size-h 9 -1 :right)
" "
(mode 16 16 :left :elide)
" "
filename-and-process)))
;; ido
(setq ido-auto-merge-work-directories-length -1
ido-case-fold t
ido-create-new-buffer 'always
ido-enable-flex-matching t
ido-save-directory-list-file nil)
(require 'ido)
; (require 'ido-ubiquitous)
(ido-mode t)
(ido-everywhere t)
;; imenu
(require 'imenu)
;; js-mode
(setq js-indent-level 2)
;; js2-mode
;; (require 'js2-mode)
;; (add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))
;; (setq js2-highlight-level 3
;; js2-bounce-indent-p t
;; js2-consistent-level-indent-inner-bracket-p t
;; js2-pretty-multiline-decl-indentation-p t
;; js2-basic-offset 2)
;; js-comint
(require 'js-comint)
(setq inferior-js-program-command "/usr/bin/rhino")
;(setq inferior-js-program-command "/usr/local/bin/node-repl")
(add-hook 'js2-mode-hook '(lambda ()
(local-set-key "\C-x\C-e" 'js-send-last-sexp)
(local-set-key "\C-\M-x" 'js-send-last-sexp-and-go)
(local-set-key "\C-cb" 'js-send-buffer)
(local-set-key "\C-c\C-b" 'js-send-buffer-and-go)
(local-set-key "\C-cl" 'js-load-file-and-go)))
;; magit
(setq-default magit-last-seen-setup-instructions "1.4.0")
(require 'magit)
(global-set-key (kbd "C-x g") 'magit-status)
;; markdown-mode
(autoload 'markdown-mode "markdown-mode.el" "Major mode for editing Markdown files" t)
(add-to-list 'auto-mode-alist '("\\.mkd$" . markdown-mode))
;; man
(setq Man-notify-method 'aggressive)
;; multi-term
; To get special control codes use: cat, xev, od -a
; Use `list-colors-display' to view all available colors
(require 'multi-term)
(define-key term-raw-map (kbd "<C-right>") 'term-send-forward-word)
(define-key term-raw-map (kbd "<C-left>") 'term-send-backward-word)
(define-key term-raw-map (kbd "<M-backspace>") 'term-send-backward-kill-word)
(define-key term-raw-map (kbd "<C-prior>") 'multi-term-prev)
(define-key term-raw-map (kbd "<C-next>") 'multi-term-next)
(global-set-key (kbd "C-S-t") 'multi-term)
(defface bjh-term-color-black
'((t :foreground "black" :background "black"))
"Face used to render black color code."
:group 'term)
(defface bjh-term-color-red
'((t :foreground "red2" :background "red2"))
"Face used to render red2 color code."
:group 'term)
(defface bjh-term-color-green
'((t :foreground "green2" :background "green2"))
"Face used to render green2 color code."
:group 'term)
(defface bjh-term-color-yellow
'((t :foreground "yellow2" :background "yellow2"))
"Face used to render yellow2 color code."
:group 'term)
(defface bjh-term-color-blue
'((t :foreground "DodgerBlue2" :background "DodgerBlue2"))
"Face used to render DodgerBlue2 color code."
:group 'term)
(defface bjh-term-color-magenta
'((t :foreground "magenta2" :background "magenta2"))
"Face used to render magenta2 color code."
:group 'term)
(defface bjh-term-color-cyan
'((t :foreground "cyan2" :background "cyan2"))
"Face used to render cyan2 color code."
:group 'term)
(defface bjh-term-color-white
'((t :foreground "white" :background "white"))
"Face used to render white color code."
:group 'term)
(if (eq bjh-color 'dark)
(setq term-default-bg-color "#000000"
term-default-fg-color "white"
ansi-term-color-vector [term
bjh-term-color-black
bjh-term-color-red
bjh-term-color-green
bjh-term-color-yellow
bjh-term-color-blue
bjh-term-color-magenta
bjh-term-color-cyan
bjh-term-color-white]))
(defun bjh-term-line-mode ()
(interactive)
(set (make-local-variable 'cua-mode) t)
(set (make-local-variable 'transient-mark-mode) t)
(term-line-mode))
(defun bjh-term-char-mode ()
(interactive)
(set (make-local-variable 'cua-mode) nil)
(set (make-local-variable 'transient-mark-mode) nil)
(term-char-mode)
(comint-goto-process-mark))
(add-hook 'term-mode-hook
'(lambda ()
(autopair-mode -1)
(define-key term-raw-map (kbd "C-c C-j") 'bjh-term-line-mode)
(define-key term-mode-map (kbd "C-c C-k") 'bjh-term-char-mode)
(define-key term-raw-map (kbd "C-y") 'term-paste)))
;; nxml-mode
(add-to-list 'auto-mode-alist '("\\.\\(html\\|xml\\|xsl\\|xhtml\\)\\'" . nxml-mode))
; set indent to 4
(setq nxml-child-indent 4)
; remap finish element
(global-set-key [(control ?.)] 'nxml-finish-element)
;; occur
(defun isearch-occur ()
"Invoke `occur' from within isearch."
(interactive)
(let ((case-fold-search isearch-case-fold-search))
(occur (if isearch-regexp isearch-string (regexp-quote isearch-string)))))
(define-key isearch-mode-map (kbd "C-o") 'isearch-occur)
;; org-mode
(setq org-replace-disputed-keys t
org-startup-folded nil
org-log-done 'time
org-todo-keywords
'((sequence "TODO(t)" "|" "DONE(d)")
(sequence "FEATURE(f)" "|" "COMPLETED(c)")
(sequence "BUG(b)" "|" "FIXED(x)")
(sequence "|" "CANCELED(a)")))
(add-to-list 'auto-mode-alist '("\\.org$" . org-mode))
(require 'org)
(add-hook 'org-mode-hook
(lambda ()
(local-unset-key [(control tab)])
(flyspell-mode 1)))
(global-set-key "\C-cl" 'org-store-link)
(global-set-key "\C-ca" 'org-agenda)
(global-set-key "\C-cb" 'org-iswitchb)
;; paredit
(require 'paredit)
;; paren-mode
(require 'paren)
(set-face-attribute 'show-paren-match nil :background "gray20" :foreground "white")
;; puppet-mode
(require 'puppet-mode)
(add-to-list 'auto-mode-alist '("\\.pp$" . puppet-mode))
(setq puppet-indent-level 4)
;; python
(require 'python)
(setq python-indent-offset 2)
;; rainbow-delimiters
;; (require 'rainbow-delimiters)
;; recentf
(require 'recentf)
(recentf-mode t)
(setq recentf-max-saved-items 50)
(global-set-key (kbd "C-x C-r") 'ido-recentf-open)
(defun ido-recentf-open ()
"Use `ido-completing-read' to \\[find-file] a recent file"
(interactive)
(if (find-file (ido-completing-read "Find recent file: " recentf-list))
(message "Opening file...")
(message "Aborting")))
;; rcirc
(let ((irc-password-file (expand-file-name "~/.ircpass.el")))
(when (file-regular-p irc-password-file)
(load irc-password-file)
;; random bitlbee notes
; account add oscar <user> <pass> login.oscar.aol.com
; account add jabber <email> <pass> talk.google.com:5223:ssl
; chat add 0 <aim_channel>
(require 'rcirc)
;; (require 'rcirc-notify)
;; (setq my-rcirc-notify-message "%s has mentioned you."
;; my-rcirc-notify-keyword "%s has mentioned you."
;; my-rcirc-notify-message-private "%s sent you a private message.")
;; (require 'rcirc-notify-mode)
(add-hook 'rcirc-mode-hook
'(lambda ()
(set (make-local-variable 'blink-matching-paren) nil)
(set (make-local-variable 'scroll-conservatively) 8192)
(rcirc-track-minor-mode 1)
(flyspell-mode 1)
(autopair-mode -1)))
(setq rcirc-fill-column 80
rcirc-default-nick "brett_h"
rcirc-default-user-name "brett"
rcirc-default-full-name "Brett"
rcirc-keywords '("brett" "bretthoerner" "hoerner")
;rcirc-authinfo `(;("freenode" nickserv "brett_h" ,bjh-freenode-password)
; ;("localhost" bitlbee "brett_h" ,bjh-bitlbee-password)
; ;("bretthoerner.com" nickserv "brett_h" ,bjh-freenode-password))
rcirc-server-alist `(;("irc.freenode.net" :channels ("#emacs"))
;("localhost")
("localhost" :port 6668 :nick "brett_h" :password ,bjh-freenode-password)
;("mozilla.local" :port 6668 :nick "brett_h/mozilla" :password ,bjh-mozilla-password)
;("irc.mozilla.org" :port 6667 :nick "brett_h" :password ,bjh-mozilla-password)
))
(defun-rcirc-command clear (arg)
"Clear rcirc buffer."
(interactive "i")
(let ((inhibit-read-only t))
(delete-region
(point-min) rcirc-prompt-start-marker)))
(defun-rcirc-command reconnect (arg)
"Reconnect the server process."
(interactive "i")
(unless process
(error "There's no process for this target"))
(let* ((server (car (process-contact process)))
(port (process-contact process :service))
(nick (rcirc-nick process))
channels query-buffers)
(dolist (buf (buffer-list))
(with-current-buffer buf
(when (eq process (rcirc-buffer-process))
(remove-hook 'change-major-mode-hook
'rcirc-change-major-mode-hook)
(if (rcirc-channel-p rcirc-target)
(setq channels (cons rcirc-target channels))
(setq query-buffers (cons buf query-buffers))))))
(delete-process process)
(rcirc-connect server port nick
rcirc-default-user-name
rcirc-default-full-name
channels)))))
;; rich-minority
(require 'rich-minority)
(setq rm-blacklist (quote (" Abbrev"
" Anzu"
" ElDoc"
" FIC"
" Fill"
" Fly"
" GitGutter"
" MRev"
" Paredit"
" Projectile"
" Undo-Tree"
" VHl"
" WS"
" company"
" hl-p"
" hl-s"
" pair"
" yas")))
(rich-minority-mode)
;; rust
(require 'rust-mode)
(setq rust-indent-offset 2)
;; savehist
(savehist-mode 1)
;; saveplace
(setq-default save-place t)
(require 'saveplace)
;; scala
(require 'sbt-mode)
;; scpaste
(require 'scpaste)
(setq scpaste-http-destination "http://b.hoerner.us"
scpaste-scp-destination "bretthoerner.com:~/bretthoerner.com/media/paste"
scpaste-scp-port "2222")
;; scratch
(autoload 'scratch "scratch" nil t)
;; slime
; (eval-after-load 'slime
; '(define-key slime-mode-map (kbd "C-c p")
; 'slime-pprint-eval-last-expression))
;
; (eval-after-load 'slime-repl
; '(define-key slime-repl-mode-map (kbd "C-c p")
; 'slime-pprint-eval-last-expression))
;
; (require 'slime nil t)
; (if (fboundp 'slime)
; (progn
; (setq slime-lisp-implementations '((sbcl ("/usr/bin/sbcl")))
; slime-net-coding-system 'utf-8-unix
; slime-protocol-version 'ignore)
; (global-set-key "\C-cs" 'slime-selector)
; (slime-setup '(slime-repl))
; (slime-require :swank-listener-hooks)))
;; smerge
(defun sm-try-smerge ()
(save-excursion
(goto-char (point-min))
(when (re-search-forward "^<<<<<<< " nil t)
(smerge-mode 1))))
(add-hook 'find-file-hook 'sm-try-smerge t)
;; smex
(require 'smex)
(smex-initialize)
(global-set-key (kbd "M-x") 'smex)
(global-set-key (kbd "M-X") 'smex-major-mode-commands)
;; old M-x.
(global-set-key (kbd "C-c C-c M-x") 'execute-extended-command)
;; smooth-scrolling for keyboard
(require 'smooth-scrolling)
;; mouse-wheel scroll one line at a time
(setq mouse-wheel-scroll-amount '(1 ((shift) . 1)))
;; but accelerate
(setq mouse-wheel-progressive-speed t)
;; sql
(defun sql-add-newline-first (output)
"Add newline to beginning of OUTPUT for `comint-preoutput-filter-functions'"
(concat "\n" output))
(defun sqli-add-hooks ()
"Add hooks to `sql-interactive-mode-hook'."
(add-hook 'comint-preoutput-filter-functions
'sql-add-newline-first))
(add-hook 'sql-interactive-mode-hook 'sqli-add-hooks)
;; tramp
(setq tramp-default-method "ssh"
tramp-persistency-file-name nil)
(require 'tramp)
;; undo-tree
(require 'undo-tree)
(global-undo-tree-mode)
;; uniquify
(setq uniquify-after-kill-buffer-p t
uniquify-buffer-name-style 'post-forward
uniquify-ignore-buffers-re "^\\*"
uniquify-separator ": ")
(require 'uniquify)
;; varnish
(require 'vcl-mode)
(setq vcl-indent-level 2)
;; --------------
;; general config
;; --------------
;; can't seem to get this to work
;; (add-to-list 'minor-mode-alist '(auto-fill-function ""))
;; cold turkey
;; (global-unset-key (kbd "<left>"))
;; (global-unset-key (kbd "<right>"))
;; (global-unset-key (kbd "<up>"))
;; (global-unset-key (kbd "<down>"))
;; show line numbers
;; (require 'linum)
;; (global-linum-mode 1)
;; example of .dir-locals.el
;; ((js2-mode . ((indent-tabs-mode . t))))
;; fix for S-up being interpreted as <select>
;; and other keys like S-M-arrow
;; https://groups.google.com/d/topic/gnu.emacs.help/rR478H4BDU8/discussion
(when (and (tty-type) (string-match "xterm" (tty-type)))
(define-key input-decode-map "\e[1;2A" [S-up])
(define-key input-decode-map "\e\e[1;2C" [S-M-right])
(define-key input-decode-map "\e\e[1;2D" [S-M-left]))
;; wrap at edge of window
(setq truncate-lines nil
truncate-partial-width-windows nil)
;; final newlines are good
(setq require-final-newline t)
;; revert changed files automatically
(global-auto-revert-mode t)
;; kill out to clipboard
(setq x-select-enable-clipboard t)
;; useful for running commands that then output to the minibuffer itself
(setq enable-recursive-minibuffers t)
;; interact with system clipboard when using kill/yank on OS X
(when (eq system-type 'darwin)
(setq interprogram-cut-function
(lambda (text &optional push)
(let* ((process-connection-type nil)
(pbproxy (start-process "pbcopy" "pbcopy" "/usr/bin/pbcopy")))
(process-send-string pbproxy text)
(process-send-eof pbproxy))))
(setq interprogram-paste-function
(lambda ()
(shell-command-to-string "pbpaste"))))
;; tell apropos to do more
(setq apropos-do-all t)
;; case-insensitive completion
(setq completion-ignore-case1 t
read-buffer-completion-ignore-case t
read-file-name-completion-ignore-case t)
;; use text-mode not fundamental-mode
(setq default-major-mode 'text-mode)
;; http://article.gmane.org/gmane.emacs.devel/64807
(setq parse-sexp-ignore-comments t)
;; completion in M-:
(when (keymapp read-expression-map)
(define-key read-expression-map (kbd "TAB") 'lisp-complete-symbol))
;; always try to indent on newline
(define-key global-map (kbd "RET") 'newline-and-indent)
;; rename buffer on F2
(define-key global-map (kbd "<f2>") 'rename-buffer)
;; show full file path on F6
(define-key global-map (kbd "<f6>") (lambda ()
(interactive "*")
(message buffer-file-truename)))
;; revert buffer on F5
(define-key global-map (kbd "<f5>") 'revert-buffer)
;; no startup message or splash screen
(setq inhibit-splash-screen t
inhibit-startup-message t
inhibit-startup-echo-area-message t)
;; don't insert instructions into the *scratch* buffer
(setq initial-scratch-message nil)
;; don't copy selected text to kill-ring automatically
(setq mouse-drag-copy-region nil)
;; mouse usage in terminal
(add-hook 'after-init-hook (lambda ()
(xterm-mouse-mode 1)))
;; automatically make files with #! executable on save
(add-hook 'after-save-hook
'executable-make-buffer-file-executable-if-script-p)
;; don't split without me asking
(setq-default split-width-threshold nil)
(setq-default split-height-threshold nil)
;; don't show vc info in modeline
(setq vc-display-status nil)
;; indent via spaces not tabs
(setq-default indent-tabs-mode nil)
;; tab = 4 spaces
(setq-default default-tab-width 2)
(setq-default tab-width 2)
;; set C indent to 2 spaces
(setq-default c-basic-offset 2
c-default-style "linux")
;; set tab stops based on default-tab-width
(setq-default tab-stop-list (loop for i
from default-tab-width to 120
by default-tab-width
collect i))
;; C-k deletes the whole line
(setq kill-whole-line t)
;; backspace on whitespace turns to spaces and removes one
(setq backward-delete-char-untabify-method 'untabify)
;; completion in mini-buffer
(icomplete-mode t)
;; show line numbers
(line-number-mode t)
;; matching pairs
;; (electric-pair-mode t)
;; show column number in status bar
(column-number-mode 1)
;; highlight characters after 80 columns
(setq whitespace-style '(face trailing lines-tail space-before-tab
space-after-tab))
;; use UTF-8 encoding
(setq locale-coding-system 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(set-selection-coding-system 'utf-8)
(prefer-coding-system 'utf-8)
;; follow symlinks to version controlled files
(setq vc-follow-symlinks t)
;; transparently open compressed files
(auto-compression-mode t)
;; titlebar = buffer unless filename
(setq frame-title-format '(buffer-file-name "%f" ("%b")))
;; don't make *~ files
(setq make-backup-files nil)
; don't make ~/.saves-PID-hostname
(setq auto-save-list-file-prefix nil)
; disable auto-saving
(setq auto-save-default nil)
; don't make me double escape \
(require 're-builder)
(setq reb-re-syntax 'string)
;; allows "y" instead of "yes" on exit
(fset 'yes-or-no-p 'y-or-n-p)
;; always ask if you really want to exit
; (setq confirm-kill-emacs 'yes-or-no-p)
;; allow narrowing
(put 'narrow-to-region 'disabled nil)
;; default to unified diffs
(setq diff-switches "-u -w")
;; bind unbound join-line
(global-set-key (kbd "C-c q") 'join-line)
;; C-x C-m as replacement for M-x
(global-set-key "\C-x\C-m" 'execute-extended-command)
(global-set-key "\C-c\C-m" 'execute-extended-command)
;; C-x C-u for undo (a common typo of mine)
(global-set-key [(control ?x) (control ?u)] 'undo)
;; keep things in the same window
(setq pop-up-windows nil)
(add-to-list 'same-window-buffer-names "*Help*")
(add-to-list 'same-window-buffer-names "*Apropos*")
(add-to-list 'same-window-buffer-names "*Summary*")
;; better C-a
(defun smart-beginning-of-line ()
"Move point to first non-whitespace character or beginning-of-line.
Move point to the first non-whitespace character on this line.
If point was already at that position, move point to beginning of line."
(interactive)
(let ((oldpos (point)))
(back-to-indentation)
(and (= oldpos (point))
(beginning-of-line))))
(global-set-key "\C-a" 'smart-beginning-of-line)
;; lolworthy function from esk
(defun bjh-disapproval ()
(interactive)
(insert "ಠ_ಠ"))
;; hippie-expand
(require 'hippie-exp)
(global-set-key (kbd "M-/") 'hippie-expand)
(delete 'try-expand-line hippie-expand-try-functions-list)
(delete 'try-expand-list hippie-expand-try-functions-list)
(delete 'try-complete-file-name-partially hippie-expand-try-functions-list)
(delete 'try-complete-file-name hippie-expand-try-functions-list)
;; mark dedicated window
(defun toggle-sticky-buffer-window ()
"Toggle whether this window is dedicated to this buffer."
(interactive)