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