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