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