metasyntax / Config / 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
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;                                                                        ;;;;
;;;;  EMACS MAIN CONFIGURATION FILE                                         ;;;;
;;;;                                                                        ;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;;  Load Path Manipulation
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(add-to-list 'load-path "~/elisp")
(add-to-list 'load-path "~/elisp/asn1")
(add-to-list 'load-path "~/elisp/bbdb")
(add-to-list 'load-path "~/elisp/erlang")
(add-to-list 'load-path "~/elisp/ess/lisp")
(add-to-list 'load-path "~/elisp/haskell")
(add-to-list 'load-path "~/elisp/logo")
(add-to-list 'load-path "~/elisp/muse")
(add-to-list 'load-path "~/elisp/org/lisp")
(add-to-list 'load-path "~/elisp/planner")
(add-to-list 'load-path "~/elisp/remember")
(add-to-list 'load-path "~/elisp/rcirc")
(add-to-list 'load-path "~/elisp/scala")
(add-to-list 'load-path "~/elisp/sml")
(add-to-list 'load-path "~/elisp/swank-clojure")
(add-to-list 'load-path "~/elisp/tuareg")

(setq tcv-emms-enable nil)		; Load EMMS configuration?
(setq tcv-mail-enable nil)		; Load mail configuration?
(setq tcv-irc-enable nil)		; Load IRC configuration?

;; Register info directories for installed elisp packages.

(add-to-list 'Info-default-directory-list "~/elisp/bbdb/info")
(add-to-list 'Info-default-directory-list "~/elisp/logo/info")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;;  Setting Mode by File Name
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(mapcar
 (lambda (mode-list)
   (if (listp (car mode-list))
       (progn
         (autoload (car (car mode-list)) (cadr (car mode-list))
           (concat "Major mode for editing " (cadr mode-list) "source code."))
         (add-to-list 'auto-mode-alist `(,(cadr (cdr mode-list)) . ,(car (car mode-list)))))
     (progn
       (autoload (car mode-list) (symbol-name (car mode-list))
         (concat "Major mode for editing " (cadr mode-list) "source code."))
       (add-to-list 'auto-mode-alist `(,(cadr (cdr mode-list)) . ,(car mode-list))))))
 '((asn1-mode      "ASN.1"                   "\\.asn$")
   (clojure-mode   "Clojure"                 "\\.clj$")
   (css-mode       "Cascading Style Sheets"  "\\.css$")
   (erlang-mode    "YAWS Dynamic Page"       "\\.yaws$")
   (fvwm-mode      "FVWM Configuration"      "\\.fvwm/config$")
   (gnuplot-mode   "Gnuplot"                 "\\.gp\\|.gpi$")
   (groovy-mode    "Groovy"                  "\\.groovy$")
   (haskell-mode   "Haskell"                 "\\.hs$")
   (lua-mode       "Lua"                     "\\.lua$")
   (php-mode       "PHP"                     "\\.php\\|\\.inc$")
   (python-mode    "Python"                  "\\.[jp]y$")
   (ruby-mode      "Ruby"                    "\\.rb$")
   (rnc-mode       "RelaxNG Compact Syntax"  "\\.rnc$")
   (rst-mode       "reStructuredText"        "\\.rst$")
   (smalltalk-mode "Smalltalk"               "\\.st$")
   (sml-mode       "Standard ML"             "\\.sml$")
   (markdown-mode  "Markdown"                "\\.text$")
   (wikipedia-mode "Wikipedia"               "\\.wiki$")
   (js2-mode       "JavaScript"              "\\.js$")
   (yaml-mode      "YAML"                    "\\.ya?ml$")
   ((logo-mode     "logo")    "Logo"         "\\.logo$")
   ((org-mode      "org")     "Org"          "\\.org$")
   ((prolog-mode   "prolog")  "Prolog"       "\\.pdb$")
   ((tuareg-mode   "tuareg")  "Caml"         "\\.mli?$")))

;; Completely replace perl-mode with cperl-mode.

;; (autoload 'cperl-mode "cperl-mode"
;;   (concat "Major mode for editing Perl source code."))

(require 'cl)

(let ((perl-elt (rassoc 'perl-mode auto-mode-alist)))
  (setq auto-mode-alist (remove perl-elt auto-mode-alist))
  (add-to-list 'auto-mode-alist `(,(car perl-elt) . cperl-mode)))

(setq interpreter-mode-alist
      (reverse
       (cl-reduce (lambda (acc elt)
		    (if (eq (cdr elt) 'perl-mode)
			(cons (cons (car elt) 'cperl-mode) acc)
		      (cons elt acc)))
		  interpreter-mode-alist
		  :initial-value nil)))

(add-to-list 'auto-mode-alist '("Makefile" . makefile-gmake-mode))
(add-to-list 'auto-mode-alist '("JSP"      . html-mode))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;;  Loading Required Elisp Packages
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(require 'autoinsert)                   ; insert text when opening new files
(require 'calendar)			; organize your life
(require 'compile)                      ; display the results of compiling a file
(require 'cperl-mode)			; a superior Perl mode
(require 'darcsum)                      ; finds the differences in Darcs repositories
;(require 'doxymacs)                    ; Doxygen integration
(require 'erc)				; the ERC chat client
(require 'erlang-start)			; support for Erlang
;(require 'ess-site)                    ; Emacs Speaks Statistics
(require 'faraday-mode)			; electricize arbitrary text
(require 'htmlize)			; convert a buffer into HTML
(require 'package)			; download / manage elisp packages
(require 'prolog)
(require 'psvn)				; enhanced Subversion interaction
;(require 'remember-planner)            ; I don't remember what this does! :)
(require 'rst)				; reStructuredText mode
;(require 'quack)                       ; superior mode for Scheme programming
;(require 'scala-mode-auto)             ; autoloads for programming in Scala
(require 'sml-autoloads)		; autoloads necessary SML mode functions
(require 'speedbar)			; file and tag browser
(require 'stamp)			; set timestamps in files

;; Enable the Marmalade online package repository.
(add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/"))

(if tcv-emms-enable  (load "~/.emacs_emms.el"))
(if tcv-mail-enable  (load "~/.emacs_mail.el"))
(if tcv-irc-enable (load "~/.emacs_irc.el"))

(load "~/elisp/haskell/haskell-site-file") ; load haskell stuff
(setq haskell-program-name "/opt/haskell/bin/ghci")
(setq inferior-R-program-name "/opt/r-lang/bin/R")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;  TRAMP
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(require 'tramp)

(setq tramp-verbose 2)
(add-to-list 'tramp-remote-path "~/bin")

(defvar tcv-tramp-auto-save-dir
  "~/.emacs.d/tramp.d/auto-save"
  "Location of a directory to use for TRAMP to put auto-save
files in. If it doesn't exist then it will be created. If nil,
then no special value will be sent on to TRAMP's configuration.")

(if tcv-tramp-auto-save-dir
    (progn
      (mkdir tcv-tramp-auto-save-dir t)
      (setq tramp-auto-save-directory tcv-tramp-auto-save-dir)))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;  AUCTeX
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(load "auctex.el" t t t)                 ; load AUCTeX
(load "preview-latex.el" t t t)          ; load preview-latex
(setq LaTeX-verbatim-environments '("verbatim" "verbatim*" "Verbatim"))
(setq LaTeX-command-style '(("" "%(PDF)%(latex) %S%(PDFout)")))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;  Perl Code
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(setq cperl-indent-level 4)
(setq cperl-close-paren-offset -4)
(setq cperl-highlight-variables-indiscriminately t)
(setq cperl-indent-parens-as-block t)

(add-hook
 'cperl-mode-hook
 (lambda ()
   (set-face-attribute
    'cperl-array-face nil
    :weight 'normal
    :background nil
    :foreground (face-attribute 'error :foreground))
   (set-face-attribute
    'cperl-hash-face nil
    :weight 'normal
    :background nil
    :foreground (face-attribute 'warning :foreground))))

;(require 'slime)                   ; autoloads a superior Lisp interaction mode
;(require 'swank-clojure)           ; to use Clojure from within SLIME

;(setenv "SBCL_HOME" "/opt/sbcl/lib/sbcl")
;(setq inferior-lisp-program "/opt/clisp/bin/clisp")
;(slime-setup '(slime-repl))

;; This is to use Clojure from within SLIME.

;(setq swank-clojure-jar-path "~/Libraries/Java/clojure.jar")
;(setq swank-clojure-extra-classpaths nil)
;(require 'swank-clojure-autoload)

(eval-after-load "htmlize"
  '(progn
     (defadvice htmlize-faces-in-buffer (after org-no-nil-faces activate)
       "Make sure there are no nil faces"
       (setq ad-return-value (delq nil ad-return-value)))))

;; Emacs Muse

;(require 'muse-mode)
;(require 'muse-html)
;(require 'muse-latex)
;(require 'muse-project)

;; Emacs Shell

(setq eshell-cmpl-dir-ignore "\\`\\(\\.\\(\\.\\|hg\\|svn\\|git\\)?\\|CVS\\)/\\'")

;(autoload 'imaxima "imaxima" "Image support for Maxima." t)

;; Set the action table for faraday electric mode.

(setq faraday-action-table
      '((sml-mode . (("type" . indent-according-to-mode)
                     ("val"  . indent-according-to-mode)))))

;; Variables specific to external packages

(setq erc-fill-column 100)
(setq erc-nick "metasyntax|work")

(setq erlang-root-dir "/usr/local/lib/erlang")
(setq js2-auto-indent-flag nil)

;(setq quack-global-menu-p nil)
;(setq quack-fontify-style 'emacs)
;(setq quack-default-program "gsi")

;(setq remember-handler-functions '(remember-planner-append))
;(setq remember-annotation-functions planner-annotation-functions)
;(setq rst-mode-lazy nil)            ; fix horribly slow font-locking in reStructuredText

(require 'pp-c-l)
(setq pp^L-^L-string-function
      (lambda (win)
        (let ((len (- (/ (window-width win) 2) 6)))
          (concat (make-string len ? )
                  "SECTION BREAK"
                  (make-string (if (evenp (window-width win)) (1- len) len) ? )))))
(setq pp^L-^L-string-pre "")
(setq pp^L-^L-string-post "")
(set-face-attribute 'pp^L-highlight nil :weight 'bold :foreground "white" :background "blue" :box nil)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;  PLANNER
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(setq muse-project-alist
      '(("Project"
         ("~/emacs-muse" :default "index")
         (:base "html" :path "~/public_html")
         (:base "pdf" :path "~/public_html/pdf"))))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;;  Fonts
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; Change an attribute for all faces that have it set to a specified value. For
;; example, I use this to change all faces that have :weight = 'bold so that
;; they have :weight = 'semibold (when using certain fonts).

(defun change-face-attrs (attr from to)
  (mapc #'(lambda (f)
	    (if (eq (face-attribute f attr) from)
		(set-face-attribute f nil attr to)))
	(face-list)))

(defvar tcv-lispm-fixed "-lispm-fixed-medium-r-normal--13-90-100-100-m-80-iso8859-15"
  "X font designator for the MIT CADR Lisp Machine type.")

(defvar tcv-dec-terminal "-dec-terminal-bold-r-normal--14-140-75-75-c-80-iso8859-1"
  "X font designator for the bolded DEC terminal type.")

(defvar tcv-swiss "-xos4-terminus-medium-r-normal--16-160-72-72-c-80-iso10646-1"
  "X font designator for my modified Terminus font.")

(defvar tcv-misc-fixed-large "-misc-fixed-medium-r-normal--13-120-75-75-c-70-iso10646-1"
  "Miscellaneous fixed Unicode font - larger version.")

(defvar tcv-misc-fixed-small "-misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso10646-1"
  "Miscellaneous fixed Unicode font - smaller version.")

(defvar tcv-font-droid
  '((:sans . "Droid Sans")
    (:serif . "Droid Serif")
    (:mono . "Droid Sans Mono")))

(defvar tcv-font-dejavu
  '((:sans . "DejaVu Sans")
    (:serif . "DejaVu Serif")
    (:mono . "DejaVu Sans Mono")))

(defvar tcv-font-liberation
  '((:sans . "Liberation Sans")
    (:serif . "Liberation Serif")
    (:mono . "Liberation Mono")))

(defvar tcv-font-inconsolata
  '((:sans . "DejaVu Sans")
    (:serif . "DejaVu Serif")
    (:mono . "Inconsolata")))

(defvar tcv-font-consolas
  '((:sans . "DejaVu Sans")
    (:serif . "DejaVu Serif")
    (:mono . "Consolas")))

(defvar tcv-font-mac
  '((:sans . "Helvetica")
    (:serif . "Times")
    (:mono . "Monaco")))

(defvar tcv-font-source
  '((:sans . "Source Sans Pro")
    (:serif . "DejaVu Serif")
    (:mono . "Source Code Pro")))

(defun make-xft-font (family variant size)
  (concat (cdr (assoc variant (eval (intern (concat "tcv-font-" family))))) "-" (int-to-string size)))

(defvar tcv-use-x-font-p (if (string= system-name "darwin") nil nil)
  "Use a regular X font (as opposed to Xft font) when true.")

(defvar tcv-x-font tcv-swiss
  "Which X font to use.")

(defvar tcv-xft-font
  (cond ((string= system-type "darwin") "mac")
	((string= system-type "cygwin") "dejavu")
	((string= system-type "windows-nt") "consolas")
	(t "source"))
  "Name of the default font set to use.")

(if (and (not tcv-use-x-font-p)
	 (string= tcv-xft-font "source"))
    (progn
      (change-face-attrs :weight 'bold 'semibold)
      (add-hook 'after-change-major-mode-hook
		(lambda () (change-face-attrs :weight 'bold 'semibold)))))

(defvar tcv-font-size
  (cond ((string-match "^thinkpad" system-name) 12)
        ((string-match "^zareason" system-name) 12)
        ((string-match "^system76" system-name) 13)
	((string-match "^zeus"     system-name) 11)
	((string= "cygwin" system-type) 10)
        ((string= "darwin" system-type) 13)
        (t 12))
  "Size of the default font size to use.")

(defvar tcv-every-mode '(ada-mode awk-mode c-mode c++-mode
  clojure-mode cperl-mode css-mode emacs-lisp-mode erlang-mode
  groovy-mode java-mode js2-mode haskell-mode html-mode lisp-mode
  perl-mode php-mode prolog-mode ruby-mode scala-mode scheme-mode
  sgml-mode sh-mode shell-script-mode sml-mode tcl-mode
  tuareg-mode xml-mode)
  "Every single mode.")

(defvar tcv-adjust-colors nil)

(setq default-frame-alist `((width . 81) (height . 41)
                            (font-backend . "xft, x")
                            ,(if tcv-use-x-font-p
                                 `(font . ,tcv-x-font)
			       `(font . ,(make-xft-font tcv-xft-font :mono tcv-font-size)))))
;(setq initial-frame-alist '((width . 120) (height . 40)))

(defvar tcv-browser 'firefox
  "Type of web browser to use.  Sets browser functions in Emacs
  appropriately. Currently supported: firefox, conkeror, opera.")

(cond
 ((eql tcv-browser 'firefox)
  (setq browse-url-new-window-flag t)
  (setq browse-url-firefox-new-window-is-tab t)
  (setq browse-url-browser-function 'browse-url-firefox))
 ((eql tcv-browser 'conkeror)
  (setq browse-url-new-window-flag nil)
  (setq browse-url-firefox-program "/opt/conkeror/xulrunner-stub")
  (setq browse-url-browser-function 'browse-url-firefox))
 ((eql tcv-browser 'opera)
  (setq browse-url-generic-program "opera")
  (setq browse-url-generic-args '("-newpage"))))
(setq c-basic-offset 4)                        ; set indentation to four spaces
(setq case-fold-search t)                      ; don't remember what this does
(setq column-number-mode t)                    ; show column numbers on the modeline
(setq comment-style 'extra-line)	       ; comment region using multi-line syntax
(setq default-input-method "TeX")              ; make TeX the alternate input method
(setq dired-recursive-deletes 'always)         ; don't ask to delete recursively
(setq display-time-format "%Y-%m-%d %H:%M")    ; use international format for time
(setq enable-remote-dir-locals t)	       ; search for remote .dir-locals.el files
(setq font-lock-maximum-decoration	       ; set per-mode fontification limits
      '((c-mode . 2)
	(t . t)))

(setq frame-title-format '((:eval (if (null (buffer-file-name))
                                      "%b"
                                    "%f"))))

(setq inhibit-startup-message t)               ; don't show the Emacs splash buffer
(setq make-backup-files nil)                   ; stop making those silly backup files
(setq mouse-wheel-follow-mouse t)              ; mouse wheel affects window over which mouse hovers
(setq mouse-wheel-progressive-speed nil)       ; don't accelerate the mouse wheel
(setq sentence-end-double-space nil)           ; sentences end with a single space
(setq require-final-newline t)                 ; automatically put newline at end of file
(setq scheme-program-name "csi")               ; Chicken Scheme Interpreter / crime scene investigation
(setq sql-sqlite-program "sqlite3")            ; modern version of sqlite program
(setq tcl-application "tclsh")                 ; Tcl program to run in inferior mode
(setq transient-mark-mode t)                   ; don't remember what this does
(setq truncate-partial-width-windows nil)      ; .... ?
(setq uniquify-buffer-name-style 'forward)     ; .... ?
(setq use-dialog-box nil)                      ; don't use the GUI for questions / file finding / etc.
(setq user-full-name "Taylor Venable")         ; full name, in case not set
(setq visible-bell t)                          ; flash the top and bottom lines instead of beeping
(setq vc-follow-symlinks t)                    ; don't ask to follow symlinks to VC files
(setq x-stretch-cursor t)                      ; stretch cursor to cover tabs

; (setq sgml-quick-keys t)                       ; make SGML tag characters behave electrically
; (setq mouse-wheel-progressive-speed t)         ; enable fast mouse scrolling

(setq safe-local-variable-values
      '((js2-additional-externs)))

(setq lazy-highlight-cleanup nil)               ; Don't automatically un-highlight isearch hits.
(setq-default buffer-file-coding-system 'utf-8-unix)
(setq-default bidi-display-reordering nil)     ; turn off all bidi stuff
(setq-default fill-column 80)                  ; fill up to column 80
(setq-default indent-tabs-mode nil)            ; never use tabs - only spaces
(setq-default indicate-empty-lines t)          ; show empty lines in the fringe

; (setq-default show-trailing-whitespace t)    ; highlight trailing whitespace
(delete-selection-mode t)              ; delete text in marked region
(global-auto-revert-mode 1)            ; enable auto-revert-mode globally
(global-font-lock-mode t)              ; enable syntax highlighting
(mouse-wheel-mode t)                   ; allow scrolling with mouse wheel
(set-language-environment "UTF-8")     ; use UTF-8 for default input
(set-scroll-bar-mode 'right)           ; show scrollbar on the right
(show-paren-mode t)                    ; highlight matching parentheses
(tool-bar-mode -1)                     ; turn off quick tool bar
(display-time-mode)                    ; show time in the modeline

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;  Indentation
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(setq c-tab-always-indent t)
(setq cperl-tab-always-indent t)
(setq tab-always-indent t)
(setq js2-auto-indent-p t)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;  Grep and Ack
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(grep-compute-defaults)

(setq grep-command "grep -rnHE --exclude-dir='.svn' --exclude='*/TAGS'")

(defalias 'ack 'ack-and-a-half)
(defalias 'ack-same 'ack-and-a-half-same)
(defalias 'ack-find-file 'ack-and-a-half-find-file)
(defalias 'ack-find-file-same 'ack-and-a-half-find-file-same)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;;  Fonts
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defun tcv-adjust-font ()
  (if tcv-use-x-font-p
      (progn
        (set-face-attribute 'default            nil :font tcv-x-font)
        (set-face-attribute 'tooltip            nil :font tcv-x-font)
        (set-face-attribute 'mode-line-inactive nil :font tcv-x-font))
      (progn
        (set-face-attribute 'default                nil :font (make-xft-font tcv-xft-font :mono tcv-font-size))
        (set-face-attribute 'fixed-pitch            nil :font (make-xft-font tcv-xft-font :mono tcv-font-size))
        (set-face-attribute 'variable-pitch         nil :font (make-xft-font tcv-xft-font :sans tcv-font-size))
        (set-face-attribute 'tooltip                nil :weight 'medium)
        (set-face-attribute 'font-lock-doc-face     nil :slant 'italic))))

(if (and (display-graphic-p)
         (not (boundp 'aquamacs-version)))
    (tcv-adjust-font))

(if tcv-adjust-colors
  (progn
    (set-face-attribute 'cursor                 nil :background "Gray50")
    (set-face-attribute 'font-lock-comment-face nil :foreground "Firebrick")
    (set-face-attribute 'font-lock-doc-face     nil :foreground "Firebrick")
    (set-face-attribute 'font-lock-string-face  nil :foreground "RoyalBlue")
    (set-face-attribute 'highlight              nil :background "LightSteelBlue")
    (set-face-attribute 'region                 nil :background "LemonChiffon2")
    (set-face-attribute 'show-paren-match       nil :background "SkyBlue3" :foreground "White")
    (set-face-attribute 'show-paren-mismatch    nil :background "IndianRed3" :foreground "White")))

;; (set-face-attribute 'mode-line              nil :background "gray75" :box nil)
;; (set-face-attribute 'mode-line-highlight    nil :box nil :foreground "Firebrick")
;; (set-face-attribute 'mode-line-inactive     nil :background "grey90" :box nil)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;  Diff Colors (Not Needed Anymore)
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(require 'diff-mode)

;; (if tcv-adjust-colors
;;   (progn
;;     (set-face-attribute 'diff-removed           nil :background "RosyBrown1")
;;     (set-face-attribute 'diff-added             nil :background "PaleGreen1")))

(setq-default diff-switches "-u")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;  Special Words
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(make-face 'tcv-warning)
(make-face 'tcv-error)

(set-face-attribute 'tcv-warning nil
  :inherit 'warning
  :inverse-video t)

(set-face-attribute 'tcv-error nil
  :inherit 'error
  :inverse-video t)

(let ((error-pattern "\\<\\(FIXME\\|ERROR\\):")
      (warning-pattern "\\<\\(TODO\\|NOTE\\|WARNING\\|NOTREACHED\\):"))
  (mapc
   (lambda (mode)
     (font-lock-add-keywords mode `((,error-pattern 1 'tcv-error prepend)))
     (font-lock-add-keywords mode `((,warning-pattern 1 'tcv-warning prepend))))
   tcv-every-mode))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;;  Global Keys
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(global-set-key (kbd "C-c m") 'blink-matching-open)
(global-set-key (kbd "C-,") 'hs-toggle-hiding)



;; The important distinction here is that these delete instead of killing. I
;; originally implemented this because XFCE's clipboard manager had some problem
;; and Emacs would slow up when using C-<Backspace> to eat a whole paragraph.

(defun delete-word (arg)
  "Delete characters forward until encountering the end of a word.
With argument ARG, do this that many times."
  (interactive "p")
  (delete-region (point) (progn (forward-word arg) (point))))

(defun backward-delete-word (arg)
  "Delete characters backward until encountering the beginning of a word.
With argument ARG, do this that many times."
  (interactive "p")
  (delete-word (- arg)))

(global-set-key (kbd "C-<backspace>") 'backward-delete-word)
(global-set-key (kbd "M-DEL") 'backward-delete-word)
(global-set-key (kbd "C-<delete>") 'delete-word)
(global-set-key (kbd "M-d") 'delete-word)



(cond ((string= system-type "darwin")
       (progn
         (global-set-key (kbd "<s-down>") #'end-of-buffer)
         (global-set-key (kbd "<s-up>") #'beginning-of-buffer)
         (global-set-key (kbd "<M-kp-delete>") #'backward-kill-word)
         (global-set-key (kbd "<kp-delete>") #'delete-char)
         (global-set-key (kbd "<M-kp-delete>") #'kill-word)
         (global-set-key (kbd "<s-left>") #'beginning-of-line)
         (global-set-key (kbd "<s-right>") #'end-of-line)
         (global-set-key (kbd "<home>") #'beginning-of-line)
         (global-set-key (kbd "<end>") #'end-of-line)
         (global-set-key (kbd "<s-s>") #'save-buffer)
         (global-set-key (kbd "<s-q>") #'save-buffers-kill-terminal)
         (global-set-key (kbd "<s-w>") #'kill-buffer))))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;  EMMS Keys
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(global-set-key (kbd "<f1>") 'emms-previous)
(global-set-key (kbd "<f2>") 'emms-start)
(global-set-key (kbd "<f3>") 'emms-stop)
(global-set-key (kbd "<f4>") 'emms-next)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;  CMUS Functions & Keys
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defun cmus-prev ()
  (interactive)
  (call-process "cmus-remote" nil nil nil "--prev")
  (cmus-status*))

(defun cmus-next ()
  (interactive)
  (call-process "cmus-remote" nil nil nil "--next")
  (cmus-status*))

(defun cmus-stop ()
  (interactive)
  (call-process "cmus-remote" nil nil nil "--stop")
  (message "Stopped"))

(defun cmus-play ()
  (interactive)
  (call-process "cmus-remote" nil nil nil "--play")
  (cmus-status*))

(defun cmus-vol-down ()
  (interactive)
  (call-process "cmus-remote" nil nil nil "--volume" "-5%"))

(defun cmus-vol-up ()
  (interactive)
  (call-process "cmus-remote" nil nil nil "--volume" "+5%"))

(defun cmus-status* ()
  (if (not (string-match "^setting: 'status_display_program=[[:print:]]+'$"
			 (car (process-lines "cmus-remote" "-C" "set status_display_program"))))
      (cmus-status)))

(defmacro cmus-status-field (field lines)
  `((lambda (s)
      (if s (substring s (+ (length ,field) 1)) nil))
    (cl-find-if (lambda (s) (string-prefix-p ,field s)) ,lines)))

(defun cmus-status ()
  (interactive)
  (let* ((lines (process-lines "cmus-remote" "-Q"))
	 (artist (cmus-status-field "tag artist" lines))
	 (album (cmus-status-field "tag album" lines))
	 (title (cmus-status-field "tag title" lines))
	 (year (cmus-status-field "tag date" lines))
	 (track-num (cmus-status-field "tag tracknumber" lines)))
    (message "%s: %s (%s) - [%s] %s" artist album year track-num title)
    (run-at-time 5 nil 'message nil)))

(global-set-key (kbd "<f9>") 'cmus-prev)
(global-set-key (kbd "<f10>") 'cmus-stop)
(global-set-key (kbd "<f11>") 'cmus-play)
(global-set-key (kbd "<f12>") 'cmus-next)
(global-set-key (kbd "C-<f9>") 'cmus-vol-down)
(global-set-key (kbd "C-<f12>") 'cmus-vol-up)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Various Functions
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defun insert-date-rfc822 ()
  "Insert the current time in the format used by RFC-822."
  (interactive)
  (insert (format-time-string "%a, %d %b %Y %H:%M:%S %Z")))

(defun tcv-decode-hex ()
  "Turn a series of hex characters (like in APDU logs) into ASCII."
  (interactive)
  (if (not (region-active-p))
      (error "You must select a region")
    (progn
      (if (< (mark) (point))
          (exchange-point-and-mark))
      (insert " ASCII: ")
      (while (re-search-forward " \\([0-9A-F]\\{2\\}\\)" (mark) t)
        (let ((code-as-decimal (string-to-number (match-string 1) 16)))
          (if (and (> code-as-decimal 31) (< code-as-decimal 127))
              (replace-match (format "%c" (make-char 'ascii code-as-decimal)) nil nil)))))))

(defun longest-line-length nil
  (let ((longest-line 0)
        (line 0)
        (length 0))
    (save-excursion
      (goto-char (point-min))
      (end-of-line)
      (setq length (current-column))
      (while (zerop (forward-line 1))
        (setq line (1+ line))
        (end-of-line)
        (cond ((> (current-column) length)
               (setq length (current-column))
               (setq longest-line line)))))
    length))

(defun protected-require (name)
  (condition-case err
      (progn
        (if (stringp name)
            (load-library name)
          (require name)))
    (file-error nil)))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;  New File Templates
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defvar tcv-templates-dir "~/Templates")

(setq auto-insert-query nil)                  ; don't ask to insert -- just do it
(setq latex-do-class-assignment-insert nil)   ; avoid screwing up AUCTeX

;; Prompt for and expand CLASS and ASSIGNMENT in the LaTeX template.

(defun latex-insert-class-assignment nil
  (if latex-do-class-assignment-insert
      (let ((class      (read-from-minibuffer "Class: "))
            (assignment (read-from-minibuffer "Assignment: ")))
        (progn
          (while (search-forward "CLASS" nil t)
            (replace-match class t t))
          (while (search-forward "ASSIGNMENT" nil t)
            (replace-match assignment t t))
          (setq latex-do-class-assignment-insert nil)))
    nil))

;; Returns a list associating filename regexes to the template file.
;; For LaTeX, also add the CLASS and ASSIGNMENT expansion function.

(defun template-list (insert-directory)
  (let (lst)
    (dolist (elt (directory-files insert-directory nil "[^\\.]" nil) lst)
      (if (string-equal elt "tex")
          (setq lst (append lst `((,(concat "\\." elt "$") . [,elt latex-insert-class-assignment]))))
        (setq lst (append lst `((,(concat "\\." elt "$") . ,elt))))))))

;; Only enable auto-insert mode if the templates directory exists.

(if (and (file-exists-p tcv-templates-dir)
         (let ((attrs (file-attributes tcv-templates-dir)))
	   (or (eq (car attrs) t)
	       (and (stringp (car attrs))
		    (let ((target (concat (file-name-directory (expand-file-name tcv-templates-dir))
					  (car attrs))))
		      (eq (car (file-attributes target)) t))))))
    (progn
      (setq auto-insert-directory tcv-templates-dir)
      (setq auto-insert-alist (template-list auto-insert-directory))
      (auto-insert-mode))
  (warn "Invalid templates directory: %s" tcv-templates-dir))

;; This makes it so we only do the class & assignment stuff when creating
;; a new file.  If we enable it all the time, AUCTeX gets messed up.

(add-hook 'find-file-not-found-functions
          (lambda nil
            (if (string-equal (file-name-extension buffer-file-name) "tex")
                (setq latex-do-class-assignment-insert t)
              nil)))

(add-hook 'after-save-hook
          (lambda nil
            (and (save-excursion
                   (save-restriction
                     (widen)
                     (goto-char (point-min))
                     (save-match-data
                       (looking-at "^#!"))))
                 (not (file-executable-p buffer-file-name))
                 (shell-command (concat "chmod +x " (shell-quote-argument buffer-file-name)))
                 (message
                  (concat "Saved as executable script: " buffer-file-name)))))
(defun work-code-conventions ()
  "Configure Emacs variables to support work coding conventions.
Intended to be used as a hook for finding a file."
  (if (string-match "Work/" buffer-file-name)
      (progn
        (set-variable 'indent-tabs-mode nil)
        (set-variable 'tab-width 4))))

(add-hook 'find-file-hook 'work-code-conventions)
(add-hook 'before-save-hook 'delete-trailing-whitespace)

; I just figured out how input methods work and they're too damn useful.
; (global-set-key (kbd "C-\\") #'hs-toggle-hiding)

(require 'cl)
(defun path-split (path)
  (split-string path "/" t))
(defun path-parent (path)
  (let ((components (path-split path)))
    (if (= (length components) 1) "/"
      (concat "/" (reduce #'(lambda (old new)
                              (concat old "/" new))
                          (reverse (cdr (reverse components))))))))
(defun tcv-find-changes-file (path)
  (let ((try (concat (file-name-directory path) "CHANGES")))
    (if (file-exists-p try)
        try
      (if (string= (path-parent try) "/")
          nil
        (tcv-find-changes-file (path-parent try))))))
(setq-default add-log-full-name "Taylor Venable")
(setq-default add-log-mailing-address "taylor.venable@trustbearer.com")

(defun tcv-add-changes ()
  (interactive)
  (let ((changes-file (or (tcv-find-changes-file (buffer-file-name)) "CHANGES")))
    (add-change-log-entry nil changes-file nil t t)))
(setq ps-mark-code-directory nil)   ; don't know what this does, but it's necessary
(setq ps-font-size '(10 . 10))      ; make the font actually legible
(setq ps-current-bg nil)            ; set the background color of the output
(setq ps-print-color-p nil)         ; print only black (for mono laser printer)

(setq ps-right-header
      (list "/pagenumberstring load"
            'ps-time-stamp-yyyy-mm-dd
            'ps-time-stamp-hh:mm:ss))

(defun a2ps-print nil
  (interactive)
  (shell-command (concat "a2ps "
                         "--medium=Letter "
                         (if (> (longest-line-length) 95) "--landscape " "--portrait ")
                         "--columns=1 "
                         "--line-numbers=1 "
                         "--header='' "
                         "--left-title="
                         (shell-quote-argument
                          (format-time-string
                           "%Y-%m-%d %H:%M:%S"
                           (nth 5 (file-attributes buffer-file-name))))
                         " "
                         "--left-footer='' "
                         "--footer=" (shell-quote-argument buffer-file-name) " "
                         "--right-footer='' "
                         "--font-size=9 "
                         "--tabsize=2 "
                         "--pretty-print "
                         "--highlight-level=heavy "
                         "--sides=duplex "
                         (shell-quote-argument buffer-file-name))))
(mapcar
 (lambda (mode)
   (let ((mode-hook (intern (concat (symbol-name mode) "-hook"))))
     (add-hook mode-hook (lambda nil (local-set-key (kbd "RET") 'newline-and-indent)))))
 (cl-remove-if (lambda (x) (eq x 'haskell-mode))
	       tcv-every-mode))
(mapcar
 (lambda (mode-hook-list)
   (add-hook (car mode-hook-list) `(lambda nil (setq ,(cadr mode-hook-list) 4))))
 '((ada-mode-hook     ada-indent)
   (fortran-mode-hook fortran-do-indent)
   (fortran-mode-hook fortran-if-indent)
   (fortran-mode-hook fortran-structure-indent)
   (prolog-mode-hook  prolog-indent-width)
   (ruby-mode-hook    ruby-indent-level)))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;  Doxygen Font Locking
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(require 'cc-mode)

(defconst doxygen-font-lock-keywords
  `((,(lambda (limit)
	(c-font-lock-doc-comments "/\\*\\*$" limit
	  gtkdoc-font-lock-doc-comments)
	(c-font-lock-doc-comments "/// " limit
	  gtkdoc-font-lock-doc-comments)
	(c-font-lock-doc-comments "/\\(\\*\\*\\|//\\)< " limit
	  gtkdoc-font-lock-doc-comments)
	))))

;; (add-hook 'c-mode-hook
;;   (lambda ()
;;     (setq c-doc-comment-start-regexp "/\\(//\\|\\*[*!]\\)")))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;  ANY CC-MODE
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; http://www.gnu.org/software/emacs/manual/html_node/ccmode/c_002doffsets_002dalist.html
;; http://www.gnu.org/software/emacs/manual/html_node/ccmode/Syntactic-Symbols.html
;; http://www.gnu.org/software/emacs/manual/html_node/ccmode/Line_002dUp-Functions.html

(c-add-style "tcv" `("gnu"
		     (c-basic-offset . 4)
		     (c-backslash-column . 80)
		     (c-backslash-max-column . 100)
		     (c-cleanup-list comment-close-slash)
		     ;; (c-doc-comment-style . 'doxygen)
		     (c-label-minimum-indentation . 0)
		     (c-offsets-alist
		      ; Don't indent "{" by itself.
		      (substatement-open . 0)

		      ;; ,----[ Example ]
		      ;; | const char *str = "concatenated"
		      ;; |                   "string";
		      ;; `----

		      (statement-cont c-lineup-string-cont (c-lineup-assignments +))

		      ;; ,----[ Example ]
		      ;; | function(arg1, "concatenated"
		      ;; |                "string",
		      ;; |          arg2);
		      ;; `----

		      (arglist-cont-nonempty
		       c-lineup-string-cont
		       ,@(cdr (assoc 'arglist-cont-nonempty (get 'c-offsets-alist 'c-stylevar-fallback))))
		      )
		     ))

(setq c-default-style '((awk-mode . "awk")
			(java-mode . "java")
			(other . "tcv")))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;  C MODE
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defun tcv-insert-triple-slash ()
  (interactive)
  (insert "/// "))

(add-hook 'c-mode-hook
          (lambda nil
	    (progn
	      (subword-mode)
	      (local-set-key (kbd "C-c /")         'tcv-insert-triple-slash)
	      (local-set-key (kbd "C-<left>")      'subword-backward)
	      (local-set-key (kbd "C-<right>")     'subword-forward)
	      (local-set-key (kbd "C-<backspace>") 'subword-backward-kill)
	      (local-set-key (kbd "C-<delete>")    'subword-kill))))

(add-hook 'emacs-lisp-mode-hook
          (lambda nil
            (progn
              (setq indent-tabs-mode t))))
(require 'java-mode-indent-annotations)

(add-hook 'java-mode-hook
          (lambda nil
            (progn
              (java-mode-indent-annotations-setup)
              (subword-mode)
	      (local-set-key (kbd "C-<left>")      'subword-backward)
	      (local-set-key (kbd "C-<right>")     'subword-forward)
	      (local-set-key (kbd "C-<backspace>") 'subword-backward-kill)
	      (local-set-key (kbd "C-<delete>")    'subword-kill))))

(add-hook 'haskell-mode-hook 'turn-on-haskell-indent)
(add-hook 'html-mode-hook
          (lambda nil
            (progn
              (set-variable 'stamp-prefix "<div id=\"updated\">" t)
              (set-variable 'stamp-suffix "</div>" t))))
(add-hook 'latex-mode-hook
  (lambda nil
    (progn
      (auto-fill-mode 1)
      (set-variable 'compile-command "pdflatex" t))))
(add-hook 'python-mode-hook
  (lambda nil
    (progn
      (imenu--menubar-select imenu--rescan-item)
      (set-face-attribute 'py-builtins-face nil       :foreground "DarkOrange2")
      (set-face-attribute 'py-pseudo-keyword-face nil :foreground "DarkOrange2")
      (setq python-honour-comment-indentation t))))
(add-hook 'ruby-mode-hook
          (lambda nil
            (progn
              (imenu-add-to-menubar "Imenu")
              (imenu--menubar-select imenu--rescan-item))))
(add-hook 'scala-mode-hook
          (lambda nil
            (progn
              (subword-mode))))
(define-key global-map "\C-cl" 'org-store-link)
(define-key global-map "\C-ca" 'org-agenda)
(setq org-log-done t)

(setq org-export-with-priority t)
(setq org-export-html-style-include-default nil)
(setq org-export-html-coding-system 'utf-8)
(setq org-export-html-style "<link rel='stylesheet' type='text/css' href='org-mode.css'/>")
(setq org-export-html-preamble nil)

(setq org-highest-priority ?1)
(setq org-default-priority ?3)
(setq org-lowest-priority  ?5)

(add-hook 'org-mode-hook
  (lambda ()
    (visual-line-mode)))

; (setq org-export-html-style "<link rel='stylesheet' type='text/css' href='http://metasyntax.net/unifraktur/style.css'/>\n<link rel='stylesheet' type='text/css' href='org-mode.css'/>")
; (setq org-export-html-postamble "<p class='tagline'>by <span style='vertical-align: middle' id='name'>Taylor Chriſtopher Venable</span> (λx.xx)(λx.xx)</p>")
(add-hook 'server-switch-hook
          (lambda nil
            (let ((server-buf (current-buffer)))
              (bury-buffer)
              (switch-to-buffer-other-frame server-buf))))

(add-hook 'server-done-hook 'delete-frame)   ; delete frame when client done
(server-start)                               ; enable Emacs server

(put 'upcase-region 'disabled nil)
(put 'downcase-region 'disabled nil)

(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.
 '(compilation-scroll-output (quote first-error))
 '(cperl-indent-region-fix-constructs nil)
 '(custom-safe-themes (quote ("628278136f88aa1a151bb2d6c8a86bf2b7631fbea5f0f76cba2a0079cd910f7d" default)))
 '(find-file-suppress-same-file-warnings t)
 '(replace-lax-whitespace t)
 '(safe-local-variable-values (quote ((ack-and-a-half-executable . "~/perl5/perlbrew/perls/perl-5.16.1/bin/ack")))))
(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.
 '(which-func ((t (:inherit modeline-buffer-id :weight normal)))))

(defun tcv-insert-tab ()
  (interactive)
  (insert-tab))

(global-set-key (kbd "M-i") 'tcv-insert-tab)

;; Local Variables:
;; mode: emacs-lisp
;; End:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.