]> git.donarmstrong.com Git - emacs.git/blob - .emacs
add commands to open mail in mutt
[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")
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  '(iswitchb-mode t)
24  '(iswitchb-prompt-newbuffer nil)
25  '(log-edit-keep-buffer t)
26  '(mail-user-agent (quote sendmail-user-agent))
27  '(markdown-enable-math t)
28  '(markdown-follow-wiki-link-on-enter nil)
29  '(mutt-alias-file-list (quote ("~/.mutt/aliases" "~/.mail_aliases")))
30  '(post-email-address "don@donarmstrong.com")
31  '(post-kill-quoted-sig nil)
32  '(post-mail-message "mutt\\(ng\\|\\)-[a-z0-9]+-[0-9]+-.*")
33  '(post-uses-fill-mode nil)
34  '(ps-footer-font-size (quote (8 . 10)))
35  '(ps-header-font-size (quote (8 . 10)))
36  '(ps-header-title-font-size (quote (10 . 10)))
37  '(ps-line-number-color "blue")
38  '(ps-print-footer t)
39  '(ps-print-footer-frame nil)
40  '(ps-print-only-one-header t)
41  '(safe-local-variable-values (quote ((auto-save-default) (make-backup-files))))
42  '(sentence-end "[.?!][]\"')]*\\($\\|   \\| \\)[        
43 ]*")
44  '(sentence-end-double-space nil)
45  '(show-paren-mode t)
46  '(tool-bar-mode nil nil (tool-bar))
47  '(user-mail-address "don@donarmstrong.com")
48  '(vc-delete-logbuf-window nil)
49  '(vc-follow-symlinks t))
50
51
52 ;; switch back to the old primary selection method
53 (setq x-select-enable-clipboard nil)
54 (setq x-select-enable-primary t)
55 ; (setq mouse-drag-copy-region t)
56
57 (fset 'perl-mode 'cperl-mode)
58 ;;(load-file "cperl-mode.el")
59 (add-to-list 'load-path '"~/lib/emacs_el/")
60 ;; this is the tiny-tools module from https://github.com/jaalto/project--emacs-tiny-tools.git
61 (add-to-list 'load-path '"~/lib/emacs_el/tiny-tools/lisp/tiny")
62 (add-to-list 'load-path '"~/lib/emacs_el/tiny-tools/lisp/other")
63 ;;(add-to-list 'Tex-style-path '"~/lib/emacs_el/auctex/")
64
65 (setq tinyprocmail--procmail-version "v3.22")
66 (add-hook 'tinyprocmail--load-hook 'tinyprocmail-install)
67 (require 'tinyprocmail)
68
69 (require 'tex-site)
70 ;;(require 'psvn)
71 (require 'cperl-mode)
72 ;;(require 'ecasound)
73 ;;(require 'emacs-wiki)
74 (require 'bibtex)
75 (require 'post)
76 ;;(require 'fixme)
77 (require 'google-weather)
78 (require 'org-google-weather)
79 (setq-default org-google-weather-format "%i %c, [%l,%h] %s %C")
80
81 ; org mode agenda files
82 (setq org-agenda-files
83       (quote ("~/projects/debbugs/debbugs.org"
84               "~/projects/notes/notes.org"
85               "~/projects/origins_of_life/ool.org"
86               "~/projects/sysadmin/sndservers/sndservers.org"
87               "~/projects/chaim/chaim.org"
88               "~/projects/fh/fh.org")))
89
90 (setq org-global-properties '(("Effort_ALL 0 0:10 0:30 1:00 2:00 3:00 4:00 5:00 6:00 7:00")))
91 (setq org-global-columns-default-format "%40ITEM(Task) %TAGS %PRIORITY %TODO %17Effort(Estimated Effort){:} %CLOCKSUM")
92
93 (setq org-default-notes-file "~/projects/notes/notes.org")
94 (setq org-capture-templates  ;; mail-specific note template, identified by "m"
95       '(("m" "Mail" entry (file+headline "~/projects/notes/refile.org" "Mail")
96          "* %?\n\n  Source: %u, %c\n  %i")
97         ("t" "todo" entry (file "~/projects/notes/refile.org")
98          "* TODO %?\n%U\n%a\n" :clock-in t :clock-resume t)
99         ("r" "respond" entry (file "~/projects/notes/refile.org")
100          "* NEXT Respond to %:from on %:subject\nSCHEDULED: %t\n%U\n%a\n" :clock-in t :clock-resume t :immediate-finish t)
101         ("n" "note" entry (file "~/projects/notes/refile.org")
102          "* %? :NOTE:\n%U\n%a\n" :clock-in t :clock-resume t)
103         ("j" "Journal" entry (file+datetree "~/projects/notes/diary.org")
104          "* %?\n%U\n" :clock-in t :clock-resume t)
105         ("w" "org-protocol" entry (file "~/projects/notes/refile.org")
106          "* TODO Review %c\n%U\n" :immediate-finish t)
107         ("p" "Phone call" entry (file "~/projects/notes/refile.org")
108          "* PHONE %? :PHONE:\n%U" :clock-in t :clock-resume t)
109         ("h" "Habit" entry (file "~/projects/notes/refile.org")
110          "* NEXT %?\n%U\n%a\nSCHEDULED: %(format-time-string \"<%Y-%m-%d %a .+1d/3d>\")\n:PROPERTIES:\n:STYLE: habit\n:REPEAT_TO_STATE: NEXT\n:END:\n")
111         )
112       )
113
114 ;; Remove empty LOGBOOK drawers on clock out
115 (defun bh/remove-empty-drawer-on-clock-out ()
116   (interactive)
117   (save-excursion
118     (beginning-of-line 0)
119     (org-remove-empty-drawer-at "LOGBOOK" (point))))
120
121 (add-hook 'org-clock-out-hook 'bh/remove-empty-drawer-on-clock-out 'append)
122
123
124 ; this is from http://doc.norang.ca/org-mode.html#Capture
125 ; use C-M-r for org mode capture
126 (global-set-key (kbd "C-M-r") 'org-capture)
127
128 ; Targets include this file and any file contributing to the agenda - up to 9 levels deep
129 (setq org-refile-targets (quote ((nil :maxlevel . 9)
130                                  (org-agenda-files :maxlevel . 9))))
131
132 ; Use full outline paths for refile targets - we file directly with IDO
133 (setq org-refile-use-outline-path t)
134
135 ; Targets complete directly with IDO
136 (setq org-outline-path-complete-in-steps nil)
137
138 ; Allow refile to create parent tasks with confirmation
139 (setq org-refile-allow-creating-parent-nodes (quote confirm))
140
141 ; Use IDO for both buffer and file completion and ido-everywhere to t
142 (setq org-completion-use-ido t)
143 (setq ido-everywhere t)
144 (setq ido-max-directory-size 100000)
145 (ido-mode (quote both))
146
147 ;;;; Refile settings
148 ; Exclude DONE state tasks from refile targets
149 (defun bh/verify-refile-target ()
150   "Exclude todo keywords with a done state from refile targets"
151   (not (member (nth 2 (org-heading-components)) org-done-keywords)))
152
153 (setq org-refile-target-verify-function 'bh/verify-refile-target)
154
155 ;; ensure that emacsclient will show just the note to be edited when invoked
156 ;; from Mutt, and that it will shut down emacsclient once finished;
157 ;; fallback to legacy behavior when not invoked via org-protocol.
158 (require 'org-protocol)
159 (add-hook 'org-capture-mode-hook 'delete-other-windows)
160 (setq my-org-protocol-flag nil)
161 (defadvice org-capture-finalize (after delete-frame-at-end activate)
162   "Delete frame at remember finalization"
163   (progn (if my-org-protocol-flag (delete-frame))
164          (setq my-org-protocol-flag nil)))
165 (defadvice org-capture-kill (after delete-frame-at-end activate)
166   "Delete frame at remember abort"
167   (progn (if my-org-protocol-flag (delete-frame))
168          (setq my-org-protocol-flag nil)))
169 (defadvice org-protocol-capture (before set-org-protocol-flag activate)
170   (setq my-org-protocol-flag t))
171
172
173 ; this comes from http://upsilon.cc/~zack/blog/posts/2010/02/integrating_Mutt_with_Org-mode/
174 (defun open-mail-in-mutt (message)
175   "Open a mail message in Mutt, using an external terminal.
176
177 Message can be specified either by a path pointing inside a
178 Maildir, or by Message-ID."
179   (interactive "MPath or Message-ID: ")
180   (shell-command
181    (format "xterm -e \"%s %s\""
182        (substitute-in-file-name "$HOME/bin/mutt_open") message)))
183
184 ;; add support for "mutt:ID" links
185 (org-add-link-type "mutt" 'open-mail-in-mutt)
186
187
188 (global-set-key "\C-xp" 'server-edit)
189
190 (setq-default auto-mode-alist (cons '("\.wml$" . 
191                               (lambda () (html-mode) (auto-fill-mode)))
192                             auto-mode-alist))
193
194 ;; Use c-mode for perl .xs files
195 (add-to-list 'auto-mode-alist '("\\.xs\\'" . c-mode))
196 (add-to-list 'auto-mode-alist '("\\.\\([pP][Llm]\\|al\\)\\'" . cperl-mode))
197 (add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))
198 (add-to-list 'interpreter-mode-alist '("perl5" . cperl-mode))
199 (add-to-list 'interpreter-mode-alist '("miniperl" . cperl-mode))
200
201 (add-to-list 'auto-mode-alist '("muttng-[a-z0-9]+-[0-9]+-" . post-mode))
202 (add-to-list 'auto-mode-alist '("muttngrc" . muttrc-mode))
203
204 (add-to-list 'auto-mode-alist '("mutt-[a-z0-9]+-[0-9]+-" . post-mode))
205 (add-to-list 'auto-mode-alist '("muttrc" . muttrc-mode))
206
207 (add-to-list 'auto-mode-alist '("\\.mdwn$" . markdown-mode))
208
209
210
211 (global-unset-key "\M-g")
212 (global-set-key "\M-g" 'goto-line)
213
214 ;;(autoload 'perl-mode "cperl-mode"
215 ;;  "alternate mode for editing Perl programs" t)
216
217 ;; self-insert-command hack.
218 ;;   Without this, "if<SP>" expands to
219 ;;   if ( -!-) {
220 ;;   }
221 ;;   which really should be,
222 ;;   if (-!-) {
223 ;;   }
224 (setq-default cperl-hairy t
225       cperl-indent-level 4
226 ;;      cperl-auto-newline t
227 ;;      cperl-auto-newline-after-colon t
228       cperl-continued-statement-offset 4
229       cperl-brace-offset -4
230       cperl-label-offset -4
231       cperl-highlight-variables-indiscriminately t
232       cperl-electric-lbrace-space nil
233       )
234 (add-hook 'cperl-mode-hook (lambda () (cperl-set-style "PerlStyle")))
235
236
237
238 ;(load-library "php-mode")
239
240 (setq-default c-indent-level 8)
241 (setq-default c-brace-imaginary-offset 0)
242 (setq-default c-brace-offset -8)
243 (setq-default c-argdecl-indent 8)
244 (setq-default c-label-offset -8)
245 (setq-default c-continued-statement-offset 8)
246 ; tabs are annoying
247 (setq-default indent-tabs-mode nil)
248 (setq-default tab-width 8)
249
250
251 ;; (autoload 'php-mode "php-mode" "PHP editing mode" t)
252 ;; (add-to-list 'auto-mode-alist '("\\.php3?\\'" . php-mode))
253 ;; (add-to-list 'auto-mode-alist '("\\.phtml?\\'" . php-mode))
254 ;; (add-to-list 'auto-mode-alist '("\\.php?\\'" . php-mode))
255 ;; (add-to-list 'auto-mode-alist '("\\.php4?\\'" . php-mode))
256
257 ;; REFTEX (much enhanced management of cross-ref, labels, etc)
258 ;; http://www.strw.leidenuniv.nl/~dominik/Tools/reftex/
259 (autoload 'reftex-mode     "reftex" "RefTeX Minor Mode" t)
260 (autoload 'turn-on-reftex  "reftex" "RefTeX Minor Mode" nil)
261 (autoload 'reftex-citation "reftex-cite" "Make citation" nil)
262 (autoload 'reftex-index-phrase-mode "reftex-index" "Phrase mode" t)
263 (add-hook 'LaTeX-mode-hook 'turn-on-reftex)   ; with AUCTeX LaTeX mode
264 (add-hook 'latex-mode-hook 'turn-on-reftex)   ; with Emacs latex mode
265 (add-hook 'LaTeX-mode-hook 'outline-minor-mode)   ; with AUCTeX LaTeX mode
266 (add-hook 'latex-mode-hook 'outline-minor-mode)   ; with Emacs latex mode
267
268 ;; (TeX-add-style-hook
269 ;;  "latex"
270 ;;  (lambda ()
271 ;;    (TeX-add-symbols
272 ;;     '("DLA" 1))))
273 ;; (custom-set-variables
274 ;;  '(font-latex-user-keyword-classes 
275 ;;    '(("fixme" 
276 ;;       ("DLA" "RZ")
277 ;;       font-lock-function-name-face 2 (command 1 t))))
278 ;; ) 
279
280 (require 'font-latex)
281 (add-to-list 'font-latex-match-reference-keywords "fref")
282 (add-to-list 'font-latex-match-reference-keywords "Fref")
283 (add-to-list 'font-latex-match-reference-keywords "citep")
284 (add-to-list 'font-latex-match-reference-keywords "citet")
285 (font-latex-match-reference-make)
286 (add-to-list 'font-latex-match-function-keywords "DLA")
287 (add-to-list 'font-latex-match-function-keywords "RZ")
288 (add-to-list 'font-latex-match-function-keywords "OM")
289 (add-to-list 'font-latex-match-function-keywords "DL")
290 (add-to-list 'font-latex-match-function-keywords "fixme")
291 (add-to-list 'font-latex-match-function-keywords "acs")
292 (add-to-list 'font-latex-match-function-keywords "acsp")
293 (add-to-list 'font-latex-match-function-keywords "ac")
294 (add-to-list 'font-latex-match-function-keywords "acp")
295 (add-to-list 'font-latex-match-function-keywords "acl")
296 (add-to-list 'font-latex-match-function-keywords "aclp")
297 (add-to-list 'font-latex-match-function-keywords "acsu")
298 (add-to-list 'font-latex-match-function-keywords "aclu")
299 (add-to-list 'font-latex-match-function-keywords "acused")
300 (font-latex-match-function-make)
301 (setq-default TeX-parse-self t)
302 (setq-default TeX-auto-save t)
303 (setq-default TeX-master nil)
304
305 (defun insert-date ()
306   "Insert date at point."
307   (interactive)
308   (insert (format-time-string "%A, %B %e, %Y %k:%M:%S %Z")))
309 (global-set-key "\C-[d" 'insert-date)
310
311 (defun unfill-paragraph (arg)
312   "Pull this whole paragraph up onto one line."
313   (interactive "*p")
314   (let ((fill-column 10000))
315     (fill-paragraph arg))
316   )
317
318 ;(iswitchb-default-keybindings)
319
320 (column-number-mode t)
321 (setq-default reftex-plug-into-AUCTeX t)
322
323 (server-start)
324
325 (require 'mode-compile)
326
327 (setq-default reftex-default-bibliography
328       '("references.bib"))
329
330 (defadvice server-process-filter (after post-mode-message first activate)
331   "If the buffer is in post mode, overwrite the server-edit
332     message with a post-save-current-buffer-and-exit message."
333   (if (eq major-mode 'post-mode)
334       (message
335        (substitute-command-keys "Type \\[describe-mode] for help composing; \\[post-save-current-buffer-and-exit] when done."))))
336                                         ; This is also needed to see the magic message.  Set to a higher
337                                         ; number if you have a faster computer or read slower than me.
338 '(font-lock-verbose 1000)
339 ;(setq-default server-temp-file-regexp "mutt\(-\|ng-\)")
340 ; (add-hook 'server-switch-hook 
341 ;         (function (lambda()
342 ;                     (cond ((string-match "Post" mode-name)
343 ;                            (post-goto-body)))
344 ;                     set-buffer-file-coding-system 'utf-8
345 ;                     )))
346
347
348 (add-hook 'post-mode-hook
349           (auto-fill-mode nil)
350           )
351
352 (fset 'insert-function-documentation
353    [?\C-x ?i home ?\C-k ?/ ?h ?o ?m ?e ?/ ?d ?o ?n ?/ ?l ?i ?b ?/ ?t ?e ?m ?p ?l ?a ?t ?e ?s ?/ ?p ?e ?r ?l ?_ ?f ?u ?n ?c ?t ?i ?o ?n ?_ ?d ?o ?c ?u ?m ?e ?n ?t ?a ?t ?i ?o ?n return])
354 (global-set-key "\M-f" 'insert-function-documentation)
355
356 (eval-after-load "lilypond-mode" 
357   '(progn
358      (load-library "lyqi-mode")
359      (define-key LilyPond-mode-map "\C-cq" 'lyqi-mode)))
360
361 (autoload 'spamassassin-mode "spamassassin-mode" nil t)
362
363 (desktop-load-default)
364 (desktop-read)
365 '(iswitchb-mode on)
366 (custom-set-faces
367   ;; custom-set-faces was added by Custom.
368   ;; If you edit it by hand, you could mess it up, so be careful.
369   ;; Your init file should contain only one such instance.
370   ;; If there is more than one, they won't work right.
371  '(menu ((((type x-toolkit)) (:background "black" :foreground "grey90")))))
372
373 (defun ess-change-directory (path)
374   "Set the current working directory to PATH for both *R* and Emacs."
375   (interactive "DDirectory to change to: ")
376
377   (when (file-exists-p path)
378     (ess-command (concat "setwd(\"" path "\")\n"))
379     ;; use file-name-as-directory to ensure it has trailing /
380     (setq default-directory (file-name-as-directory path))))
381
382 (put 'upcase-region 'disabled nil)
383 (put 'downcase-region 'disabled nil)
384 (put 'narrow-to-region 'disabled nil)
385
386 ;; The following lines are always needed. Choose your own keys.
387 (add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
388 (add-hook 'org-mode-hook 'turn-on-font-lock) ; not needed when global-font-lock-mode is on
389 (global-set-key "\C-cl" 'org-store-link)
390 (global-set-key "\C-ca" 'org-agenda)
391 (global-set-key "\C-cb" 'org-iswitchb)
392 (setq-default org-log-done 'time)
393 (setq-default org-agenda-ndays 5)
394
395
396 (autoload 'flyspell-mode "flyspell" "On-the-fly spelling checker." t)
397 (add-hook 'message-mode-hook 'turn-on-flyspell)
398 (add-hook 'text-mode-hook 'turn-on-flyspell)
399 (add-hook 'c-mode-common-hook 'flyspell-prog-mode)
400 (add-hook 'cperl-mode-hook 'flyspell-prog-mode)
401 (add-hook 'tcl-mode-hook 'flyspell-prog-mode)
402 (add-hook 'ess-mode-hook 'flyspell-prog-mode)
403 (defun turn-on-flyspell ()
404    "Force flyspell-mode on using a positive arg.  For use in hooks."
405    (interactive)
406    (flyspell-mode 1))
407
408 ;;; outlining support for ess modes
409 (add-hook 'ess-mode-hook
410           '(lambda ()
411              (outline-minor-mode)
412              (setq outline-regexp "\\(^#\\{4,5\\} \\)\\|\\(^[a-zA-Z0-9_\.]+ ?<- ?function(.*{\\)")
413              (defun outline-level
414                (lambda () (interactive) (cond ((looking-at "^##### ") 1)((looking-at "^#### ") 2)((looking-at "^[a-zA-Z0-9_\.]+ ?<- ?function(.*{") 3) (t 1000)))
415                )))
416
417  ; Outline-minor-mode key map
418  (define-prefix-command 'cm-map nil "Outline-")
419  ; HIDE
420  (define-key cm-map "q" 'hide-sublevels)    ; Hide everything but the top-level headings
421  (define-key cm-map "t" 'hide-body)         ; Hide everything but headings (all body lines)
422  (define-key cm-map "o" 'hide-other)        ; Hide other branches
423  (define-key cm-map "c" 'hide-entry)        ; Hide this entry's body
424  (define-key cm-map "l" 'hide-leaves)       ; Hide body lines in this entry and sub-entries
425  (define-key cm-map "d" 'hide-subtree)      ; Hide everything in this entry and sub-entries
426  ; SHOW
427  (define-key cm-map "a" 'show-all)          ; Show (expand) everything
428  (define-key cm-map "e" 'show-entry)        ; Show this heading's body
429  (define-key cm-map "i" 'show-children)     ; Show this heading's immediate child sub-headings
430  (define-key cm-map "k" 'show-branches)     ; Show all sub-headings under this heading
431  (define-key cm-map "s" 'show-subtree)      ; Show (expand) everything in this heading & below
432  ; MOVE
433  (define-key cm-map "u" 'outline-up-heading)                ; Up
434  (define-key cm-map "n" 'outline-next-visible-heading)      ; Next
435  (define-key cm-map "p" 'outline-previous-visible-heading)  ; Previous
436  (define-key cm-map "f" 'outline-forward-same-level)        ; Forward - same level
437  (define-key cm-map "b" 'outline-backward-same-level)       ; Backward - same level
438  (global-set-key "\M-o" cm-map)
439
440 (defun my-org-mode-setup ()
441  (when (and (buffer-file-name)
442             (file-exists-p (buffer-file-name)))
443   (load-library "reftex")
444   (and (buffer-file-name)
445         (file-exists-p (buffer-file-name))
446         (reftex-parse-all))
447    (reftex-set-cite-format
448      '((?b . "[[bib::%l]]")
449        (?n . "[[note::%l]]"))))
450    (define-key org-mode-map "\C-c\C-g" 'reftex-citation)
451 )
452 (add-hook 'org-mode-hook 'my-org-mode-setup)
453
454 (setq-default org-mobile-directory "/rzlab.ucr.edu:/sites/dav.donarmstrong.com/root/org/")
455 (setq-default org-directory "/home/don/org-mode/")
456 (setq-default org-mobile-inbox-for-pull "/home/don/org-mode/from-mobile.org")
457
458 ; debian stuff
459 (setq-default debian-changelog-mailing-address "don@debian.org")
460 (setq-default debian-changelog-full-name "Don Armstrong")
461
462 ; use iedit
463 (require 'iedit)
464 (define-key global-map (kbd "C-;") 'iedit-mode)
465 (global-set-key  (kbd "C-;") 'iedit-mode)
466
467 (require 'multi-web-mode)
468 (setq mweb-default-major-mode 'html-mode)
469 (setq mweb-tags '((php-mode "<\\?php\\|<\\? \\|<\\?=" "\\?>")
470                   (js-mode "<script +\\(type=\"text/javascript\"\\|language=\"javascript\"\\)[^>]*>" "</script>")
471                   (css-mode "<style +type=\"text/css\"[^>]*>" "</style>")))
472 (setq mweb-filename-extensions '("php" "htm" "html" "ctp" "phtml" "php4" "php5"))
473 (multi-web-global-mode 1)
474
475 ; clean-mode-line from http://www.masteringemacs.org/articles/2012/09/10/hiding-replacing-modeline-strings/
476 (defvar mode-line-cleaner-alist
477   `((auto-complete-mode . " α")
478     (yas/minor-mode . " υ")
479     (paredit-mode . " π")
480     (eldoc-mode . "")
481     (abbrev-mode . "")
482     (my-keys-minor-mode . "")
483     ;; Major modes
484     (lisp-interaction-mode . "λ")
485     (hi-lock-mode . "")
486     (python-mode . "Py")
487     (cperl-mode . "ρ")
488     (auctex-mode . "Lχ")
489     (org-agenda-mode . "øα")
490     (org-mode . "ø")
491     (emacs-lisp-mode . "EL")
492     (nxhtml-mode . "nx"))
493   "Alist for `clean-mode-line'.
494  
495 When you add a new element to the alist, keep in mind that you
496 must pass the correct minor/major mode symbol and a string you
497 want to use in the modeline *in lieu of* the original.")
498  
499  
500 (defun clean-mode-line ()
501   (interactive)
502   (loop for cleaner in mode-line-cleaner-alist
503         do (let* ((mode (car cleaner))
504                  (mode-str (cdr cleaner))
505                  (old-mode-str (cdr (assq mode minor-mode-alist))))
506              (when old-mode-str
507                  (setcar old-mode-str mode-str))
508                ;; major mode
509              (when (eq mode major-mode)
510                (setq mode-name mode-str)))))
511  
512  
513 (add-hook 'after-change-major-mode-hook 'clean-mode-line)
514  
515 ;;; alias the new `flymake-report-status-slim' to
516 ;;; `flymake-report-status'
517 (defalias 'flymake-report-status 'flymake-report-status-slim)
518 (defun flymake-report-status-slim (e-w &optional status)
519   "Show \"slim\" flymake status in mode line."
520   (when e-w
521     (setq flymake-mode-line-e-w e-w))
522   (when status
523     (setq flymake-mode-line-status status))
524   (let* ((mode-line " Φ"))
525     (when (> (length flymake-mode-line-e-w) 0)
526       (setq mode-line (concat mode-line ":" flymake-mode-line-e-w)))
527     (setq mode-line (concat mode-line flymake-mode-line-status))
528     (setq flymake-mode-line mode-line)
529     (force-mode-line-update)))
530
531 ; apparently things like to step on C-;, so we'll use a hack from
532 ; http://stackoverflow.com/questions/683425/globally-override-key-binding-in-emacs/5340797#5340797 to fix this
533
534 (defvar my-keys-minor-mode-map (make-keymap) "my-keys-minor-mode keymap.")
535
536 ; use iedit everywhere
537 (define-key my-keys-minor-mode-map (kbd "C-;") 'iedit-mode)
538
539 (define-minor-mode my-keys-minor-mode
540   "A minor mode so that my key settings override annoying major modes."
541   t " my-keys" 'my-keys-minor-mode-map)
542
543 (my-keys-minor-mode 1)
544 (defun my-minibuffer-setup-hook ()
545   (my-keys-minor-mode 0))
546
547 (add-hook 'minibuffer-setup-hook 'my-minibuffer-setup-hook)
548 (defadvice load (after give-my-keybindings-priority)
549   "Try to ensure that my keybindings always have priority."
550   (if (not (eq (car (car minor-mode-map-alist)) 'my-keys-minor-mode))
551       (let ((mykeys (assq 'my-keys-minor-mode minor-mode-map-alist)))
552         (assq-delete-all 'my-keys-minor-mode minor-mode-map-alist)
553         (add-to-list 'minor-mode-map-alist mykeys))))
554 (ad-activate 'load)