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