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