]> git.donarmstrong.com Git - org-ref.git/blob - org-ref-init.el
Merge branch 'master' of https://github.com/OlafMerkert/org-ref into OlafMerkert...
[org-ref.git] / org-ref-init.el
1 ;;; org-ref-init.el --- setup bibliography, cite, ref and label org-mode links.
2
3 ;; Copyright(C) 2014 John Kitchin
4
5 ;; Author: John Kitchin <jkitchin@andrew.cmu.edu>
6 ;; This file is not currently part of GNU Emacs.
7
8 ;; This program is free software; you can redistribute it and/or
9 ;; modify it under the terms of the GNU General Public License as
10 ;; published by the Free Software Foundation; either version 2, or (at
11 ;; your option) any later version.
12
13 ;; This program is distributed in the hope that it will be useful, but
14 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 ;; General Public License for more details.
17
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with this program ; see the file COPYING.  If not, write to
20 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 ;; Boston, MA 02111-1307, USA.
22
23 ;;; Version: 0.1
24
25 ;;; Commentary:
26 ;;
27 ;; Lisp code to setup bibliography cite, ref and label org-mode links.
28 ;; also sets up reftex and helm for org-mode citations. The links are
29 ;; clickable and do things that are useful. You should really read
30 ;; org-ref.org for details.
31 ;;
32 ;; Package-Requires: ((dash) (helm) (helm-bibtex))
33
34 ;; org path for loadable org-files
35 (defvar org-ref-org-load-path
36   nil
37   "List of directories to find org-files that `org-babel-load-file' can load code from.")
38
39 ;; https://github.com/jkitchin/org-ref
40 (defun org-ref-org-require (feature)
41   "Load a FEATURE from an org-file.
42 FEATURE is a symbol, and it is loaded from an org-file by the name of FEATURE.org, that is in the `org-load-path'.  The FEATURE is loaded from `org-babel-load-file'."
43   (let ((org-file (concat (symbol-name feature) ".org"))
44         (path))
45
46     ;; find the org-file
47     (catch 'result
48       (loop for dir in org-ref-org-load-path do
49             (when (file-exists-p
50                    (setq path
51                          (expand-file-name
52                           org-file
53                           dir)))
54               (throw 'result path))))
55     (let ((default-directory (file-name-directory path)))
56       (org-babel-load-file path))))
57
58 ;; remember this directory
59 (defconst org-ref-dir (file-name-directory (or load-file-name
60                                                (buffer-file-name)))
61     "Directory where org-ref is installed.")
62
63 ;; for loading org-files
64 (add-to-list 'org-ref-org-load-path org-ref-dir)
65 ;; for loading emacs-lisp files
66 (add-to-list 'load-path org-ref-dir)
67
68 (org-ref-org-require 'org-ref)
69 (org-ref-org-require 'doi-utils)
70 (org-ref-org-require 'pubmed)
71 (require 'jmax-bibtex)
72
73 (provide 'org-ref-init)
74
75 ;;; org-ref-init.el ends here