-(defun my-org-mode-setup ()
- (load-library "reftex")
- (and (buffer-file-name)
- (file-exists-p (buffer-file-name))
- (progn
- (reftex-parse-all)
- (reftex-set-cite-format
- '((?b . "[[bib::%l][%l-bib]]")
- (?n . "[[note::%l][%l-notes]]")
- (?c . "\\cite{%l}")
- (?h . "*** %t\n:PROPERTIES:\n:Custom_ID: %l\n:END:\n[[papers:%l][%l paper]]")))
- ))
- (define-key org-mode-map (kbd "C-c )") 'reftex-citation)
- (define-key org-mode-map (kbd "C-c [") 'reftex-citation)
- (define-key org-mode-map (kbd "C-c (") 'org-mode-reftex-search)
- (define-key org-mode-map (kbd "C-c 0") 'reftex-view-crossref)
- )
-(add-hook 'org-mode-hook 'my-org-mode-setup)
-
-(defun org-mode-reftex-search ()
- (interactive)
- (org-open-link-from-string (format "[[notes:%s]]" (reftex-citation t))))
-
-(defun open-research-paper (bibtexkey)
- "Open a paper by bibtex key"
- (interactive "bibtex key: ")
- (shell-command
- (format "%s %s"
- (substitute-in-file-name "$HOME/bin/bibtex_to_paper") bibtexkey)))
-(org-add-link-type "papers" 'open-research-paper)
-
-
-;; stolen from
-;; http://www-public.it-sudparis.eu/~berger_o/weblog/2012/03/23/how-to-manage-and-export-bibliographic-notesrefs-in-org-mode/
-(defun my-rtcite-export-handler (path desc format)
- (message "my-rtcite-export-handler is called : path = %s, desc = %s, format = %s" path desc format)
- (let* ((search (when (string-match "::#?\\(.+\\)\\'" path)
- (match-string 1 path)))
- (path (substring path 0 (match-beginning 0))))
- (cond ((eq format 'latex)
- (if (or (not desc)
- (equal 0 (search "rtcite:" desc)))
- (format "\\cite{%s}" search)
- (format "\\cite[%s]{%s}" desc search))))))
-
-(org-add-link-type "rtcite"
- 'org-bibtex-open
- 'my-rtcite-export-handler)
-
-
-(setq-default org-mobile-directory "/rzlab.ucr.edu:/sites/dav.donarmstrong.com/root/org/")
-(setq-default org-directory "/home/don/org-mode/")
-(setq-default org-mobile-inbox-for-pull "/home/don/org-mode/from-mobile.org")
-
-;; org mode ical export
-(setq org-icalendar-timezone "America/Los_Angeles")
-(setq org-icalendar-use-scheduled '(todo-start event-if-todo))
-(setq org-icalendar-store-UID t)
-
-;; org babel support
-(org-babel-do-load-languages
- 'org-babel-load-languages
- '((emacs-lisp . t )
- (R . t)
- (latex . t)))
-;; org-babel-by-backend
-(defmacro org-babel-by-backend (&rest body)
- `(case (if (boundp 'backend)
- (org-export-backend-name backend)
- nil) ,@body))
-
-
-
-;; org latex
-;; stolen from http://kieranhealy.org/esk/kjhealy.html
-(require 'org-latex)
-;; Choose either listings or minted for exporting source code blocks.
-;; Using minted (as here) requires pygments be installed. To use the
-;; default listings package instead, use
-;; (setq org-latex-listings t)
-;; and change references to "minted" below to "listings"
-; (setq org-latex-listings 'minted)
-
-;; default settings for minted code blocks
-(setq org-latex-minted-options
- '(;("frame" "single")
- ("bgcolor" "bg") ; bg will need to be defined in the preamble of your document. It's defined in org-preamble-pdflatex.sty and org-preamble-xelatex.sty below.
- ("fontsize" "\\small")
- ))
-;; turn off the default toc behavior; deal with it properly in headers to files.
-(defun org-latex-no-toc (depth)
- (when depth
- (format "%% Org-mode is exporting headings to %s levels.\n"
- depth)))
-(setq org-latex-format-toc-function 'org-latex-no-toc)
-
-(require 'ox-latex)
-(add-to-list 'org-latex-classes
- '("memarticle"
- "\\documentclass[11pt,oneside,article]{memoir}\n"
- ("\\section{%s}" . "\\section*{%s}")
- ("\\subsection{%s}" . "\\subsection*{%s}")
- ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
- ("\\paragraph{%s}" . "\\paragraph*{%s}")
- ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
-
-(add-to-list 'org-latex-classes
- '("membook"
- "\\documentclass[11pt,oneside]{memoir}\n"
- ("\\chapter{%s}" . "\\chapter*{%s}")
- ("\\section{%s}" . "\\section*{%s}")
- ("\\subsection{%s}" . "\\subsection*{%s}")
- ("\\subsubsection{%s}" . "\\subsubsection*{%s}")))
-
-(add-to-list 'org-latex-classes
- '("letter"
- "\\documentclass[11pt]{letter}"
- ("\\section{%s}" . "\\section*{%s}")
- ("\\subsection{%s}" . "\\subsection*{%s}")
- ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
- ("\\paragraph{%s}" . "\\paragraph*{%s}")
- ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
-
-;; Originally taken from Bruno Tavernier: http://thread.gmane.org/gmane.emacs.orgmode/31150/focus=31432
-;; but adapted to use latexmk 4.22 or higher.
-(setq org-latex-pdf-process '("latexmk -pdflatex=xelatex -bibtex -use-make -pdf %f"))
-
-;; Default packages included in /every/ tex file, latex, pdflatex or xelatex
-(setq org-latex-default-packages-alist
- '())
-(setq org-latex-packages-alist
- '(("" "graphicx" t)
- ("" "fontspec" t)
- ("" "xunicode" t)
- ("" "hyperref" t)
- ("" "url" t)
- ("" "rotating" t)
- ("" "longtable" nil)
- ("" "float" )))
-
-(defun org-create-formula--latex-header ()
- "Return LaTeX header appropriate for previewing a LaTeX snippet."
- (let ((info (org-combine-plists (org-export--get-global-options
- (org-export-get-backend 'latex))
- (org-export--get-inbuffer-options
- (org-export-get-backend 'latex)))))
- (org-latex-guess-babel-language
- (org-latex-guess-inputenc
- (org-splice-latex-header
- org-format-latex-header
- org-latex-default-packages-alist
- nil t
- (plist-get info :latex-header)))
- info)))
-
-
-; support ignoring headers in org mode export to latex
-; from http://article.gmane.org/gmane.emacs.orgmode/67692
-(defadvice org-latex-headline (around my-latex-skip-headlines
- (headline contents info) activate)
- (if (member "ignoreheading" (org-element-property :tags headline))
- (setq ad-return-value contents)
- ad-do-it))