-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdot-emacs
978 lines (792 loc) · 28.4 KB
/
dot-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
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
;; -*- Mode: emacs-lisp; -*-
;; Emacs configuration
;;
;; (c) July 2011 - Manuel Odendahl - [email protected]
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; General setup
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defvar HOME (expand-file-name "~"))
(setq home-dir HOME)
(setq user-mail-address "[email protected]")
(defvar emacs-dir (file-name-directory (file-truename "~/.emacs")))
(add-to-list 'load-path emacs-dir)
(setq split-window-preferred-function 'split-window-sensibly)
(setq split-width-threshold nil)
;; crude fix for el capitan
(setq visible-bell nil)
(setq ring-bell-function 'ignore)
;; (setq server-use-tcp t)
;; (server-start)
;; paths
(defun add-emacs-dirs (&rest paths)
(dolist (path paths)
(add-to-list 'load-path (concat emacs-dir path "/"))))
(add-emacs-dirs
"packages"
;; "Slime"
"mo-git-blame"
; "auto-complete"
; "auto-complete-clang"
; "cucumber.el"
; "geben"
; "emacs-w3m"
; "clojure-mode"
"gist.el"
"tumble"
"lua-mode")
;; load elpa
(require 'package)
(setq package-user-dir (concat emacs-dir "packages/"))
(add-to-list 'package-archives
'("marmalade" . "http://marmalade-repo.org/packages/"))
(add-to-list 'package-archives
'("melpa" . "http://melpa.org/packages/"))
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/") t)
(package-initialize)
;; load modes
;; (require 'ruby-mode)
;; (require 'prefer-utf)
;; (unless (boundp 'aquamacs-version)
;; (require 'mouse)
;; (xterm-mouse-mode t)
;; (defun track-mouse (e))
;; (setq mouse-sel-mode t)
;; ;; terminal smooth scrolling
;; (defun smooth-scroll (increment)
;; (scroll-up increment)
;; (sit-for 0.05)
;; (scroll-up increment)
;; (sit-for 0.02)
;; (scroll-up increment)
;; (sit-for 0.02)
;; (scroll-up increment)
;; (sit-for 0.05)
;; (scroll-up increment)
;; (sit-for 0.06)
;; (scroll-up increment))
;; (global-set-key [(mouse-5)] '(lambda () (interactive) (smooth-scroll 1)))
;; (global-set-key [(mouse-4)] '(lambda () (interactive) (smooth-scroll -1)))
;; (defun my-terminal-config (&optional frame)
;; (if (not frame)
;; (xterm-mouse-mode 1)
;; (if xterm-mouse-mode
;; (xterm-mouse-mode 1))))
;; (add-hook 'after-make-frame-functions 'my-terminal-config)
;; )
;; key bindings for sexp navigation
(setq font-lock-verbose nil)
(global-set-key "\M-a" 'backward-sexp)
(global-set-key "\M-e" 'forward-sexp)
(global-set-key (kbd "ESC <up>") 'backward-up-list)
(global-set-key (kbd "ESC <down>") 'down-list)
(global-set-key (kbd "M-SPC") 'mark-sexp)
(add-emacs-dirs "solarized")
(require 'color-theme)
(color-theme-initialize)
(require 'color-theme-solarized)
(color-theme-dark-laptop)
(global-font-lock-mode t)
(set-face-attribute 'default nil
:family "Monaco" :height 100 :weight 'normal)
(menu-bar-mode -1)
(when (fboundp 'tool-bar-mode)
(tool-bar-mode -1))
(when (fboundp 'tabbar-mode)
(tabbar-mode -1))
(show-paren-mode 1)
(transient-mark-mode t)
;; automatic indent on return
(define-key global-map [(control m)] 'newline-and-indent)
; (define-key ruby-mode-map [(control m)] 'newline-and-indent)
(require 'asm-mode)
(define-key asm-mode-map [(control m)] 'newline-and-indent)
;; (global-set-key [(meta g)] 'goto-line)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Emacs lisp mode configuration
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(add-hook 'emacs-lisp-mode-hook 'turn-on-eldoc-mode)
(add-hook 'lisp-interaction-mode-hook 'turn-on-eldoc-mode)
(add-hook 'ielm-mode-hook 'turn-on-eldoc-mode)
(defun rgr/toggle-context-help ()
"Turn on or off the context help.
Note that if ON and you hide the help buffer then you need to
manually reshow it. A double toggle will make it reappear"
(interactive)
(with-current-buffer (help-buffer)
(unless (local-variable-p 'context-help)
(set (make-local-variable 'context-help) t))
(if (setq context-help (not context-help))
(progn
(if (not (get-buffer-window (help-buffer)))
(display-buffer (help-buffer)))))
(message "Context help %s" (if context-help "ON" "OFF"))))
(defun rgr/context-help ()
"Display function or variable at point in *Help* buffer if visible.
Default behaviour can be turned off by setting the buffer local
context-help to false"
(interactive)
(let ((rgr-symbol (symbol-at-point))) ; symbol-at-point http://www.emacswiki.org/cgi-bin/wiki/thingatpt%2B.el
(with-current-buffer (help-buffer)
(unless (local-variable-p 'context-help)
(set (make-local-variable 'context-help) t))
(when (and context-help (get-buffer-window (help-buffer))
rgr-symbol)
(progn
(if (fboundp rgr-symbol)
(describe-function rgr-symbol)
(if (boundp rgr-symbol)
(describe-variable rgr-symbol))))))))
(defadvice eldoc-print-current-symbol-info
(around eldoc-show-c-tag activate)
(cond
((eq major-mode 'emacs-lisp-mode) (rgr/context-help) ad-do-it)
((eq major-mode 'lisp-interaction-mode) (rgr/context-help) ad-do-it)
((eq major-mode 'apropos-mode) (rgr/context-help) ad-do-it)
(t ad-do-it)))
(global-set-key (kbd "C-c h") 'rgr/toggle-context-help)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Mode list
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; mode list stuff
(setq auto-mode-alist
(append '(
("\\.emacs$" . emacs-lisp-mode)
("\\.ino$" . c++-mode)
("\\.cu$" . c++-mode)
("\\.cl$" . c++-mode)
("\\.sh$" . shell-script-mode)
("\\.pde$" . java-mode)
("Capfile" . ruby-mode)
("\\.asd$" . lisp-mode)
("\\.lisp$" . lisp-mode)
("\\.lsp$" . lisp-mode)
("\\.cl$" . lisp-mode)
("\\.system$" . lisp-mode)
("\\.js" . js2-mode)
("\\.html" . html-mode)
("\\.bknr$" . nxml-mode)
("\\.mustache" . html-mode)
("\\.php" . php-mode)
("\\.sql" . sql-mode)
("\\.less" . css-mode)
("\\.s" . asm-mode)
("\\.S" . asm-mode)
("\\.clj" . clojure-mode)
) auto-mode-alist))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Slime setup
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq slime-contribs '(slime-fancy))
(defun load-slime ()
(require 'slime-autoloads)
(require 'slime)
(slime-setup '(slime-fancy slime-tramp slime-autodoc))0;95;c
(add-hook 'lisp-mode-hook (lambda ()
(slime-mode t)
(setq lisp-indent-function 'common-lisp-indent-function)
))
(global-set-key [(control t)] (quote slime-selector))
(setq slime-lisp-implementations
'(
;; (ccl-qh ("ccl-qh"))
(ccl64 ("ccl64"))
;; (clojure ("/usr/local/bin/clj"))
)))
(setq inferior-lisp-program "/usr/local/bin/ccl64")
;; (load-slime)
;; (add-hook 'inferior-lisp-mode-hook (lambda () (inferior-slime-mode t)))
;; (setq inferior-lisp-program "ccl-qh")
;;(define-key lisp-mode-map [(control m)] 'newline-and-indent)
;; (define-key js2-mode-map [(control m)] 'newline-and-indent)
;; add hyperspec lookup
(require 'info-look)
;; info-lookup-symbol in lisp: C-h S
(info-lookup-add-help
:mode 'lisp-mode
:regexp "[^][()'\" \t\n]+"
:ignore-case t
:doc-spec '(("(ansicl)Symbol Index" nil nil nil)))
(define-key global-map (kbd "C-h C-i") 'info-lookup-symbol)
(defun slime-quit-other-buffer ()
(interactive)
(other-window 1)
(slime-popup-buffer-quit))
; (define-key slime-mode-map (kbd "C-c q") 'slime-quit-other-buffer)
; (define-key slime-repl-mode-map (kbd "C-c q") 'slime-quit-other-buffer)
;; javascript swank-js hook
;; (add-hook 'js2-mode-hook
;; (lambda ()
;; (slime-js-minor-mode 1)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; C indent config
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq c-basic-offset 2)
(setq-default c-basic-offset 2)
(setq c-indent-level 2)
(setq tab-width 2)
(setq indent-tabs-mode t)
(setq-default indent-tabs-mode nil)
(global-auto-revert-mode 1)
(defun linux-c-mode ()
"C mode with adjusted defaults for use with the Linux
kernel."
(interactive)
(c-mode)
(setq c-indent-level 8)
(setq c-brace-imaginary-offset 0)
(setq c-brace-offset -8)
(setq c-argdecl-indent 8)
(setq c-label-offset -8)
(setq c-continued-statement-offset 8)
(setq indent-tabs-mode nil)
(setq tab-width 8))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Misc modes
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ack searching
(autoload 'ack-same "full-ack" nil t)
(autoload 'ack "full-ack" nil t)
(autoload 'ack-find-same-file "full-ack" nil t)
(autoload 'ack-find-file "full-ack" nil t)
(define-coding-system-alias 'utf8 'utf-8)
; (add-emacs-dirs "zencoding")
;(require 'zencoding-mode)
;(add-hook 'sgml-mode-hook 'zencoding-mode)
(require 'inf-ruby)
(autoload 'mo-git-blame-file "mo-git-blame" nil t)
(autoload 'mo-git-blame-current "mo-git-blame" nil t)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Autocomplete setup
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(require 'auto-complete-config)
(ac-config-default)
(add-to-list 'ac-dictionary-directories "~/.emacs.d/ac-dict")
(setq ac-auto-start nil)
(setq ac-quick-help-delay 0.1)
(define-key ac-mode-map (kbd "C-c TAB") 'auto-complete)
(defvar ac-cursor-color "blanched almond"
"Old cursor color.")
(defun my-ac-config ()
(setq ac-clang-flags (split-string "-I/usr/include/c++/4.2.1 -I/usr/include -I/usr/local/include"))
(setq ac-clang-executable "/usr/local/bin/clang")
(setq-default ac-sources '(ac-source-abbrev ac-source-dictionary ac-source-words-in-same-mode-buffers))
(add-hook 'emacs-lisp-mode-hook 'ac-emacs-lisp-mode-setup)
(add-hook 'c-mode-common-hook 'ac-cc-mode-setup)
(add-hook 'c++-mode-common-hook 'ac-cc-mode-setup)
(add-hook 'ruby-mode-hook 'ac-ruby-mode-setup)
(add-hook 'css-mode-hook 'ac-css-mode-setup)
(add-hook 'auto-complete-mode-hook 'ac-common-setup)
(global-auto-complete-mode t))
(defun my-ac-cc-mode-setup ()
(setq ac-sources (append '(ac-source-clang ac-source-yasnippet) ac-sources)))
(add-hook 'c-mode-common-hook 'my-ac-cc-mode-setup)
(add-hook 'c++-mode-common-hook 'my-ac-cc-mode-setup)
(my-ac-config)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Further configuration
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun kill-other-buffers ()
"Kill all other buffers."
(interactive)
(mapc 'kill-buffer
(delq (current-buffer)
(remove-if-not 'buffer-file-name (buffer-list)))))
(require 'el-navigation)
; (require 'w3m-load)
; (setq w3m-pop-up-frames t)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; misc stuff
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(require 'hide-region)
(defun indent-buffer ()
(interactive)
(indent-region (point-min) (point-max)))
(global-set-key (kbd "C-M-]") 'indent-buffer)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; linum
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(add-hook 'find-file-hook (lambda () (when (buffer-file-name) (linum-mode 1))))
;; (global-linum-mode t)
;; (global-linum-mode nil)
(setq linum-format "%d ")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Clojure
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(require 'clojure-mode)
(require 'ac-cider)
(add-hook 'cider-mode-hook 'ac-flyspell-workaround)
(add-hook 'cider-mode-hook 'ac-cider-setup)
(add-hook 'cider-repl-mode-hook 'ac-cider-setup)
(eval-after-load "auto-complete"
'(progn
(add-to-list 'ac-modes 'cider-mode)
(add-to-list 'ac-modes 'cider-repl-mode)))
(defun set-auto-complete-as-completion-at-point-function ()
(setq completion-at-point-functions '(auto-complete)))
(add-hook 'auto-complete-mode-hook 'set-auto-complete-as-completion-at-point-function)
(add-hook 'cider-mode-hook 'set-auto-complete-as-completion-at-point-function)
(add-hook 'cider-mode-hook 'cider-turn-on-eldoc-mode)
(require 'cider-eldoc)
(define-key cider-repl-mode-map (kbd "M-RET") 'cider-repl-closing-return)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; markdown mode
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(add-emacs-dirs "markdown-mode")
(require 'markdown-mode)
(add-to-list 'auto-mode-alist '("\\.md$" . markdown-mode))
(define-key key-translation-map (kbd "M-[ C") (kbd "C-<right>"))
(define-key key-translation-map (kbd "M-[ d") (kbd "C-<left>"))
(defun file-basename (filename)
(replace-regexp-in-string "^\\(.*\/\\)?\\([^/\.]*\\)\\(\.[^\.]*\\)?$" "\\2" filename))
(defun downcase-first (string)
(store-substring string 0 (downcase (substring string 0 1))))
;;; automatic revert (git!!)
(global-auto-revert-mode 1)
(require 'pbcopy)
(turn-on-pbcopy)
(setq make-backup-files nil)
(put 'downcase-region 'disabled nil)
;; gist.el
(require 'gist)
(setq gist-view-gist t)
(load "~/.private.el")
(require 'align)
(add-to-list 'align-rules-list
'(php-array
(regexp . "\\(\\s-*\\)=>")
(group . 1)
(modes . (list 'php-mode))
(repeat . nil)))
;; (add-to-list 'align-rules-list
;; '(assignments
;; (regexp . "\\(\\s-*\\)=[^>]")
;; (group . 1)
;; (modes . (list 'php-mode 'c-mode 'js-mode 'js2-mode))
;; (repeat . nil)))
(add-to-list 'align-rules-list
'(assignments
(regexp . "\\(\\s-*\\):\\(\\s-+\\)")
(group . 2)
(modes . (list 'js-mode 'js2-mode))
(repeat . nil)))
(add-to-list 'align-rules-list
'(assignments
(regexp . ")\\(\\s-*\\)\\.")
(group . 1)
(modes . (list 'js-mode 'js2-mode))
(spacing . 0)
(repeat . nil)))
(add-to-list 'align-rules-list
'(assignments
(regexp . ",\\(\\s-*\\)")
(group . 1)
(modes . (list 'js-mode 'js2-mode 'c-mode 'c++-mode 'php-mode))
(spacing . 1)
(repeat . nil)))
(setq align-rules-list (remove-if (lambda (x) (eq (car x) 'c++-comment)) align-rules-list))
;; align c-comments in c-mode
(add-to-list 'align-rules-list
`(c-comment
(regexp . ,(concat "\\(\\s-*\\)" (regexp-quote "/* ")))
(modes . (list 'c-mode 'c++-mode))))
;; align c-comments in asm-mode
(add-to-list 'align-rules-list
`(asm-comment
(regexp . ,(concat "\\(\\s-*\\)" (regexp-quote "/* ")))
(modes . (list 'asm-mode))))
(add-to-list 'align-open-comment-modes 'asm-mode)
(add-to-list 'align-rules-list
'(assignments
(regexp . "\\(\\s-*\\)//")
(group . 1)
(modes . (list 'js-mode 'js2-mode 'c-mode 'c++-mode 'php-mode))
(spacing . 1)
(repeat . nil)))
(define-key global-map (kbd "M-'") 'align)
(define-key global-map (kbd "M-\"") 'align-regexp)
(define-key global-map (kbd "M-C-_") 'fixup-whitespace)
(setq whitespace-style '(face tabs trailing space-before-tab
empty space-after-tab tab-mark))
;; (global-whitespace-mode t)
(require 'ethan-wspace)
(global-ethan-wspace-mode 1)
(defun my-makefile-hook ()
(message "makefile hook")
(setq ethan-wspace-mode nil)
(ethan-wspace-mode 0)
(ethan-wspace-clean-tabs-mode 0)
(ethan-wspace-highlight-tabs-mode 0)
(message "ethan wspace mode %s" ethan-wspace-mode))
(add-hook 'makefile-mode-hook 'my-makefile-hook)
(add-hook 'makefile-bsdmake-mode-hook 'my-makefile-hook)
;; (require 'flymake-jslint)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Org mode
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(org-babel-do-load-languages
'org-babel-load-languages
'(
(C . t)
(clojure . t)
(ditaa . t)
(haskell . t)
(shell . true)
(emacs-lisp . t)
(plantuml . t)
(python . true)
))
(setq org-plantuml-jar-path (expand-file-name "/usr/local/Cellar/plantuml/8015/plantuml.8015.jar"))
(setq org-ditaa-jar-path (expand-file-name "/usr/local/Cellar/ditaa/0.9/libexec/ditaa0_9.jar"))
(add-to-list 'org-src-lang-modes
'("plantuml" . fundamental))
(setq org-image-actual-width 400)
(setq shift-select-mode nil)
(setq org-modules '(org-timer))
(setq org-mac-mail-account "[email protected]")
;(org-babel-do-load-languages
; 'org-babel-load-languages
;'((sh . true) (python . true)
; (js . true) ))
(global-set-key "\C-ca" 'org-agenda)
(global-set-key "\C-cb" 'org-iswitchb)
(global-set-key "\C-cl" 'org-store-link)
(setq org-startup-with-inline-images t)
(defun bh/display-inline-images ()
(condition-case nil
(org-display-inline-images)
(error nil)))
(add-hook 'org-babel-after-execute-hook 'bh/display-inline-images 'append)
; Do not prompt to confirm evaluation
; This may be dangerous - make sure you understand the consequences
; of setting this -- see the docstring for details
(setq org-confirm-babel-evaluate nil)
(add-hook 'remember-mode-hook 'org-remember-apply-template)
(define-key global-map [(control meta ?r)] 'remember)
(setq org-src-fontify-natively t)
;(setq org-confirm-babel-evaluate nil)
(setq org-log-done t)
(eval-after-load "org"
'(progn
(define-prefix-command 'org-todo-state-map)
(define-key org-mode-map "\C-cx" 'org-todo-state-map)
(setq org-agenda-files (list "~/code/wesen/wesen-misc/org/log.org"
"~/code/wesen/wesen-misc/org/formlabs.org"))
(define-key org-todo-state-map "x"
#'(lambda nil (interactive) (org-todo "CANCELLED")))
(define-key org-todo-state-map "d"
#'(lambda nil (interactive) (org-todo "DONE")))
(define-key org-todo-state-map "f"
#'(lambda nil (interactive) (org-todo "DEFERRED")))
(define-key org-todo-state-map "l"
#'(lambda nil (interactive) (org-todo "DELEGATED")))
(define-key org-todo-state-map "s"
#'(lambda nil (interactive) (org-todo "STARTED")))
(define-key org-todo-state-map "w"
#'(lambda nil (interactive) (org-todo "WAITING")))))
;; org-mode publishing
(setq org-publish-project-alist
'(("formlabs-notes"
:base-directory "~/code/wesen/wesen-misc/org/formlabs/"
:base-extension "org"
;; :publishing-directory "~/Sites/org/"
:publishing-directory "/ssh:[email protected]:public_html/"
:recursive nil
:publishing-function org-html-publish-to-html
:headline-levels 4
:auto-preamble t)
("org-static"
:base-directory "~/code/wesen/wesen-misc/org/formlabs/"
:base-extension "css\\|js\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|ogg\\|swf"
;; :publishing-directory "~/Sites/org/"
:publishing-directory "/ssh:[email protected]:public_html/"
:recursive t
:publishing-function org-publish-attachment
)
("org" :components ("org-notes" "org-static"))
)
)
(require 'ox-md)
; (require 'ox-taskjuggler)
(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.
'(coq-prog-args
(\`
("-emacs" "-R"
(\,
(concat emacs-dir "cpdt/src"))
"Cpdt")))
'(haskell-tags-on-save t)
'(org-export-backends (quote (ascii html icalendar latex md)))
'(promela-auto-match-delimiter nil)
'(tuareg-use-abbrev-mode t))
;(require 'flymake-jslint)
;(require 'ethan-wspace)
;(global-ethan-wspace-mode 1)
;; benjamin ferrari
(defun bf-pretty-print-xml-region (begin end)
"Pretty format XML markup in region. You need to have nxml-mode
http://www.emacswiki.org/cgi-bin/wiki/NxmlMode installed to do
this. The function inserts linebreaks to separate tags that have
nothing but whitespace between them. It then indents the markup
by using nxml's indentation rules."
(interactive "r")
(save-excursion
(nxml-mode)
(goto-char begin)
(while (search-forward-regexp "\>[ \\t]*\<" nil t)
(backward-char) (insert "\n"))
(indent-region begin end))
(message "Ah, much better!"))
(require 'htmlize)
(add-emacs-dirs "scpaste2")
(require 'scpaste)
(setq scpaste-http-destination "http://bl0rg.net/~manuel/p"
scpaste-scp-destination "bl0rg.net:public_html/p")
(defadvice terminal-init-xterm (after select-shift-up activate)
(define-key input-decode-map "\e[1;2A" [S-up])
(define-key input-decode-map "\e[1;2B" [S-down])
(define-key input-decode-map "\e[1;2C" [S-right])
(define-key input-decode-map "\e[1;2D" [S-left])
(define-key input-decode-map "\e[1;3A" [M-up])
(define-key input-decode-map "\e[1;3B" [M-down])
(define-key input-decode-map "\e[1;3C" [M-right])
(define-key input-decode-map "\e[1;3D" [M-left])
(define-key input-decode-map "\e[1;5A" [C-up])
(define-key input-decode-map "\e[1;5B" [C-down])
(define-key input-decode-map "\e[1;5C" [C-right])
(define-key input-decode-map "\e[1;5D" [C-left]))
(require 'longlines)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; custom variables
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(require 'go-mode-load)
(require 'go-autocomplete)
(require 'auto-complete-config)
(setq ac-expand-on-auto-complete nil
ac-use-quick-help t
ac-use-fuzzy nil
ac-menu-height 20)
(define-key ac-mode-map (kbd "C-c TAB") 'auto-complete)
(define-key ac-mode-map (kbd "C-c H") 'ac-last-persist-help)
(define-key ac-mode-map (kbd "C-c h") 'ac-help)
(add-hook 'go-mode-hook '(lambda()
(setq ethan-wspace-mode nil)
(setq ethan-wspace-highlight-tabs-mode nil)
(ethan-wspace-mode 0)
(ethan-wspace-clean-tabs-mode 0)
(ethan-wspace-highlight-tabs-mode 0)
(setq tab-width 2)))
(setq tags-table-list '("/Users/manuel/code/misc/go-path/" "."))
;; (require 'pos-tip)
(defun orgtbl-to-markdown (table params)
"Convert the Orgtbl mode TABLE to Markdown."
(let* ((alignment (mapconcat (lambda (x) (if x "r" "l"))
org-table-last-alignment ""))
(params2
(list
:tstart ""
:tend ""
:lstart "|" :lend "|" :sep "| "
:efmt "%s\\,(%s)" :hline "---")))
(orgtbl-to-generic table (org-combine-plists params2 params))))
(defun markdown-preview-file ()
"run Marked on the current file and revert the buffer"
(interactive)
(shell-command
(format "open -a /Applications/Marked.app %s"
(shell-quote-argument (buffer-file-name))))
)
(global-set-key "\C-cm" 'markdown-preview-file)
;; glsl mode
(autoload 'glsl-mode "glsl-mode" nil t)
(add-to-list 'auto-mode-alist '("\\.vsh\\'" . glsl-mode))
(add-to-list 'auto-mode-alist '("\\.fsh\\'" . glsl-mode))
(require 'haskell-interactive-mode)
(require 'haskell-process)
; (add-hook 'haskell-mode-hook 'interactive-haskell-mode)
(add-hook 'haskell-mode-hook 'turn-on-haskell-indentation)
(add-hook 'haskell-mode-hook 'haskell-indent-mode)
(add-hook 'haskell-mode-hook 'turn-on-haskell-doc-mode)
;; Usage Example:
;;
;; <!-- BEGIN RECEIVE ORGTBL ${1:YOUR_TABLE_NAME} -->
;; <!-- END RECEIVE ORGTBL $1 -->
;;
;; <!--
;; #+ORGTBL: SEND $1 orgtbl-to-gfm
;; | $0 |
;; -->
(defun orgtbl-to-gfm (table params)
"Convert the Orgtbl mode TABLE to GitHub Flavored Markdown."
(let* ((alignment (mapconcat (lambda (x) (if x "|--:" "|---"))
org-table-last-alignment ""))
(params2
(list
:splice t
:hline (concat alignment "|")
:lstart "| " :lend " |" :sep " | ")))
(concat (orgtbl-to-generic table (org-combine-plists params2 params)) "\n")))
(defun stag-insert-org-to-md-table (table-name)
(interactive "*sEnter table name: ")
(insert "<!---
#+ORGTBL: SEND " table-name " orgtbl-to-gfm
-->
<!--- BEGIN RECEIVE ORGTBL " table-name " -->
<!--- END RECEIVE ORGTBL " table-name " -->")
(previous-line)
(previous-line)
(previous-line))
(defun clear-shell ()
"Clear a comint window buffer"
(interactive)
(let ((comint-buffer-maximum-size 0))
(comint-truncate-buffer)))
(add-emacs-dirs "flymake-easy" "flymake-haskell-multi" "emacs-flymake-cursor")
(require 'flymake-easy)
(require 'flymake-haskell-multi)
(add-hook 'haskell-mode-hoook 'flymake-haskell-multi-load)
(add-hook 'haskell-mode-hoook 'flymake-cursor-mode)
(eval-after-load 'flymake '(require 'flymake-cursor))
(require 'server)
(unless (server-running-p)
(server-start))
(put 'narrow-to-region 'disabled nil)
(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.
)
;; tufte-book class for writing classy books
(require 'ox-latex)
(add-to-list 'org-latex-classes
'("tuftebook"
"\\documentclass{tufte-book}\n
\\usepackage{color}
\\usepackage{amssymb}
\\usepackage{gensymb}
\\usepackage{nicefrac}
\\usepackage{units}"
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
(add-to-list 'org-latex-classes
'("tuftehandout"
"\\documentclass{tufte-handout}
\\usepackage{color}
\\usepackage{amssymb}
\\usepackage{amsmath}
\\usepackage{gensymb}
\\usepackage{nicefrac}
\\usepackage{units}"
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
;; coq mode
(load-file (concat emacs-dir "/ProofGeneral/generic/proof-site.el"))
(add-to-list 'load-path "/usr/local/opt/coq/lib/emacs/site-lisp")
(setq auto-mode-alist (cons '("\\.v$" . coq-mode) auto-mode-alist))
(autoload 'coq-mode "coq" "Major mode for editing Coq vernacular." t)
(with-eval-after-load 'coq
(define-key coq-mode-map (kbd "C-c i") 'proof-query-identifier)
;; from http://www.dougwoos.com/2014/03/01/prettifying-coq-buffers-in-emacs.html
(global-prettify-symbols-mode 1)
(setq coq-symbols
'(("forall" ?∀)
("->" ?→)
("exists" ?∃)
("=>" ?⇒)
("False" ?⊥)
("fun" ?λ)
("True" ?⊤)))
(add-hook 'coq-mode-hook
(lambda ()
(setq prettify-symbols-alist coq-symbols)))
(add-hook 'coq-goals-mode-hook
(lambda ()
(setq prettify-symbols-alist coq-symbols)))
(add-hook 'coq-response-mode-hook
(lambda ()
(setq prettify-symbols-alist coq-symbols))))
;; ocaml stuff
(autoload 'utop "utop" "Toplevel for OCaml" t)
(autoload 'utop-minor-mode "utop" "Minor mode for utop" t)
(add-hook 'tuareg-mode-hook 'utop-minor-mode)
;; Add opam emacs directory to the load-path
(setq opam-share (substring (shell-command-to-string "opam config var share 2> /dev/null") 0 -1))
(add-to-list 'load-path (concat opam-share "/emacs/site-lisp"))
;; Load merlin-mode
(require 'merlin)
;; Start merlin on ocaml files
(add-hook 'tuareg-mode-hook 'merlin-mode t)
(add-hook 'caml-mode-hook 'merlin-mode t)
;; Enable auto-complete
(setq merlin-use-auto-complete-mode 'easy)
;; Use opam switch to lookup ocamlmerlin binary
(setq merlin-command 'opam)
(setq auto-mode-alist
(append '(("\\.ml[ily]?$" . tuareg-mode)
("\\.topml$" . tuareg-mode))
auto-mode-alist))
(add-to-list 'align-rules-list
'(ocaml-match
(regexp . "\\(\\s-*\\):")
(group . 1)
(modes . (list 'tuareg-mode))
(repeat . nil)))
(add-to-list 'align-rules-list
'(ocaml-match
(regexp . "\\(\\s-*\\)->")
(group . 1)
(modes . (list 'tuareg-mode))
(repeat . nil)))
(add-to-list 'align-rules-list
'(ocaml-match
(regexp . "\\(\\s-*\\)of")
(group . 1)
(modes . (list 'tuareg-mode))
(repeat . nil)))
(require 'ocp-indent)
;; verilog stuff
(require 'verilog-mode)
(defun dos2unix (buffer)
"Automate M-% C-q C-m RET C-q C-j RET"
(interactive "*b")
(save-excursion
(goto-char (point-min))
(while (search-forward (string ?\C-m) nil t)
(replace-match (string ?\C-j) nil t))))