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