]> git.donarmstrong.com Git - lib.git/blob - emacs_el/configuration/don-configuration.org
move general configuration from .emacs to don-configuration.org
[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 [33 57 north])
257   (setq calendar-longitude [117 24 west])
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   (setq display-time t)
263   (setq display-time-24hr-format t)
264   (setq display-time-day-and-date t)
265   (setq display-time-mode t)
266   (setq font-latex-fontify-script nil)
267   (setq font-latex-fontify-sectioning (quote color))
268   (setq font-latex-script-display (quote (nil)))
269   (setq global-auto-revert-mode t)
270   (setq global-font-lock-mode t)
271   (setq icomplete-mode t)
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   (setq show-paren-mode t)
293   (tool-bar-mode -1)
294   (setq user-mail-address "don@donarmstrong.com")
295   (setq vc-delete-logbuf-window nil)
296   (setq vc-follow-symlinks t)
297
298   ;; use git before SVN; use CVS earlier, because I have CVS
299   ;; repositories inside of git directories
300   (setq vc-handled-backends (quote (CVS Git RCS SVN SCCS Bzr Hg Mtn Arch)))
301
302   ;; switch back to the old primary selection method
303   (setq x-select-enable-clipboard nil)
304   (setq x-select-enable-primary t)
305   ; (setq mouse-drag-copy-region t)
306
307   (fset 'perl-mode 'cperl-mode)
308   ;;(load-file "cperl-mode.el")
309
310   (require 'vcl-mode)
311
312   (require 'tex-site)
313   ;;(require 'psvn)
314   ;;(require 'ecasound)
315   ;;(require 'emacs-wiki)
316   (require 'bibtex)
317   (require 'post)
318   ;;(require 'fixme)
319   ; (require 'google-weather)
320   ; (require 'org-google-weather)
321   ; (setq-default org-google-weather-format "%i %c, [%l,%h] %s %C")
322
323   ; http://julien.danjou.info/projects/emacs-packages#rainbow-mode
324   ; this colorizes color strings
325   (require 'rainbow-mode)
326   ; add ess to the x major mode
327   (add-to-list 'rainbow-x-colors-major-mode-list 'ESS[S])
328   (add-to-list 'rainbow-x-colors-major-mode-list 'ESS[R])
329
330   (global-set-key "\C-xp" 'server-edit)
331
332   (setq-default auto-mode-alist (cons '("\.wml$" . 
333                     (lambda () (html-mode) (auto-fill-mode)))
334                   auto-mode-alist))
335
336
337   ; use markdown mode for mdwn files
338   (add-to-list 'auto-mode-alist '("\\.mdwn$" . markdown-mode))
339   (add-to-list 'auto-mode-alist '("\\.md$" . markdown-mode))
340
341
342   ;; tramp configuration
343   (setq tramp-use-ssh-controlmaster-options nil)
344
345   ; mail configuration
346   (add-to-list 'auto-mode-alist '("muttng-[a-z0-9]+-[0-9]+-" . message-mode))
347   (add-to-list 'auto-mode-alist '("muttngrc" . muttrc-mode))
348
349   (add-to-list 'auto-mode-alist '("mutt-[a-z0-9]+-[0-9]+-" . message-mode))
350   (add-to-list 'auto-mode-alist '("muttrc" . muttrc-mode))
351   (defun my-message-mode-settings ()
352     (font-lock-add-keywords nil
353                             '(("^[ \t]*>[ \t]*>[ \t]*>.*$"
354                                (0 'message-multiply-quoted-text-face))
355                               ("^[ \t]*>[ \t]*>.*$"
356                                (0 'message-double-quoted-text-face))))
357     (local-set-key (kbd "C-c C-a") 'my-post-attach-file)
358     )
359   (add-hook 'message-mode-hook 'my-message-mode-settings)
360
361   (defun my-post-attach-file ()
362     "Prompt for an attachment."
363     (interactive)
364     (let ((file (read-file-name "Attach file: " nil nil t nil))
365           (description (string-read "Description: ")))
366       (my-header-attach-file file description)))
367
368   (symbol-function 'my-post-attach-file)
369
370   (defun my-header-attach-file (file description)
371     "Attach a FILE to the current message (works with Mutt).
372   Argument DESCRIPTION MIME description."
373     (interactive "fAttach file: \nsDescription: ")
374     (when (> (length file) 0)
375       (save-excursion
376         (save-match-data
377           (save-restriction
378             (widen)
379             (goto-char (point-min))
380             (search-forward-regexp "^$")
381             (insert (concat "Attach: " (replace-regexp-in-string "\\([[:space:]\\]\\)" "\\\\\\1" (file-truename file)) " "
382                             description "\n"))
383             (message (concat "Attached '" file "'."))
384             (setq post-has-attachment t))))))
385
386
387
388   (setq mail-yank-prefix "> ")
389
390   (global-unset-key "\M-g")
391   (global-set-key "\M-g" 'goto-line)
392
393   ;; self-insert-command hack.
394   ;;   Without this, "if<SP>" expands to
395   ;;   if ( -!-) {
396   ;;   }
397   ;;   which really should be,
398   ;;   if (-!-) {
399   ;;   }
400
401
402
403   ;(load-library "php-mode")
404
405   (setq-default c-indent-level 4)
406   (setq-default c-brace-imaginary-offset 0)
407   (setq-default c-brace-offset -4)
408   (setq-default c-argdecl-indent 4)
409   (setq-default c-label-offset -4)
410   (setq-default c-continued-statement-offset 4)
411   ; tabs are annoying
412   (setq-default indent-tabs-mode nil)
413   (setq-default tab-width 4)
414
415
416   ;; (autoload 'php-mode "php-mode" "PHP editing mode" t)
417   ;; (add-to-list 'auto-mode-alist '("\\.php3?\\'" . php-mode))
418   ;; (add-to-list 'auto-mode-alist '("\\.phtml?\\'" . php-mode))
419   ;; (add-to-list 'auto-mode-alist '("\\.php?\\'" . php-mode))
420   ;; (add-to-list 'auto-mode-alist '("\\.php4?\\'" . php-mode))
421
422
423   (defun insert-date ()
424     "Insert date at point."
425     (interactive)
426     (insert (format-time-string "%A, %B %e, %Y %k:%M:%S %Z")))
427   (global-set-key "\C-[d" 'insert-date)
428
429   (defun unfill-paragraph (arg)
430     "Pull this whole paragraph up onto one line."
431     (interactive "*p")
432     (let ((fill-column 10000))
433       (fill-paragraph arg))
434     )
435
436   (column-number-mode t)
437   (setq-default reftex-plug-into-AUCTeX t)
438
439   (server-start)
440
441   ; (require 'mode-compile)
442
443   (defadvice server-process-filter (after post-mode-message first activate)
444     "If the buffer is in post mode, overwrite the server-edit
445       message with a post-save-current-buffer-and-exit message."
446     (if (eq major-mode 'post-mode)
447         (message
448          (substitute-command-keys "Type \\[describe-mode] for help composing; \\[post-save-current-buffer-and-exit] when done."))))
449                       ; This is also needed to see the magic message.  Set to a higher
450                       ; number if you have a faster computer or read slower than me.
451   '(font-lock-verbose 1000)
452   ;(setq-default server-temp-file-regexp "mutt\(-\|ng-\)")
453   ; (add-hook 'server-switch-hook 
454   ;     (function (lambda()
455   ;             (cond ((string-match "Post" mode-name)
456   ;                (post-goto-body)))
457   ;             set-buffer-file-coding-system 'utf-8
458   ;             )))
459   ; 
460
461   (add-hook 'post-mode-hook
462         (auto-fill-mode nil)
463         )
464   ; abbrev mode settings
465   ; load abbreviations from 
466   (setq abbrev-file-name       
467         "~/.emacs_abbrev_def")
468
469   ; read the abbrev file if it exists
470   (if (file-exists-p abbrev-file-name)
471       (quietly-read-abbrev-file))
472
473   ; for now, use abbrev mode everywhere
474   (setq default-abbrev-mode t)
475
476
477   (defun insert-function-documentation ()
478     "Insert function documentation"
479     (interactive)
480     (insert-file-contents "/home/don/lib/templates/perl_function_documentation" nil))
481   (global-set-key "\M-f" 'insert-function-documentation)
482
483   (eval-after-load "lilypond-mode" 
484     '(progn
485        (load-library "lyqi-mode")
486        (define-key LilyPond-mode-map "\C-cq" 'lyqi-mode)))
487
488   (autoload 'spamassassin-mode "spamassassin-mode" nil t)
489
490   (desktop-load-default)
491   (desktop-read)
492   '(icomplete-mode on)
493   (custom-set-faces
494    ;; custom-set-faces was added by Custom.
495    ;; If you edit it by hand, you could mess it up, so be careful.
496    ;; Your init file should contain only one such instance.
497    ;; If there is more than one, they won't work right.
498    '(menu ((((type x-toolkit)) (:background "black" :foreground "grey90")))))
499
500
501   (put 'upcase-region 'disabled nil)
502   (put 'downcase-region 'disabled nil)
503   (put 'narrow-to-region 'disabled nil)
504
505
506   (autoload 'flyspell-mode "flyspell" "On-the-fly spelling checker." t)
507   (add-hook 'message-mode-hook 'turn-on-flyspell)
508   (add-hook 'text-mode-hook 'turn-on-flyspell)
509   (add-hook 'c-mode-common-hook 'flyspell-prog-mode)
510   (add-hook 'cperl-mode-hook 'flyspell-prog-mode)
511   (add-hook 'tcl-mode-hook 'flyspell-prog-mode)
512   ; (defun turn-on-flyspell ()
513   ;    "Force flyspell-mode on using a positive arg.  For use in hooks."
514   ;    (interactive)
515   ;    (flyspell-mode 1))
516
517
518    ; Outline-minor-mode key map
519    (define-prefix-command 'cm-map nil "Outline-")
520    ; HIDE
521    (define-key cm-map "q" 'hide-sublevels)    ; Hide everything but the top-level headings
522    (define-key cm-map "t" 'hide-body)         ; Hide everything but headings (all body lines)
523    (define-key cm-map "o" 'hide-other)        ; Hide other branches
524    (define-key cm-map "c" 'hide-entry)        ; Hide this entry's body
525    (define-key cm-map "l" 'hide-leaves)       ; Hide body lines in this entry and sub-entries
526    (define-key cm-map "d" 'hide-subtree)      ; Hide everything in this entry and sub-entries
527    ; SHOW
528    (define-key cm-map "a" 'show-all)          ; Show (expand) everything
529    (define-key cm-map "e" 'show-entry)        ; Show this heading's body
530    (define-key cm-map "i" 'show-children)     ; Show this heading's immediate child sub-headings
531    (define-key cm-map "k" 'show-branches)     ; Show all sub-headings under this heading
532    (define-key cm-map "s" 'show-subtree)      ; Show (expand) everything in this heading & below
533    ; MOVE
534    (define-key cm-map "u" 'outline-up-heading)                ; Up
535    (define-key cm-map "n" 'outline-next-visible-heading)      ; Next
536    (define-key cm-map "p" 'outline-previous-visible-heading)  ; Previous
537    (define-key cm-map "f" 'outline-forward-same-level)        ; Forward - same level
538    (define-key cm-map "b" 'outline-backward-same-level)       ; Backward - same level
539    (global-set-key "\M-o" cm-map)
540
541
542   ; debian stuff
543   (setq-default debian-changelog-mailing-address "don@debian.org")
544   (setq-default debian-changelog-full-name "Don Armstrong")
545
546   ; ediff configuration
547   ; don't use the multi-window configuration
548   (setq ediff-window-setup-function 'ediff-setup-windows-plain)
549
550   ; use iedit
551   (require 'iedit)
552   (define-key global-map (kbd "C-;") 'iedit-mode)
553   (global-set-key  (kbd "C-;") 'iedit-mode)
554
555   ; fix up css mode to not be silly
556   ; from http://www.stokebloke.com/wordpress/2008/03/21/css-mode-indent-buffer-fix/
557   (setq cssm-indent-level 4)
558   (setq cssm-newline-before-closing-bracket t)
559   (setq cssm-indent-function #'cssm-c-style-indenter)
560   (setq cssm-mirror-mode nil)
561
562   (require 'multi-web-mode)
563   (setq mweb-default-major-mode 'html-mode)
564   (setq mweb-tags '((php-mode "<\\?php\\|<\\? \\|<\\?=" "\\?>")
565                     (js-mode "<script +\\(type=\"text/javascript\"\\|language=\"javascript\"\\)[^>]*>" "</script>")
566                     (css-mode "<style +type=\"text/css\"[^>]*>" "</style>")))
567   (setq mweb-filename-extensions '("php" "htm" "html" "ctp" "phtml" "php4" "php5"))
568   (multi-web-global-mode 1)
569
570   ;;; alias the new `flymake-report-status-slim' to
571   ;;; `flymake-report-status'
572   (defalias 'flymake-report-status 'flymake-report-status-slim)
573   (defun flymake-report-status-slim (e-w &optional status)
574     "Show \"slim\" flymake status in mode line."
575     (when e-w
576       (setq flymake-mode-line-e-w e-w))
577     (when status
578       (setq flymake-mode-line-status status))
579     (let* ((mode-line " Φ"))
580       (when (> (length flymake-mode-line-e-w) 0)
581         (setq mode-line (concat mode-line ":" flymake-mode-line-e-w)))
582       (setq mode-line (concat mode-line flymake-mode-line-status))
583       (setq flymake-mode-line mode-line)
584       (force-mode-line-update)))
585
586   ; load sql-indent when sql is loaded
587   (eval-after-load "sql"
588     '(load-library "sql-indent"))
589
590   ; fix up tmux xterm keys
591   ; stolen from http://unix.stackexchange.com/questions/24414/shift-arrow-not-working-in-emacs-within-tmux
592   (if (getenv "TMUX")
593       (progn
594         (let ((x 2) (tkey ""))
595           (while (<= x 8)
596             ;; shift
597             (if (= x 2)
598                 (setq tkey "S-"))
599             ;; alt
600             (if (= x 3)
601                 (setq tkey "M-"))
602             ;; alt + shift
603             (if (= x 4)
604                 (setq tkey "M-S-"))
605             ;; ctrl
606             (if (= x 5)
607                 (setq tkey "C-"))
608             ;; ctrl + shift
609             (if (= x 6)
610                 (setq tkey "C-S-"))
611             ;; ctrl + alt
612             (if (= x 7)
613                 (setq tkey "C-M-"))
614             ;; ctrl + alt + shift
615             (if (= x 8)
616                 (setq tkey "C-M-S-"))
617   
618             ;; arrows
619             (define-key key-translation-map (kbd (format "M-[ 1 ; %d A" x)) (kbd (format "%s<up>" tkey)))
620             (define-key key-translation-map (kbd (format "M-[ 1 ; %d B" x)) (kbd (format "%s<down>" tkey)))
621             (define-key key-translation-map (kbd (format "M-[ 1 ; %d C" x)) (kbd (format "%s<right>" tkey)))
622             (define-key key-translation-map (kbd (format "M-[ 1 ; %d D" x)) (kbd (format "%s<left>" tkey)))
623             ;; home
624             (define-key key-translation-map (kbd (format "M-[ 1 ; %d H" x)) (kbd (format "%s<home>" tkey)))
625             ;; end
626             (define-key key-translation-map (kbd (format "M-[ 1 ; %d F" x)) (kbd (format "%s<end>" tkey)))
627             ;; page up
628             (define-key key-translation-map (kbd (format "M-[ 5 ; %d ~" x)) (kbd (format "%s<prior>" tkey)))
629             ;; page down
630             (define-key key-translation-map (kbd (format "M-[ 6 ; %d ~" x)) (kbd (format "%s<next>" tkey)))
631             ;; insert
632             (define-key key-translation-map (kbd (format "M-[ 2 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
633             ;; delete
634             (define-key key-translation-map (kbd (format "M-[ 3 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
635             ;; f1
636             (define-key key-translation-map (kbd (format "M-[ 1 ; %d P" x)) (kbd (format "%s<f1>" tkey)))
637             ;; f2
638             (define-key key-translation-map (kbd (format "M-[ 1 ; %d Q" x)) (kbd (format "%s<f2>" tkey)))
639             ;; f3
640             (define-key key-translation-map (kbd (format "M-[ 1 ; %d R" x)) (kbd (format "%s<f3>" tkey)))
641             ;; f4
642             (define-key key-translation-map (kbd (format "M-[ 1 ; %d S" x)) (kbd (format "%s<f4>" tkey)))
643             ;; f5
644             (define-key key-translation-map (kbd (format "M-[ 15 ; %d ~" x)) (kbd (format "%s<f5>" tkey)))
645             ;; f6
646             (define-key key-translation-map (kbd (format "M-[ 17 ; %d ~" x)) (kbd (format "%s<f6>" tkey)))
647             ;; f7
648             (define-key key-translation-map (kbd (format "M-[ 18 ; %d ~" x)) (kbd (format "%s<f7>" tkey)))
649             ;; f8
650             (define-key key-translation-map (kbd (format "M-[ 19 ; %d ~" x)) (kbd (format "%s<f8>" tkey)))
651             ;; f9
652             (define-key key-translation-map (kbd (format "M-[ 20 ; %d ~" x)) (kbd (format "%s<f9>" tkey)))
653             ;; f10
654             (define-key key-translation-map (kbd (format "M-[ 21 ; %d ~" x)) (kbd (format "%s<f10>" tkey)))
655             ;; f11
656             (define-key key-translation-map (kbd (format "M-[ 23 ; %d ~" x)) (kbd (format "%s<f11>" tkey)))
657             ;; f12
658             (define-key key-translation-map (kbd (format "M-[ 24 ; %d ~" x)) (kbd (format "%s<f12>" tkey)))
659             ;; f13
660             (define-key key-translation-map (kbd (format "M-[ 25 ; %d ~" x)) (kbd (format "%s<f13>" tkey)))
661             ;; f14
662             (define-key key-translation-map (kbd (format "M-[ 26 ; %d ~" x)) (kbd (format "%s<f14>" tkey)))
663             ;; f15
664             (define-key key-translation-map (kbd (format "M-[ 28 ; %d ~" x)) (kbd (format "%s<f15>" tkey)))
665             ;; f16
666             (define-key key-translation-map (kbd (format "M-[ 29 ; %d ~" x)) (kbd (format "%s<f16>" tkey)))
667             ;; f17
668             (define-key key-translation-map (kbd (format "M-[ 31 ; %d ~" x)) (kbd (format "%s<f17>" tkey)))
669             ;; f18
670             (define-key key-translation-map (kbd (format "M-[ 32 ; %d ~" x)) (kbd (format "%s<f18>" tkey)))
671             ;; f19
672             (define-key key-translation-map (kbd (format "M-[ 33 ; %d ~" x)) (kbd (format "%s<f19>" tkey)))
673             ;; f20
674             (define-key key-translation-map (kbd (format "M-[ 34 ; %d ~" x)) (kbd (format "%s<f20>" tkey)))
675
676             (setq x (+ x 1))
677             ))
678         )
679     )
680
681   ; procmailmode configuration
682   (load "procmail_mode")
683
684   (load "mode-line-cleaner")
685
686   (defadvice ask-user-about-supersession-threat (around ask-user-about-supersession-threat-if-necessary)
687     "Call ask-user-about-supersession-threat only if the buffer is actually obsolete."
688     (if (or (buffer-modified-p)
689             (verify-visited-file-modtime)
690             (< (* 8 1024 1024) (buffer-size))
691             (/= 0 (call-process-region 1 (+ 1 (buffer-size)) "diff" nil nil nil "-q" (buffer-file-name) "-")))
692         ad-do-it
693       (clear-visited-file-modtime)
694       (not-modified)))
695   (ad-activate 'ask-user-about-supersession-threat)
696
697   ; apparently things like to step on C-;, so we'll use a hack from
698   ; http://stackoverflow.com/questions/683425/globally-override-key-binding-in-emacs/5340797#5340797 to fix this
699
700   (defvar my-keys-minor-mode-map (make-keymap) "my-keys-minor-mode keymap.")
701
702   ; use iedit everywhere
703   (define-key my-keys-minor-mode-map (kbd "C-;") 'iedit-mode)
704
705   (define-minor-mode my-keys-minor-mode
706     "A minor mode so that my key settings override annoying major modes."
707     t " my-keys" 'my-keys-minor-mode-map)
708
709   (my-keys-minor-mode 1)
710   (defun my-minibuffer-setup-hook ()
711     (my-keys-minor-mode 0))
712
713   (add-hook 'minibuffer-setup-hook 'my-minibuffer-setup-hook)
714   (defadvice load (after give-my-keybindings-priority)
715     "Try to ensure that my keybindings always have priority."
716     (if (not (eq (car (car minor-mode-map-alist)) 'my-keys-minor-mode))
717         (let ((mykeys (assq 'my-keys-minor-mode minor-mode-map-alist)))
718           (assq-delete-all 'my-keys-minor-mode minor-mode-map-alist)
719           (add-to-list 'minor-mode-map-alist mykeys))))
720   (ad-activate 'load)
721   (global-set-key "\M- " 'hippie-expand)
722
723 #+END_SRC
724
725 * END
726 #+BEGIN_SRC emacs-lisp  :tangle don-configuration.el
727   (provide 'don-configuration)
728 #+END_SRC