]> git.donarmstrong.com Git - org-ref.git/blob - org-ref-init.el
hydra menus for bibtex entries
[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 (require 'cl)
34
35 ;; org path for loadable org-files
36 (defvar org-ref-org-load-path
37   nil
38   "List of directories to find org-files that `org-babel-load-file' can load code from.")
39
40 ;; https://github.com/jkitchin/org-ref
41 (defun org-ref-org-require (feature)
42   "Load a FEATURE from an org-file.
43 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'."
44   (let ((org-file (concat (symbol-name feature) ".org"))
45         (path))
46
47     ;; find the org-file
48     (catch 'result
49       (loop for dir in org-ref-org-load-path do
50             (when (file-exists-p
51                    (setq path
52                          (expand-file-name
53                           org-file
54                           dir)))
55               (throw 'result path))))
56     (let ((default-directory (file-name-directory path)))
57       (org-babel-load-file path))))
58
59 ;; remember this directory
60 (defconst org-ref-dir (file-name-directory (or load-file-name
61                                                (buffer-file-name)))
62     "Directory where org-ref is installed.")
63
64 ;; for loading org-files
65 (add-to-list 'org-ref-org-load-path org-ref-dir)
66 ;; for loading emacs-lisp files
67 (add-to-list 'load-path org-ref-dir)
68
69 (org-ref-org-require 'org-ref)
70 (org-ref-org-require 'doi-utils)
71 (org-ref-org-require 'pubmed)
72 (require 'jmax-bibtex)
73
74 (provide 'org-ref-init)
75
76 ;;; org-ref-init.el ends here