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