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