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