]> git.donarmstrong.com Git - lib.git/blob - emacs_el/configuration/don-configuration.org
54230bfc15ee5e93b0d2918eb5ed69e16884dc91
[lib.git] / emacs_el / configuration / don-configuration.org
1 * Load debugger
2
3 # if for some reason, things get pear-shaped, we want to be able to
4 # enter the debugger by sending -USR2 to emacs
5
6 #+BEGIN_SRC emacs-lisp :tangle don-configuration.el
7 (setq debug-on-event 'siguser2)
8 #+END_SRC
9 * Add library paths
10
11 #+BEGIN_SRC emacs-lisp  :tangle don-configuration.el
12   (add-to-list 'load-path '"~/lib/emacs_el/")
13   (add-to-list 'load-path '"~/lib/emacs_el/helm")
14   (add-to-list 'load-path '"~/lib/emacs_el/tiny-tools/lisp/tiny")
15   (add-to-list 'load-path '"~/lib/emacs_el/tiny-tools/lisp/other")
16   (add-to-list 'load-path '"~/lib/emacs_el/auctex/lisp")
17   (add-to-list 'load-path '"~/lib/emacs_el/auctex")
18   (add-to-list 'load-path '"~/lib/emacs_el/ESS/lisp")
19   (add-to-list 'load-path '"~/lib/emacs_el/org-mode/lisp")
20   (add-to-list 'load-path '"~/lib/emacs_el/auctex-beamer")
21   (add-to-list 'load-path '"~/lib/emacs_el/magit-annex")
22   (add-to-list 'load-path '"~/lib/emacs_el/polymode")
23 #+END_SRC
24
25
26 * Misc functions
27 ** with-library
28 #+BEGIN_SRC emacs-lisp  :tangle don-configuration.el
29 ;; From http://www.emacswiki.org/emacs/LoadingLispFiles
30 ;; execute conditional code when loading libraries
31 (defmacro with-library (symbol &rest body)
32   `(when (require ,symbol nil t)
33      ,@body))
34 (put 'with-library 'lisp-indent-function 1)
35 #+END_SRC
36
37
38
39 * Modules
40 ** Tinyprocmail
41
42 #+BEGIN_SRC emacs-lisp  :tangle don-configuration.el
43   ;; load tinyprocmail
44   (with-library 'tinyprocmail
45     ; (setq tinyprocmail--procmail-version "v3.22")
46     (add-hook 'tinyprocmail--load-hook 'tinyprocmail-install))
47 #+END_SRC
48
49 ** Magit
50 #+BEGIN_SRC emacs-lisp :tangle don-configuration.el
51   ; don't verify where we are pushing
52   (setq magit-push-always-verify nil)
53 #+END_SRC
54
55 ** Perl
56 #+BEGIN_SRC emacs-lisp  :tangle don-configuration.el
57   (require 'cperl-mode)
58   ;; Use c-mode for perl .xs files
59   (add-to-list 'auto-mode-alist '("\\.xs\\'" . c-mode))
60   (add-to-list 'auto-mode-alist '("\\.\\([pP][Llm]\\|al\\)\\'" . cperl-mode))
61   (add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))
62   (add-to-list 'interpreter-mode-alist '("perl5" . cperl-mode))
63   (add-to-list 'interpreter-mode-alist '("miniperl" . cperl-mode))
64   (setq cperl-hairy t
65         cperl-indent-level 4
66         cperl-auto-newline nil
67         cperl-auto-newline-after-colon nil
68         cperl-continued-statement-offset 4
69         cperl-brace-offset -1
70         cperl-continued-brace-offset 0
71         cperl-label-offset -4
72         cperl-highlight-variables-indiscriminately t
73         cperl-electric-lbrace-space nil
74         cperl-indent-parens-as-block nil
75         cperl-close-paren-offset -1
76         cperl-tab-always-indent t)
77   ;(add-hook 'cperl-mode-hook (lambda () (cperl-set-style "PerlStyle")))
78 #+END_SRC
79
80 ** Helm
81 #+BEGIN_SRC emacs-lisp  :tangle don-configuration.el
82 (require 'don-helm)
83 #+END_SRC
84 ** Hydra
85 #+BEGIN_SRC emacs-lisp :tangle don-configuration.el
86 (require 'don-hydra)
87 #+END_SRC
88
89 ** Tramp
90 #+BEGIN_SRC emacs-lisp  :tangle don-configuration.el
91   (add-to-list 'tramp-methods '("vcsh"
92                                 (tramp-login-program "vcsh")
93                                 (tramp-login-args
94                                  (("enter")
95                                   ("%h")))
96                                 (tramp-remote-shell "/bin/sh")
97                                 (tramp-remote-shell-args
98                                  ("-c"))))
99 #+END_SRC
100 ** LaTeX
101 #+BEGIN_SRC emacs-lisp  :tangle don-configuration.el
102   (load "auctex.el" nil t t)
103   (load "preview-latex.el" nil t t)
104   (load "latex.el" nil t t)
105
106   ;; this is in the very newest auctex; avoid for now
107   (add-to-list 'LaTeX-fill-excluded-macros
108                '("Sexpr"))
109   ;; REFTEX (much enhanced management of cross-ref, labels, etc)
110   ;; http://www.strw.leidenuniv.nl/~dominik/Tools/reftex/
111   (autoload 'reftex-mode     "reftex" "RefTeX Minor Mode" t)
112   (autoload 'turn-on-reftex  "reftex" "RefTeX Minor Mode" nil)
113   (autoload 'reftex-citation "reftex-cite" "Make citation" nil)
114   (autoload 'reftex-index-phrase-mode "reftex-index" "Phrase mode" t)
115   (add-hook 'LaTeX-mode-hook 'turn-on-reftex)   ; with AUCTeX LaTeX mode
116   (add-hook 'latex-mode-hook 'turn-on-reftex)   ; with Emacs latex mode
117   (add-hook 'LaTeX-mode-hook 'outline-minor-mode)   ; with AUCTeX LaTeX mode
118   (add-hook 'latex-mode-hook 'outline-minor-mode)   ; with Emacs latex mode
119
120   ; use smart quotes by default instead of `` and ''
121   ; taken from http://kieranhealy.org/esk/kjhealy.html
122   (setq TeX-open-quote "“")
123   (setq TeX-close-quote "”")
124
125   ;; (TeX-add-style-hook
126   ;;  "latex"
127   ;;  (lambda ()
128   ;;    (TeX-add-symbols
129   ;;     '("DLA" 1))))
130   ;; (custom-set-variables
131   ;;  '(font-latex-user-keyword-classes 
132   ;;    '(("fixme" 
133   ;;       ("DLA" "RZ")
134   ;;       font-lock-function-name-face 2 (command 1 t))))
135   ;; ) 
136
137   (require 'font-latex)
138   (setq font-latex-match-reference-keywords
139         '(
140           ("fref" "{")
141           ("Fref" "{")
142           ("citep" "{")
143           ("citet" "{")
144           ("acs" "{")
145           ("acsp" "{")
146           ("ac" "{")
147           ("acp" "{")
148           ("acl" "{")
149           ("aclp" "{")
150           ("acsu" "{")
151           ("aclu" "{")
152           ("acused" "{")
153   ;         ))
154   ; (setq font-latex-match-warning-keywords
155   ;       '(
156           ("DLA" "{")
157           ("RZ" "{")
158           ("OM" "{")
159           ("DL" "{")
160           ("fixme" "{")))
161       
162   (setq-default TeX-parse-self t)
163   (setq-default TeX-auto-save t)
164   (setq-default TeX-master nil)
165   (eval-after-load
166       "latex"
167     '(TeX-add-style-hook
168       "cleveref"
169       (lambda ()
170         (if (boundp 'reftex-ref-style-alist)
171         (add-to-list
172          'reftex-ref-style-alist
173          '("Cleveref" "cleveref"
174            (("\\cref" ?c) ("\\Cref" ?C) ("\\cpageref" ?d) ("\\Cpageref" ?D)))))
175         (reftex-ref-style-activate "Cleveref")
176         (TeX-add-symbols
177          '("cref" TeX-arg-ref)
178          '("Cref" TeX-arg-ref)
179          '("cpageref" TeX-arg-ref)
180          '("Cpageref" TeX-arg-ref)))))
181   ;; this doesn't seem to work; not currently sure why
182   ; (setq font-latex-user-keyword-classes
183   ;       '(("my-warning-commands"
184   ;          (("DLA" "{")
185   ;           ("RZ" "{")
186   ;           ("OM" "{")
187   ;           ("DL" "{")
188   ;           ("fixme" "{")
189   ;           )
190   ;          (:foreground "red" :weight bold :underline (:color foreground-color :style line)))
191   ;         ))
192
193   (setq-default reftex-default-bibliography
194         '("~/projects/research/references.bib"))
195
196
197 #+END_SRC
198 ** Org
199 #+BEGIN_SRC emacs-lisp  :tangle don-configuration.el
200   (require 'org-mode-configuration)
201 #+END_SRC
202 ** ESS
203 #+BEGIN_SRC emacs-lisp  :tangle don-configuration.el
204   (require 'ess_configuration)
205 #+END_SRC
206
207
208 ** Polymode
209 #+BEGIN_SRC emacs-lisp  :tangle don-configuration.el
210   (setq load-path
211         (append '("~/lib/emacs_el/polymode/modes")
212                 load-path))
213   (require 'polymode)
214   (require 'poly-R)
215   (require 'poly-noweb)
216   (require 'poly-markdown)
217   (add-to-list 'auto-mode-alist '("\\.Snw" . poly-noweb+r-mode))
218   (add-to-list 'auto-mode-alist '("\\.Rnw" . poly-noweb+r-mode))
219   (add-to-list 'auto-mode-alist '("\\.Rmd" . poly-markdown+r-mode))
220 #+END_SRC
221
222 * Keybindings
223 ** Override other things
224 #+BEGIN_SRC emacs-lisp  :tangle don-configuration.el
225   ; apparently things like to step on C-;, so we'll use a hack from
226   ; http://stackoverflow.com/questions/683425/globally-override-key-binding-in-emacs/5340797#5340797 to fix this
227
228   (defvar my-keys-minor-mode-map (make-keymap) "my-keys-minor-mode keymap.")
229
230   ; use iedit everywhere
231   (define-key my-keys-minor-mode-map (kbd "C-;") 'iedit-mode)
232   ;; use outline mode keybindings everywhere
233   (define-key my-keys-minor-mode-map (kbd "C-;") 'my/mydra-outline/body)
234
235   (define-minor-mode my-keys-minor-mode
236     "A minor mode so that my key settings override annoying major modes."
237     t " my-keys" 'my-keys-minor-mode-map)
238
239   (my-keys-minor-mode 1)
240   (defun my-minibuffer-setup-hook ()
241     (my-keys-minor-mode 0))
242
243   (add-hook 'minibuffer-setup-hook 'my-minibuffer-setup-hook)
244   (defadvice load (after give-my-keybindings-priority)
245     "Try to ensure that my keybindings always have priority."
246     (if (not (eq (car (car minor-mode-map-alist)) 'my-keys-minor-mode))
247         (let ((mykeys (assq 'my-keys-minor-mode minor-mode-map-alist)))
248           (assq-delete-all 'my-keys-minor-mode minor-mode-map-alist)
249           (add-to-list 'minor-mode-map-alist mykeys))))
250   (ad-activate 'load)
251 #+END_SRC
252
253 * Misc (uncharacterized)
254 #+BEGIN_SRC emacs-lisp  :tangle don-configuration.el
255   (setq bibtex-user-optional-fields (quote (("annote" "Personal annotation (ignored)") ("abstract" "") ("pmid" "") ("doi" ""))))
256   (setq calendar-latitude 40.11)
257   (setq calendar-longitude -88.24)
258   (setq case-fold-search t)
259   (setq confirm-kill-emacs (quote y-or-n-p))
260   (setq cperl-lazy-help-time nil)
261   (setq debian-changelog-mailing-address "don@debian.org")
262   (display-time)
263   (setq display-time-24hr-format t)
264   (setq display-time-day-and-date t)
265   (display-time-mode 1)
266   (setq font-latex-fontify-script nil)
267   (setq font-latex-fontify-sectioning (quote color))
268   (setq font-latex-script-display (quote (nil)))
269   (global-auto-revert-mode 1)
270   (global-font-lock-mode 1)
271   (icomplete-mode 1)
272   (setq log-edit-keep-buffer t)
273   (setq mail-user-agent (quote sendmail-user-agent))
274   (setq markdown-enable-math t)
275   (setq markdown-follow-wiki-link-on-enter nil)
276   (setq mutt-alias-file-list (quote ("~/.mutt/aliases" "~/.mail_aliases")))
277   (setq post-email-address "don@donarmstrong.com")
278   (setq post-kill-quoted-sig nil)
279   (setq post-mail-message "mutt\\(ng\\|\\)-[a-z0-9]+-[0-9]+-.*")
280   (setq post-uses-fill-mode nil)
281   (setq ps-footer-font-size (quote (8 . 10)))
282   (setq ps-header-font-size (quote (8 . 10)))
283   (setq ps-header-title-font-size (quote (10 . 10)))
284   (setq ps-line-number-color "blue")
285   (setq ps-print-footer t)
286   (setq ps-print-footer-frame nil)
287   (setq ps-print-only-one-header t)
288   (setq safe-local-variable-values (quote ((auto-save-default) (make-backup-files))))
289   (setq sentence-end "[.?!][]\"')]*\\($\\|   \\| \\)[    
290   ]*")
291   (setq sentence-end-double-space nil)
292   ; enable matching parenthesis
293   (show-paren-mode 1)
294   (tool-bar-mode -1)
295   (setq user-mail-address "don@donarmstrong.com")
296   (setq vc-delete-logbuf-window nil)
297   (setq vc-follow-symlinks t)
298
299   ;; use git before SVN; use CVS earlier, because I have CVS
300   ;; repositories inside of git directories
301   (setq vc-handled-backends (quote (CVS Git RCS SVN SCCS Bzr Hg Mtn Arch)))
302
303   ;; switch back to the old primary selection method
304   (setq x-select-enable-clipboard nil)
305   (setq x-select-enable-primary t)
306   ; (setq mouse-drag-copy-region t)
307
308   (fset 'perl-mode 'cperl-mode)
309   ;;(load-file "cperl-mode.el")
310
311   (require 'vcl-mode)
312
313   (require 'tex-site)
314   ;;(require 'psvn)
315   ;;(require 'ecasound)
316   ;;(require 'emacs-wiki)
317   (require 'bibtex)
318   (require 'post)
319   ;;(require 'fixme)
320   ; (require 'google-weather)
321   ; (require 'org-google-weather)
322   ; (setq-default org-google-weather-format "%i %c, [%l,%h] %s %C")
323
324   ; http://julien.danjou.info/projects/emacs-packages#rainbow-mode
325   ; this colorizes color strings
326   (require 'rainbow-mode)
327   ; add ess to the x major mode
328   (add-to-list 'rainbow-x-colors-major-mode-list 'ESS[S])
329   (add-to-list 'rainbow-x-colors-major-mode-list 'ESS[R])
330
331   (global-set-key "\C-xp" 'server-edit)
332
333   (setq-default auto-mode-alist (cons '("\.wml$" . 
334                     (lambda () (html-mode) (auto-fill-mode)))
335                   auto-mode-alist))
336
337
338   ; use markdown mode for mdwn files
339   (add-to-list 'auto-mode-alist '("\\.mdwn$" . markdown-mode))
340   (add-to-list 'auto-mode-alist '("\\.md$" . markdown-mode))
341
342
343   ;; tramp configuration
344   (setq tramp-use-ssh-controlmaster-options nil)
345
346   ; mail configuration
347   (add-to-list 'auto-mode-alist '("muttng-[a-z0-9]+-[0-9]+-" . message-mode))
348   (add-to-list 'auto-mode-alist '("muttngrc" . muttrc-mode))
349
350   (add-to-list 'auto-mode-alist '("mutt-[a-z0-9]+-[0-9]+-" . message-mode))
351   (add-to-list 'auto-mode-alist '("muttrc" . muttrc-mode))
352   (defun my-message-mode-settings ()
353     (font-lock-add-keywords nil
354                             '(("^[ \t]*>[ \t]*>[ \t]*>.*$"
355                                (0 'message-multiply-quoted-text-face))
356                               ("^[ \t]*>[ \t]*>.*$"
357                                (0 'message-double-quoted-text-face))))
358     (local-set-key (kbd "C-c C-a") 'my-post-attach-file)
359     )
360   (add-hook 'message-mode-hook 'my-message-mode-settings)
361
362   (defun my-post-attach-file ()
363     "Prompt for an attachment."
364     (interactive)
365     (let ((file (read-file-name "Attach file: " nil nil t nil))
366           (description (string-read "Description: ")))
367       (my-header-attach-file file description)))
368
369   (symbol-function 'my-post-attach-file)
370
371   (defun my-header-attach-file (file description)
372     "Attach a FILE to the current message (works with Mutt).
373   Argument DESCRIPTION MIME description."
374     (interactive "fAttach file: \nsDescription: ")
375     (when (> (length file) 0)
376       (save-excursion
377         (save-match-data
378           (save-restriction
379             (widen)
380             (goto-char (point-min))
381             (search-forward-regexp "^$")
382             (insert (concat "Attach: " (replace-regexp-in-string "\\([[:space:]\\]\\)" "\\\\\\1" (file-truename file)) " "
383                             description "\n"))
384             (message (concat "Attached '" file "'."))
385             (setq post-has-attachment t))))))
386
387
388
389   (setq mail-yank-prefix "> ")
390
391   (global-unset-key "\M-g")
392   (global-set-key "\M-g" 'goto-line)
393
394   ;; self-insert-command hack.
395   ;;   Without this, "if<SP>" expands to
396   ;;   if ( -!-) {
397   ;;   }
398   ;;   which really should be,
399   ;;   if (-!-) {
400   ;;   }
401
402
403
404   ;(load-library "php-mode")
405
406   (setq-default c-indent-level 4)
407   (setq-default c-brace-imaginary-offset 0)
408   (setq-default c-brace-offset -4)
409   (setq-default c-argdecl-indent 4)
410   (setq-default c-label-offset -4)
411   (setq-default c-continued-statement-offset 4)
412   ; tabs are annoying
413   (setq-default indent-tabs-mode nil)
414   (setq-default tab-width 4)
415
416
417   ;; (autoload 'php-mode "php-mode" "PHP editing mode" t)
418   ;; (add-to-list 'auto-mode-alist '("\\.php3?\\'" . php-mode))
419   ;; (add-to-list 'auto-mode-alist '("\\.phtml?\\'" . php-mode))
420   ;; (add-to-list 'auto-mode-alist '("\\.php?\\'" . php-mode))
421   ;; (add-to-list 'auto-mode-alist '("\\.php4?\\'" . php-mode))
422
423
424   (defun insert-date ()
425     "Insert date at point."
426     (interactive)
427     (insert (format-time-string "%A, %B %e, %Y %k:%M:%S %Z")))
428   (global-set-key "\C-[d" 'insert-date)
429
430   (defun unfill-paragraph (arg)
431     "Pull this whole paragraph up onto one line."
432     (interactive "*p")
433     (let ((fill-column 10000))
434       (fill-paragraph arg))
435     )
436
437   (column-number-mode t)
438   (setq-default reftex-plug-into-AUCTeX t)
439
440   (server-start)
441
442   ; (require 'mode-compile)
443
444   (defadvice server-process-filter (after post-mode-message first activate)
445     "If the buffer is in post mode, overwrite the server-edit
446       message with a post-save-current-buffer-and-exit message."
447     (if (eq major-mode 'post-mode)
448         (message
449          (substitute-command-keys "Type \\[describe-mode] for help composing; \\[post-save-current-buffer-and-exit] when done."))))
450                       ; This is also needed to see the magic message.  Set to a higher
451                       ; number if you have a faster computer or read slower than me.
452   '(font-lock-verbose 1000)
453   ;(setq-default server-temp-file-regexp "mutt\(-\|ng-\)")
454   ; (add-hook 'server-switch-hook 
455   ;     (function (lambda()
456   ;             (cond ((string-match "Post" mode-name)
457   ;                (post-goto-body)))
458   ;             set-buffer-file-coding-system 'utf-8
459   ;             )))
460   ; 
461
462   (add-hook 'post-mode-hook
463         (auto-fill-mode nil)
464         )
465   ; abbrev mode settings
466   ; load abbreviations from 
467   (setq abbrev-file-name       
468         "~/.emacs_abbrev_def")
469
470   ; read the abbrev file if it exists
471   (if (file-exists-p abbrev-file-name)
472       (quietly-read-abbrev-file))
473
474   ; for now, use abbrev mode everywhere
475   (setq default-abbrev-mode t)
476
477
478   (defun insert-function-documentation ()
479     "Insert function documentation"
480     (interactive)
481     (insert-file-contents "/home/don/lib/templates/perl_function_documentation" nil))
482   (global-set-key "\M-f" 'insert-function-documentation)
483
484   (eval-after-load "lilypond-mode" 
485     '(progn
486        (load-library "lyqi-mode")
487        (define-key LilyPond-mode-map "\C-cq" 'lyqi-mode)))
488
489   (autoload 'spamassassin-mode "spamassassin-mode" nil t)
490
491   (desktop-load-default)
492   (desktop-read)
493   '(icomplete-mode on)
494   (custom-set-faces
495    ;; custom-set-faces was added by Custom.
496    ;; If you edit it by hand, you could mess it up, so be careful.
497    ;; Your init file should contain only one such instance.
498    ;; If there is more than one, they won't work right.
499    '(menu ((((type x-toolkit)) (:background "black" :foreground "grey90")))))
500
501
502   (put 'upcase-region 'disabled nil)
503   (put 'downcase-region 'disabled nil)
504   (put 'narrow-to-region 'disabled nil)
505
506
507   (autoload 'flyspell-mode "flyspell" "On-the-fly spelling checker." t)
508   (add-hook 'message-mode-hook 'turn-on-flyspell)
509   (add-hook 'text-mode-hook 'turn-on-flyspell)
510   (add-hook 'c-mode-common-hook 'flyspell-prog-mode)
511   (add-hook 'cperl-mode-hook 'flyspell-prog-mode)
512   (add-hook 'tcl-mode-hook 'flyspell-prog-mode)
513   ; (defun turn-on-flyspell ()
514   ;    "Force flyspell-mode on using a positive arg.  For use in hooks."
515   ;    (interactive)
516   ;    (flyspell-mode 1))
517
518
519    ; Outline-minor-mode key map
520    (define-prefix-command 'cm-map nil "Outline-")
521    ; HIDE
522    (define-key cm-map "q" 'hide-sublevels)    ; Hide everything but the top-level headings
523    (define-key cm-map "t" 'hide-body)         ; Hide everything but headings (all body lines)
524    (define-key cm-map "o" 'hide-other)        ; Hide other branches
525    (define-key cm-map "c" 'hide-entry)        ; Hide this entry's body
526    (define-key cm-map "l" 'hide-leaves)       ; Hide body lines in this entry and sub-entries
527    (define-key cm-map "d" 'hide-subtree)      ; Hide everything in this entry and sub-entries
528    ; SHOW
529    (define-key cm-map "a" 'show-all)          ; Show (expand) everything
530    (define-key cm-map "e" 'show-entry)        ; Show this heading's body
531    (define-key cm-map "i" 'show-children)     ; Show this heading's immediate child sub-headings
532    (define-key cm-map "k" 'show-branches)     ; Show all sub-headings under this heading
533    (define-key cm-map "s" 'show-subtree)      ; Show (expand) everything in this heading & below
534    ; MOVE
535    (define-key cm-map "u" 'outline-up-heading)                ; Up
536    (define-key cm-map "n" 'outline-next-visible-heading)      ; Next
537    (define-key cm-map "p" 'outline-previous-visible-heading)  ; Previous
538    (define-key cm-map "f" 'outline-forward-same-level)        ; Forward - same level
539    (define-key cm-map "b" 'outline-backward-same-level)       ; Backward - same level
540    (global-set-key "\M-o" cm-map)
541
542
543   ; debian stuff
544   (setq-default debian-changelog-mailing-address "don@debian.org")
545   (setq-default debian-changelog-full-name "Don Armstrong")
546
547   ; ediff configuration
548   ; don't use the multi-window configuration
549   (setq ediff-window-setup-function 'ediff-setup-windows-plain)
550
551   ; use iedit
552   (require 'iedit)
553   (define-key global-map (kbd "C-;") 'iedit-mode)
554   (global-set-key  (kbd "C-;") 'iedit-mode)
555
556   ; fix up css mode to not be silly
557   ; from http://www.stokebloke.com/wordpress/2008/03/21/css-mode-indent-buffer-fix/
558   (setq cssm-indent-level 4)
559   (setq cssm-newline-before-closing-bracket t)
560   (setq cssm-indent-function #'cssm-c-style-indenter)
561   (setq cssm-mirror-mode nil)
562
563   (require 'multi-web-mode)
564   (setq mweb-default-major-mode 'html-mode)
565   (setq mweb-tags '((php-mode "<\\?php\\|<\\? \\|<\\?=" "\\?>")
566                     (js-mode "<script +\\(type=\"text/javascript\"\\|language=\"javascript\"\\)[^>]*>" "</script>")
567                     (css-mode "<style +type=\"text/css\"[^>]*>" "</style>")))
568   (setq mweb-filename-extensions '("php" "htm" "html" "ctp" "phtml" "php4" "php5"))
569   (multi-web-global-mode 1)
570
571   ;;; alias the new `flymake-report-status-slim' to
572   ;;; `flymake-report-status'
573   (defalias 'flymake-report-status 'flymake-report-status-slim)
574   (defun flymake-report-status-slim (e-w &optional status)
575     "Show \"slim\" flymake status in mode line."
576     (when e-w
577       (setq flymake-mode-line-e-w e-w))
578     (when status
579       (setq flymake-mode-line-status status))
580     (let* ((mode-line " Φ"))
581       (when (> (length flymake-mode-line-e-w) 0)
582         (setq mode-line (concat mode-line ":" flymake-mode-line-e-w)))
583       (setq mode-line (concat mode-line flymake-mode-line-status))
584       (setq flymake-mode-line mode-line)
585       (force-mode-line-update)))
586
587   ; load sql-indent when sql is loaded
588   (eval-after-load "sql"
589     '(load-library "sql-indent"))
590
591   ; fix up tmux xterm keys
592   ; stolen from http://unix.stackexchange.com/questions/24414/shift-arrow-not-working-in-emacs-within-tmux
593   (if (getenv "TMUX")
594       (progn
595         (let ((x 2) (tkey ""))
596           (while (<= x 8)
597             ;; shift
598             (if (= x 2)
599                 (setq tkey "S-"))
600             ;; alt
601             (if (= x 3)
602                 (setq tkey "M-"))
603             ;; alt + shift
604             (if (= x 4)
605                 (setq tkey "M-S-"))
606             ;; ctrl
607             (if (= x 5)
608                 (setq tkey "C-"))
609             ;; ctrl + shift
610             (if (= x 6)
611                 (setq tkey "C-S-"))
612             ;; ctrl + alt
613             (if (= x 7)
614                 (setq tkey "C-M-"))
615             ;; ctrl + alt + shift
616             (if (= x 8)
617                 (setq tkey "C-M-S-"))
618   
619             ;; arrows
620             (define-key key-translation-map (kbd (format "M-[ 1 ; %d A" x)) (kbd (format "%s<up>" tkey)))
621             (define-key key-translation-map (kbd (format "M-[ 1 ; %d B" x)) (kbd (format "%s<down>" tkey)))
622             (define-key key-translation-map (kbd (format "M-[ 1 ; %d C" x)) (kbd (format "%s<right>" tkey)))
623             (define-key key-translation-map (kbd (format "M-[ 1 ; %d D" x)) (kbd (format "%s<left>" tkey)))
624             ;; home
625             (define-key key-translation-map (kbd (format "M-[ 1 ; %d H" x)) (kbd (format "%s<home>" tkey)))
626             ;; end
627             (define-key key-translation-map (kbd (format "M-[ 1 ; %d F" x)) (kbd (format "%s<end>" tkey)))
628             ;; page up
629             (define-key key-translation-map (kbd (format "M-[ 5 ; %d ~" x)) (kbd (format "%s<prior>" tkey)))
630             ;; page down
631             (define-key key-translation-map (kbd (format "M-[ 6 ; %d ~" x)) (kbd (format "%s<next>" tkey)))
632             ;; insert
633             (define-key key-translation-map (kbd (format "M-[ 2 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
634             ;; delete
635             (define-key key-translation-map (kbd (format "M-[ 3 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
636             ;; f1
637             (define-key key-translation-map (kbd (format "M-[ 1 ; %d P" x)) (kbd (format "%s<f1>" tkey)))
638             ;; f2
639             (define-key key-translation-map (kbd (format "M-[ 1 ; %d Q" x)) (kbd (format "%s<f2>" tkey)))
640             ;; f3
641             (define-key key-translation-map (kbd (format "M-[ 1 ; %d R" x)) (kbd (format "%s<f3>" tkey)))
642             ;; f4
643             (define-key key-translation-map (kbd (format "M-[ 1 ; %d S" x)) (kbd (format "%s<f4>" tkey)))
644             ;; f5
645             (define-key key-translation-map (kbd (format "M-[ 15 ; %d ~" x)) (kbd (format "%s<f5>" tkey)))
646             ;; f6
647             (define-key key-translation-map (kbd (format "M-[ 17 ; %d ~" x)) (kbd (format "%s<f6>" tkey)))
648             ;; f7
649             (define-key key-translation-map (kbd (format "M-[ 18 ; %d ~" x)) (kbd (format "%s<f7>" tkey)))
650             ;; f8
651             (define-key key-translation-map (kbd (format "M-[ 19 ; %d ~" x)) (kbd (format "%s<f8>" tkey)))
652             ;; f9
653             (define-key key-translation-map (kbd (format "M-[ 20 ; %d ~" x)) (kbd (format "%s<f9>" tkey)))
654             ;; f10
655             (define-key key-translation-map (kbd (format "M-[ 21 ; %d ~" x)) (kbd (format "%s<f10>" tkey)))
656             ;; f11
657             (define-key key-translation-map (kbd (format "M-[ 23 ; %d ~" x)) (kbd (format "%s<f11>" tkey)))
658             ;; f12
659             (define-key key-translation-map (kbd (format "M-[ 24 ; %d ~" x)) (kbd (format "%s<f12>" tkey)))
660             ;; f13
661             (define-key key-translation-map (kbd (format "M-[ 25 ; %d ~" x)) (kbd (format "%s<f13>" tkey)))
662             ;; f14
663             (define-key key-translation-map (kbd (format "M-[ 26 ; %d ~" x)) (kbd (format "%s<f14>" tkey)))
664             ;; f15
665             (define-key key-translation-map (kbd (format "M-[ 28 ; %d ~" x)) (kbd (format "%s<f15>" tkey)))
666             ;; f16
667             (define-key key-translation-map (kbd (format "M-[ 29 ; %d ~" x)) (kbd (format "%s<f16>" tkey)))
668             ;; f17
669             (define-key key-translation-map (kbd (format "M-[ 31 ; %d ~" x)) (kbd (format "%s<f17>" tkey)))
670             ;; f18
671             (define-key key-translation-map (kbd (format "M-[ 32 ; %d ~" x)) (kbd (format "%s<f18>" tkey)))
672             ;; f19
673             (define-key key-translation-map (kbd (format "M-[ 33 ; %d ~" x)) (kbd (format "%s<f19>" tkey)))
674             ;; f20
675             (define-key key-translation-map (kbd (format "M-[ 34 ; %d ~" x)) (kbd (format "%s<f20>" tkey)))
676
677             (setq x (+ x 1))
678             ))
679         )
680     )
681
682   ; procmailmode configuration
683   (load "procmail_mode")
684
685   (load "mode-line-cleaner")
686
687   (defadvice ask-user-about-supersession-threat (around ask-user-about-supersession-threat-if-necessary)
688     "Call ask-user-about-supersession-threat only if the buffer is actually obsolete."
689     (if (or (buffer-modified-p)
690             (verify-visited-file-modtime)
691             (< (* 8 1024 1024) (buffer-size))
692             (/= 0 (call-process-region 1 (+ 1 (buffer-size)) "diff" nil nil nil "-q" (buffer-file-name) "-")))
693         ad-do-it
694       (clear-visited-file-modtime)
695       (not-modified)))
696   (ad-activate 'ask-user-about-supersession-threat)
697
698   ; apparently things like to step on C-;, so we'll use a hack from
699   ; http://stackoverflow.com/questions/683425/globally-override-key-binding-in-emacs/5340797#5340797 to fix this
700
701   (defvar my-keys-minor-mode-map (make-keymap) "my-keys-minor-mode keymap.")
702
703   ; use iedit everywhere
704   (define-key my-keys-minor-mode-map (kbd "C-;") 'iedit-mode)
705
706   (define-minor-mode my-keys-minor-mode
707     "A minor mode so that my key settings override annoying major modes."
708     t " my-keys" 'my-keys-minor-mode-map)
709
710   (my-keys-minor-mode 1)
711   (defun my-minibuffer-setup-hook ()
712     (my-keys-minor-mode 0))
713
714   (add-hook 'minibuffer-setup-hook 'my-minibuffer-setup-hook)
715   (defadvice load (after give-my-keybindings-priority)
716     "Try to ensure that my keybindings always have priority."
717     (if (not (eq (car (car minor-mode-map-alist)) 'my-keys-minor-mode))
718         (let ((mykeys (assq 'my-keys-minor-mode minor-mode-map-alist)))
719           (assq-delete-all 'my-keys-minor-mode minor-mode-map-alist)
720           (add-to-list 'minor-mode-map-alist mykeys))))
721   (ad-activate 'load)
722   (global-set-key "\M- " 'hippie-expand)
723
724 #+END_SRC
725
726 * END
727 #+BEGIN_SRC emacs-lisp  :tangle don-configuration.el
728   (provide 'don-configuration)
729 #+END_SRC