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