]> git.donarmstrong.com Git - org-ref.git/blobdiff - org-ref.org
add html output
[org-ref.git] / org-ref.org
index 62e9804063331dbce20da913f39b412f6f265c76..fd9e3d65fd425b68d15e4cb3b08171f9d3bc00a7 100644 (file)
@@ -92,10 +92,28 @@ There are some variables needed later to tell this library where you store your
   :group 'org-ref)
 
 (defcustom org-ref-bibliography-entry-format
-  "%a, %t, <i>%j</i>, <b>%v(%n)</b>, %p (%y). <a href=\"%U\">link</a>. <a href=\"http://dx.doi.org/%D\">doi</a>."
-  "string to format an entry. Just the reference, no numbering at the beginning, etc..."
+  '(("article" . "%a, %t, <i>%j</i>, <b>%v(%n)</b>, %p (%y). <a href=\"%U\">link</a>. <a href=\"http://dx.doi.org/%D\">doi</a>.")
+
+    ("book" . "%a, %t, %u (%y).")
+
+    ("proceedings" . "%e, %t in %S, %u (%y).")
+
+    ("inproceedings" . "%a, %t, %p, in %b, edited by %e, %u (%y)"))
+
+  "string to format an entry. Just the reference, no numbering at the beginning, etc... see the `org-ref-reftex-format-citation' docstring for the escape codes."
   :type 'string
   :group 'org-ref)
+
+(defcustom org-ref-open-notes-function
+  (lambda ()
+    (org-show-entry)
+    (show-branches)
+    (show-children)
+    (org-cycle '(64))
+    ;;(org-tree-to-indirect-buffer)
+    (outline-previous-visible-heading 1)
+    (recenter-top-bottom 0))
+  "User-defined way to open a notes entry. This is excecuted after the entry is found, with the cursor at the beginning of the headline. The default setting fully expands the notes, and moves the headline to the top of the buffer") 
 #+END_SRC
 
 This next variable determines the citation types that are available in org-ref. Links for each one are automatically generated, and completion functions are automatically generated. Users may add to this list in their own init files.
@@ -133,6 +151,8 @@ This next variable determines the citation types that are available in org-ref.
     "footcites" "footcitetexts"
     "smartcites" "Smartcites" "textcites" "Textcites"
     "supercites" "autocites" "Autocites"
+    ;; for the bibentry package
+    "bibentry"
     )
   "List of citation types known in org-ref"
   :type '(repeat :tag "List of citation types" string)
@@ -159,12 +179,16 @@ We need a hook variable to store user-defined bibtex entry cleaning functions
 We setup reftex here. We use a custom insert cite link function defined here: [[*org-ref-insert-cite-link][org-ref-insert-cite-link]]. We setup reftex to use our org citation format.
 
 #+BEGIN_SRC emacs-lisp  :tangle org-ref.el
+(require 'reftex)
 (defun org-mode-reftex-setup ()
-    (load-library "reftex")
     (and (buffer-file-name)
          (file-exists-p (buffer-file-name))
         (global-auto-revert-mode t)
-         (reftex-parse-all))
+        ;; I do not remember why I put this next line in. It doesn't
+        ;; work for org-files. Nothing very bad happens, but it gives
+        ;; an annoying error. Commenting it out for now.
+         ;(reftex-parse-all)
+        )
     (make-local-variable 'reftex-cite-format)
     (setq reftex-cite-format 'org)
     (define-key org-mode-map (kbd org-ref-insert-cite-key) 'org-ref-insert-cite-link))
@@ -263,6 +287,7 @@ It is also possible to access all other BibTeX database fields:
 %B booktitle, abbreviated          %T title, abbreviated
 %U url
 %D doi
+%S series
 
 Usually, only %l is needed.  The other stuff is mainly for the echo area
 display, and for (setq reftex-comment-citations t).
@@ -324,6 +349,7 @@ environment, only %l is available."
                                (org-ref-reftex-get-bib-field "pages" entry)
                                "[- .]+")))
                ((= l ?s) (org-ref-reftex-get-bib-field "school" entry))
+               ((= l ?S) (org-ref-reftex-get-bib-field "series" entry))
                ((= l ?u) (org-ref-reftex-get-bib-field "publisher" entry))
                ((= l ?U) (org-ref-reftex-get-bib-field "url" entry))
                ((= l ?r) (org-ref-reftex-get-bib-field "address" entry))
@@ -347,10 +373,10 @@ environment, only %l is available."
   format)
 
 (defun org-ref-get-bibtex-entry-citation (key)
-  "returns a string for the bibliography entry corresponding to key, and formatted according to `org-ref-bibliography-entry-format'"
+  "returns a string for the bibliography entry corresponding to key, and formatted according to the type in `org-ref-bibliography-entry-format'"
 
   (let ((org-ref-bibliography-files (org-ref-find-bibliography))
-       (file) (entry))
+       (file) (entry) (bibtex-entry) (entry-type) (format))
 
     (setq file (catch 'result
                 (loop for file in org-ref-bibliography-files do
@@ -361,7 +387,14 @@ environment, only %l is available."
     (with-temp-buffer
       (insert-file-contents file)
       (bibtex-search-entry key nil 0)
-      (setq entry  (org-ref-reftex-format-citation (bibtex-parse-entry) org-ref-bibliography-entry-format)))
+      (setq bibtex-entry (bibtex-parse-entry))
+      (setq entry-type (downcase (cdr (assoc "=type=" bibtex-entry))))
+      (setq format (cdr (assoc entry-type org-ref-bibliography-entry-format)))
+      (if format
+         (setq entry  (org-ref-reftex-format-citation bibtex-entry format))
+       (save-restriction
+         (bibtex-narrow-to-entry)
+         (setq entry (buffer-string)))))      
     entry))
 #+END_SRC
 
@@ -379,7 +412,7 @@ Here is how to use the function. You call it with point in an entry in a bibtex
 
 I am not sure why full author names are not used.
 
-This code provides some functions to generate a simple sorted bibliography in html. First we get all the keys in the bufer.
+This code provides some functions to generate a simple sorted bibliography in html. First we get all the keys in the buffer.
 
 #+BEGIN_SRC emacs-lisp :tangle org-ref.el
 (defun org-ref-get-bibtex-keys ()
@@ -423,6 +456,79 @@ Now, we map over the whole list of keys, and the whole bibliography, formatted a
 
 I do not have plans to make a numbered bibliography with numbered citations anytime soon. This will require changing the way the citation links are exported, and keeping track of the numbers.
 
+*** An org bibliography
+You can export an org-file to an org-file or org-buffer (org-org-epxort-as-org). In this case, it would be useful convert the cite links to links to custom_ids, and the bibliography link to a first-level heading Bibliography with org-bibtex like headings for each entry. This code should enable this. Right now, it does not appear to work for org export though.
+
+First, we get the string for a single entry.
+#+BEGIN_SRC emacs-lisp :tangle org-ref.el
+(defun org-ref-get-bibtex-entry-org (key)
+  "returns an org string for the bibliography entry corresponding to key"
+  (let ((org-ref-bibliography-files (org-ref-find-bibliography))
+       (file) (entry) (bibtex-entry) (entry-type) (format))
+
+    (setq file (catch 'result
+                (loop for file in org-ref-bibliography-files do
+                      (if (org-ref-key-in-file-p key (file-truename file)) 
+                          (throw 'result file)
+                        (message "%s not found in %s" key (file-truename file))))))
+
+    (with-temp-buffer
+      (insert-file-contents file)
+      (bibtex-search-entry key nil 0)
+      (setq entry (bibtex-parse-entry))
+      (format "** %s - %s
+  :PROPERTIES:
+  %s
+  :END:
+" (org-ref-reftex-get-bib-field "author" entry)
+(org-ref-reftex-get-bib-field "title" entry)
+(concat "   :CUSTOM_ID: " (org-ref-reftex-get-bib-field "=key=" entry) "\n"
+       (mapconcat (lambda (element) (format "   :%s: %s"
+                                            (upcase (car element))
+                                            (cdr element)))
+                  entry
+                  "\n"))))))
+#+END_SRC
+
+Now, we loop over the keys, and combine all the entries into a bibliography.
+#+BEGIN_SRC emacs-lisp :tangle org-ref.el 
+(defun org-ref-get-org-bibliography ()
+  "Create an org bibliography when there are keys"
+  (let ((keys (org-ref-get-bibtex-keys)))
+    (when keys
+      (concat "* Bibliography
+"
+             (mapconcat (lambda (x) (org-ref-get-bibtex-entry-org x)) keys "\n")
+             "\n"))))
+#+END_SRC
+
+*** An ascii bibliography
+
+This function gets the html for one entry.
+
+#+BEGIN_SRC emacs-lisp :tangle org-ref.el
+(defun org-ref-get-bibtex-entry-ascii (key)
+  "returns an ascii string for the bibliography entry corresponding to key"
+
+  (format "[%s] %s" key (org-ref-get-bibtex-entry-citation key)))
+#+END_SRC
+
+Now, we map over the whole list of keys, and the whole bibliography, formatted as an unordered list.
+
+#+BEGIN_SRC emacs-lisp :tangle org-ref.el 
+(defun org-ref-get-ascii-bibliography ()
+  "Create an html bibliography when there are keys"
+  (let ((keys (org-ref-get-bibtex-keys)))
+    (when keys
+      (concat 
+"Bibliography
+=============
+"
+             (mapconcat (lambda (x) (org-ref-get-bibtex-entry-ascii x)) keys "\n")
+             "\n"))))
+#+END_SRC
+
+
 *** the links
 We use a link for the bibliography so that we can click on it to open the bibliography file. The link may have more than one bibliography file in it, separated by commas. Clicking opens the file under the cursor. The bibliographies should be full filenames with the bib extension. Clicking on this link makes reftex-default-bibliography local and sets it to the list of files in the link. We need this to use reftex's searching capability.
 
@@ -474,10 +580,93 @@ We use a link for the bibliography so that we can click on it to open the biblio
                     ;; formatting code
                   (lambda (keyword desc format)
                     (cond
+                     ((eq format 'org) (org-ref-get-org-bibliography))
+                      ((eq format 'ascii) (org-ref-get-ascii-bibliography))
                      ((eq format 'html) (org-ref-get-html-bibliography))
                      ((eq format 'latex)
-                        ;; write out the latex bibliography command
-                      (format "\\bibliography{%s}" (replace-regexp-in-string  "\\.bib" "" keyword))))))
+                      ;; write out the latex bibliography command                     
+                      (format "\\bibliography{%s}" (replace-regexp-in-string  "\\.bib" "" (mapconcat 'identity
+                                                                                                     (mapcar 'expand-file-name
+                                                                                                             (split-string keyword ","))
+                                                                                                     ",")))))))
+                                                                              
+#+END_SRC
+
+Believe it or not, sometimes it makes sense /not/ to include the bibliography in a document (e.g. when you are required to submit references as a separate file). To generate the references,  in another file, you must make a little tex file with these contents, and then compile it.
+
+#+BEGIN_LaTeX
+  \input{project-description.bbl}
+#+END_LaTeX
+
+Here, we make a =nobibliography= link that acts like the bibliography, enables creation of the bbl file, but does not put an actual bibliography in the file.
+
+#+BEGIN_SRC emacs-lisp :tangle org-ref.el
+(org-add-link-type "nobibliography"
+                  ;; this code is run on clicking. The bibliography
+                  ;; may contain multiple files. this code finds the
+                  ;; one you clicked on and opens it.
+                  (lambda (link-string)        
+                      ;; get link-string boundaries
+                      ;; we have to go to the beginning of the line, and then search forward
+                      
+                    (let* ((bibfile)
+                           ;; object is the link you clicked on
+                           (object (org-element-context))
+                           (link-string-beginning) 
+                           (link-string-end))
+
+                    (save-excursion
+                      (goto-char (org-element-property :begin object))
+                      (search-forward link-string nil nil 1)
+                      (setq link-string-beginning (match-beginning 0))
+                      (setq link-string-end (match-end 0)))
+
+                      ;; We set the reftex-default-bibliography
+                      ;; here. it should be a local variable only in
+                      ;; the current buffer. We need this for using
+                      ;; reftex to do citations.
+                      (set (make-local-variable 'reftex-default-bibliography) 
+                           (split-string (org-element-property :path object) ","))
+
+                      ;; now if we have comma separated bibliographies
+                      ;; we find the one clicked on. we want to
+                      ;; search forward to next comma from point
+                      (save-excursion
+                        (if (search-forward "," link-string-end 1 1)
+                            (setq key-end (- (match-end 0) 1)) ; we found a match
+                          (setq key-end (point)))) ; no comma found so take the point
+                      ;; and backward to previous comma from point
+                      (save-excursion
+                        (if (search-backward "," link-string-beginning 1 1)
+                            (setq key-beginning (+ (match-beginning 0) 1)) ; we found a match
+                          (setq key-beginning (point)))) ; no match found
+                      ;; save the key we clicked on.
+                      (setq bibfile (org-ref-strip-string (buffer-substring key-beginning key-end)))
+                      (find-file bibfile))) ; open file on click
+
+                    ;; formatting code
+                  (lambda (keyword desc format)
+                    (cond
+                     ((eq format 'org) (org-ref-get-org-bibliography))
+                      ((eq format 'ascii) (org-ref-get-ascii-bibliography))
+                     ((eq format 'html) (org-ref-get-html-bibliography))
+                     ((eq format 'latex)
+                      ;; write out the latex bibliography command                     
+
+;                     (format "{\\setbox0\\vbox{\\bibliography{%s}}}"
+;                             (replace-regexp-in-string  "\\.bib" "" (mapconcat 'identity
+;                                                                               (mapcar 'expand-file-name
+;                                                                                       (split-string keyword ","))
+;                                                                               ",")))
+
+                      (format "\\nobibliography{%s}"
+                              (replace-regexp-in-string  "\\.bib" "" (mapconcat 'identity
+                                                                                (mapcar 'expand-file-name
+                                                                                        (split-string keyword ","))
+                                                                                ",")))
+
+                      ))))                                                                            
 #+END_SRC
 
 #+BEGIN_SRC emacs-lisp :tangle org-ref.el
@@ -485,10 +674,12 @@ We use a link for the bibliography so that we can click on it to open the biblio
                   (lambda (arg) (message "Nothing implemented for clicking here."))
                   (lambda (keyword desc format)
                     (cond
+                      ((eq format 'org) (org-ref-get-org-bibliography))
                       ((eq format 'html) (org-ref-get-html-bibliography))
                      ((eq format 'latex)
-                      ;; write out the latex bibliography command
-                      (format "\\printbibliography" keyword)))))
+                      ;; write out the biblatex bibliography command
+                      "\\printbibliography"))
+))
 #+END_SRC
 
 We also create a bibliographystyle link. There is nothing to do on clicking here, and we create it for consistency. This sets the style for latex export, so use something appropriate there, e.g. unsrt, plain, plainnat, ...
@@ -777,6 +968,7 @@ At the moment, ref links are not usable for section links. You need [[#CUSTOM_ID
      ;; we did not find anything, so go back to where we came
      (org-mark-ring-goto)
      (error "%s not found" label))
+   (org-show-entry)
    (message "go back with (org-mark-ring-goto) `C-c &`"))
  ;formatting
  (lambda (keyword desc format)
@@ -786,7 +978,18 @@ At the moment, ref links are not usable for section links. You need [[#CUSTOM_ID
      (format "\\ref{%s}" keyword)))))
 #+END_SRC
 
-It would be nice to use completion to enter a ref link, where a list of labels is provided. The following code searches the buffer for labels, custom_ids, and table names as potential items to make a ref link to.
+It would be nice to use completion to enter a ref link, where a list of labels is provided. The following code searches the buffer for org and latex labels, custom_ids, and table names as potential items to make a ref link to.
+
+#+BEGIN_SRC emacs-lisp :tangle org-ref.el
+(defun org-ref-get-org-labels ()
+ "find #+LABEL: labels"
+  (save-excursion
+    (goto-char (point-min))
+    (let ((matches '()))
+      (while (re-search-forward "^#\\+label:\\s-+\\(.*\\)\\b" (point-max) t)
+       (add-to-list 'matches (match-string-no-properties 1) t))
+matches)))
+#+END_SRC
 
 #+BEGIN_SRC emacs-lisp :tangle org-ref.el
 (defun org-ref-get-custom-ids ()
@@ -803,7 +1006,7 @@ results))
 Here we get a list of the labels defined as raw latex labels, e.g. \label{eqtre}.
 #+BEGIN_SRC emacs-lisp :tangle org-ref.el
 (defun org-ref-get-latex-labels ()
-(save-excursion
+  (save-excursion
     (goto-char (point-min))
     (let ((matches '()))
       (while (re-search-forward "\\\\label{\\([a-zA-z0-9:-]*\\)}" (point-max) t)
@@ -832,7 +1035,7 @@ Now, we can put all the labels together which will give us a list of candidates.
       (let ((matches '()))
        (while (re-search-forward "label:\\([a-zA-z0-9:-]*\\)" (point-max) t)
          (add-to-list 'matches (match-string-no-properties 1) t))
-       (append matches (org-ref-get-latex-labels) (org-ref-get-tblnames) (org-ref-get-custom-ids))))))
+       (append matches (org-ref-get-org-labels) (org-ref-get-latex-labels) (org-ref-get-tblnames) (org-ref-get-custom-ids))))))
 #+END_SRC
 
 Now we create the completion function. This works from the org-machinery, e.g. if you type C-c C-l to insert a link, and use completion by pressing tab.
@@ -985,7 +1188,6 @@ This is just the LaTeX ref for equations. On export, the reference is enclosed i
      (format "\\eqref{%s}" keyword)))))
 #+END_SRC
 
-
 ** cite
 This is the main reason this library exists. We want the following behavior. A cite link should be able to contain multiple bibtex keys. You should be able to click on the link, and get a brief citation of the entry for that key, and a menu of options to open the bibtex file, open a pdf if you have it, open your notes on the entry, or open a url if it exists. You should be able to insert new references onto an existing cite link, or create new ones easily. The following code implements these features.
 
@@ -1002,30 +1204,43 @@ to get a comma, or the beginning of the link. that delimits the
 keyword we clicked on. We also strip the text properties."
   (interactive)
   (let* ((object (org-element-context))         
-        (link-string (org-element-property :path object)))    
-    
-    ;; we need the link path start and end
-    (save-excursion
+        (link-string (org-element-property :path object)))
+    ;; you may click on the part before the citations. here we make
+    ;; sure to move to the beginning so you get the first citation.
+    (let ((cp (point)))
       (goto-char (org-element-property :begin object))
-      (search-forward link-string nil nil 1)
-      (setq link-string-beginning (match-beginning 0))
-      (setq link-string-end (match-end 0)))
+      (search-forward link-string (org-element-property :end object))
+      (goto-char (match-beginning 0))
+      ;; check if we clicked before the path and move as needed.
+      (unless (< cp (point))
+       (goto-char cp)))
+       
+    (if (not (org-element-property :contents-begin object))
+       ;; this means no description in the link
+       (progn    
+         ;; we need the link path start and end
+         (save-excursion
+           (goto-char (org-element-property :begin object))
+           (search-forward link-string nil nil 1)
+           (setq link-string-beginning (match-beginning 0))
+           (setq link-string-end (match-end 0)))
 
-    ;; The key is the text between commas, or the link boundaries
-    (save-excursion
-      (if (search-forward "," link-string-end t 1)
-         (setq key-end (- (match-end 0) 1)) ; we found a match
-       (setq key-end link-string-end))) ; no comma found so take the end
-    ;; and backward to previous comma from point which defines the start character
-    (save-excursion
-      (if (search-backward "," link-string-beginning 1 1)
-         (setq key-beginning (+ (match-beginning 0) 1)) ; we found a match
-       (setq key-beginning link-string-beginning))) ; no match found
-    ;; save the key we clicked on.
-    (setq bibtex-key (org-ref-strip-string (buffer-substring key-beginning key-end)))
-    (set-text-properties 0 (length bibtex-key) nil bibtex-key)
-    bibtex-key
-    ))
+         ;; The key is the text between commas, or the link boundaries
+         (save-excursion
+           (if (search-forward "," link-string-end t 1)
+               (setq key-end (- (match-end 0) 1)) ; we found a match
+             (setq key-end link-string-end))) ; no comma found so take the end
+         ;; and backward to previous comma from point which defines the start character
+         (save-excursion
+           (if (search-backward "," link-string-beginning 1 1)
+               (setq key-beginning (+ (match-beginning 0) 1)) ; we found a match
+             (setq key-beginning link-string-beginning))) ; no match found
+         ;; save the key we clicked on.
+         (setq bibtex-key (org-ref-strip-string (buffer-substring key-beginning key-end)))
+         (set-text-properties 0 (length bibtex-key) nil bibtex-key)
+         bibtex-key)
+      ;; link with description. assume only one key
+      link-string)))
 #+END_SRC
 
 We also need to find which bibliography file that key is in. For that, we need to know which bibliography files are referred to in the file. If none are specified with a bibliography link, we use the default bibliography. This function searches for a bibliography link, and then the LaTeX bibliography link. We also consider the addbibresource link which is used with biblatex.
@@ -1085,11 +1300,9 @@ Now, we can see if an entry is in a file.
 (defun org-ref-key-in-file-p (key filename)
   "determine if the key is in the file"
   (interactive "skey: \nsFile: ")
-
-  (with-temp-buffer
-    (insert-file-contents filename)
-    (prog1
-        (bibtex-search-entry key nil 0))))
+  (save-current-buffer
+    (let ((bibtex-files (list filename)))
+      (bibtex-search-entry key t))))
 #+END_SRC
 
 Finally, we want to know which file the key is in.
@@ -1109,62 +1322,6 @@ Finally, we want to know which file the key is in.
    (cons key file)))
 #+END_SRC
 
-**** Creating the menu for when we click on a key
-     :PROPERTIES:
-     :ID:       d7b7530b-802f-42b1-b61e-1e77da33e278
-     :END:
-When we click on a cite link, we want to get a menu in the minibuffer. We need to create a string for this. We want a citation, and some options that depend on the key. We want to know if the key is found, if there is a pdf, if etc... Here we create that string.
-
-#+BEGIN_SRC emacs-lisp  :tangle org-ref.el
-(defun org-ref-get-menu-options ()
-  "returns a dynamically determined string of options for the citation under point.
-
-we check to see if there is pdf, and if the key actually exists in the bibliography"
-  (interactive)
-  (let* ((results (org-ref-get-bibtex-key-and-file))
-        (key (car results))
-         (pdf-file (format (concat org-ref-pdf-directory "%s.pdf") key))
-         (bibfile (cdr results))
-        m1 m2 m3 m4 m5 menu-string)
-    (setq m1 (if bibfile                
-                "(o)pen"
-              "(No key found)"))
-
-    (setq m3 (if (file-exists-p pdf-file)
-                "(p)df"
-                    "(No pdf found)"))
-
-    (setq m4 (if (not
-                  (and bibfile
-                       (string= (catch 'url
-                                  (progn
-
-                                    (with-temp-buffer
-                                      (insert-file-contents bibfile)
-                                      (bibtex-search-entry key)
-                                      (when (not
-                                             (string= (setq url (bibtex-autokey-get-field "url")) ""))
-                                        (throw 'url url))
-
-                                      (when (not
-                                             (string= (setq url (bibtex-autokey-get-field "doi")) ""))
-                                        (throw 'url url))))) "")))
-               "(u)rl" "(no url found)"))
-    (setq m5 "(n)otes")
-    (setq m2 (if bibfile
-                (progn
-                   (setq citation (progn
-                                    (with-temp-buffer
-                                      (insert-file-contents bibfile)
-                                      (bibtex-search-entry key)
-                                      (org-ref-bib-citation))))
-                   citation)
-              "no key found"))
-
-    (setq menu-string (mapconcat 'identity (list m2 "\n" m1 m3 m4 m5 "(q)uit") "  "))
-    menu-string))
-#+END_SRC
-
 **** convenience functions to act on citation at point
      :PROPERTIES:
      :ID:       af0b2a82-a7c9-4c08-9dac-09f93abc4a92
@@ -1208,6 +1365,7 @@ We need some convenience functions to open act on the citation at point. These w
                 (browse-url (format "http://dx.doi.org/%s" doi)))
               (throw 'done nil))))))))
 
+
 (defun org-ref-open-notes-at-point ()
   "open the notes for bibtex key under point."
   (interactive)
@@ -1220,6 +1378,7 @@ We need some convenience functions to open act on the citation at point. These w
         (bibtex-search-entry key)
         (org-ref-open-bibtex-notes)))))
 
+
 (defun org-ref-citation-at-point ()
   "give message of current citation at point"
   (interactive)
@@ -1233,6 +1392,7 @@ We need some convenience functions to open act on the citation at point. These w
                       (bibtex-search-entry key)
                       (org-ref-bib-citation))))))
 
+
 (defun org-ref-open-citation-at-point ()
   "open bibtex file to key at point"
   (interactive)
@@ -1245,56 +1405,186 @@ We need some convenience functions to open act on the citation at point. These w
 #+END_SRC
 
 **** the actual minibuffer menu
-Now, we create the menu.
+Now, we create the menu. This is a rewrite of the cite action. This makes the function extendable by users.
+#+BEGIN_SRC emacs-lisp  :tangle org-ref.el
+(defvar org-ref-cite-menu-funcs '()
+ "Functions to run on cite click menu. Each entry is a list of (key menu-name function). 
+The function must take no arguments and work on the key at point. Do not modify this variable, it is set to empty in the menu click function, and functions are conditionally added to it.")
 
-#+BEGIN_SRC emacs-lisp :tangle org-ref.el
-(defun org-ref-cite-onclick-minibuffer-menu (&optional link-string)
-  "use a minibuffer to select options for the citation under point.
 
-you select your option with a single key press."
+(defvar org-ref-user-cite-menu-funcs
+  '(("C" "rossref" org-ref-crossref-at-point))
+  "user-defined functions to run on bibtex key at point.")
+
+
+(defun org-ref-get-doi-at-point ()
+  "Get doi for key at point."
   (interactive)
-  (let* ((choice (read-char (org-ref-get-menu-options)))
-        (results (org-ref-get-bibtex-key-and-file))
+  (let* ((results (org-ref-get-bibtex-key-and-file))
         (key (car results))
-        (cb (current-buffer))
-         (pdf-file (format (concat org-ref-pdf-directory "%s.pdf") key))
-         (bibfile (cdr results)))
+        (bibfile (cdr results)))
+    (save-excursion
+      (with-temp-buffer
+        (insert-file-contents bibfile)
+        (bibtex-search-entry key)
+       (bibtex-autokey-get-field "doi")
+       ;; in case doi is a url, remove the url part.
+       (replace-regexp-in-string "^http://dx.doi.org/" "" doi)))))
+  
 
-    (cond
-     ;; open
-     ((= choice ?o)
-      (find-file bibfile)
-       (bibtex-search-entry key))
-
-     ;; cite
-     ((= choice ?c)
-      (org-ref-citation-at-point))
-      
+;; functions that operate on key at point for click menu
+(defun org-ref-wos-at-point ()
+  "open the doi in wos for bibtex key under point."
+  (interactive)
+  (doi-utils-wos (org-ref-get-doi-at-point)))
+
+
+(defun org-ref-wos-citing-at-point ()
+  "open the doi in wos citing articles for bibtex key under point."
+  (interactive)
+  (doi-utils-wos-citing (org-ref-get-doi-at-point)))
 
-     ;; quit
-     ((or 
-      (= choice ?q) ; q
-      (= choice ?\ )) ; space
-      ;; this clears the minibuffer
-      (message ""))
 
-     ;; pdf
-     ((= choice ?p)
-      (org-ref-open-pdf-at-point))
+(defun org-ref-wos-related-at-point ()
+  "open the doi in wos related articles for bibtex key under point."
+  (interactive)
+  (doi-utils-wos-related (org-ref-get-doi-at-point)))
 
-     ;; notes
-     ((= choice ?n)
-      (org-ref-open-notes-at-point))
 
-     ;; url
-     ((= choice ?u)
-      (org-ref-open-url-at-point))
+(defun org-ref-google-scholar-at-point ()
+  "open the doi in google scholar for bibtex key under point."
+  (interactive)
+  (doi-utils-google-scholar (org-ref-get-doi-at-point)))
 
-     ;; anything else we just quit.
-     (t (message "")))))
-    
+
+(defun org-ref-pubmed-at-point ()
+  "open the doi in pubmed for bibtex key under point."
+  (interactive)
+  (doi-utils-pubmed (org-ref-get-doi-at-point)))
+
+
+(defun org-ref-crossref-at-point ()
+  "open the doi in crossref for bibtex key under point."
+  (interactive)
+  (doi-utils-crossref (org-ref-get-doi-at-point)))
+
+
+(defun org-ref-cite-onclick-minibuffer-menu (&optional link-string)
+  "action when a cite link is clicked on.
+Provides a menu of context sensitive actions. If the bibtex entry has a pdf, you get an option to open it. If there is a doi, you get a lot of options."
+  (interactive)
+  (let* ((results (org-ref-get-bibtex-key-and-file))
+        (key (car results))
+         (pdf-file (format (concat org-ref-pdf-directory "%s.pdf") key))
+         (bibfile (cdr results))
+        (url (save-excursion
+               (with-temp-buffer
+                 (insert-file-contents bibfile)
+                 (bibtex-search-entry key)             
+                 (bibtex-autokey-get-field "url"))))
+        (doi (save-excursion
+               (with-temp-buffer
+                 (insert-file-contents bibfile)
+                 (bibtex-search-entry key)
+                 ;; I like this better than bibtex-url which does not always find
+                 ;; the urls             
+                 (bibtex-autokey-get-field "doi")))))
+
+    (when (string= "" doi) (setq doi nil))
+    (when (string= "" url) (setq url nil))
+    (setq org-ref-cite-menu-funcs '())
+        
+    ;; open action
+    (when
+       bibfile
+      (add-to-list 
+       'org-ref-cite-menu-funcs
+       '("o" "pen" org-ref-open-citation-at-point)))
+
+    ;; pdf
+    (when (file-exists-p pdf-file)
+      (add-to-list
+       'org-ref-cite-menu-funcs
+       '("p" "df" org-ref-open-pdf-at-point) t))
+
+    ;; notes
+    (add-to-list
+     'org-ref-cite-menu-funcs
+     '("n" "otes" org-ref-open-notes-at-point) t)
+
+    ;; url
+    (when (or url doi)
+      (add-to-list
+       'org-ref-cite-menu-funcs
+       '("u" "rl" org-ref-open-url-at-point) t))
+
+    ;; doi funcs
+    (when doi
+      (add-to-list
+       'org-ref-cite-menu-funcs
+       '("w" "os" org-ref-wos-at-point) t)
+
+      (add-to-list
+       'org-ref-cite-menu-funcs
+       '("c" "iting" org-ref-wos-citing-at-point) t)
+
+      (add-to-list
+       'org-ref-cite-menu-funcs
+       '("r" "elated" org-ref-wos-related-at-point) t)
+      
+      (add-to-list
+       'org-ref-cite-menu-funcs
+       '("g" "oogle scholar" org-ref-google-scholar-at-point) t)
+
+      (add-to-list
+       'org-ref-cite-menu-funcs
+       '("P" "ubmed" org-ref-pubmed-at-point) t))
+
+    ;; add user functions
+    (dolist (tup org-ref-user-cite-menu-funcs)
+      (add-to-list
+       'org-ref-cite-menu-funcs
+       tup t))
+
+    ;; finally quit
+    (add-to-list
+     'org-ref-cite-menu-funcs
+     '("q" "uit" (lambda ())) t)
+      
+    ;; now we make a menu
+    ;; construct menu string as a message
+    (message
+     (concat
+      (let* ((results (org-ref-get-bibtex-key-and-file))
+            (key (car results))
+            (bibfile (cdr results)))
+       (save-excursion
+         (with-temp-buffer
+           (insert-file-contents bibfile)
+           (bibtex-search-entry key)
+           (org-ref-bib-citation))))
+      "\n"
+      (mapconcat
+       (lambda (tup)
+        (concat "[" (elt tup 0) "]"
+                (elt tup 1) " "))
+       org-ref-cite-menu-funcs "")))
+    ;; get the input
+    (let* ((input (read-char-exclusive))
+          (choice (assoc
+                   (char-to-string input) org-ref-cite-menu-funcs)))
+      ;; now run the function (2nd element in choice)
+      (when choice
+       (funcall
+        (elt 
+         choice
+         2))))))
 #+END_SRC
 
+#+RESULTS:
+: org-ref-cite-onclick-minibuffer-menu
+
 *** A function to format a cite link
 
 Next, we define a formatting function for the cite link. This is done so that the cite link definition is very short, and easy to change. You just need to specify the functions in the definition. This function is deprecated. The formatting is defined later automatically.
@@ -1340,6 +1630,19 @@ We will want to generate formatting functions for each citation type. The reason
 (defmacro org-ref-make-format-function (type)
   `(defun ,(intern (format "org-ref-format-%s" type)) (keyword desc format)
      (cond
+      ((eq format 'org)
+       (mapconcat
+       (lambda (key)
+         (format "[[#%s][%s]]" key key))
+       (org-ref-split-and-strip-string keyword) ","))
+
+      ((eq format 'ascii)
+       (concat "["
+              (mapconcat
+               (lambda (key)
+                 (format "%s" key))
+               (org-ref-split-and-strip-string keyword) ",") "]"))
+       
       ((eq format 'html) 
        (mapconcat 
        (lambda (key) 
@@ -1492,56 +1795,274 @@ org-mode already defines a store link function for bibtex entries. It does not s
     (car org-stored-links)))
 #+END_SRC
 
-** An html bibliography
-This code provides some functions to generate a simple bibliography in html.
+** Index entries
+org-ref minimally supports index entries. To make an index in a file, you should put in the LaTeX header these lines
+
+
+#+LATEX_HEADER: \usepackage{makeidx}
+#+LATEX_HEADER: \makeindex
+
+
+Finally, put \makeindex at the end of the document where you want the index to appear. You will need to run the makeindex program at an appropriate point in your LaTeX to pdf, or use ox-manuscript, which will do it for you.
+
+
+Use index links to create entries (see http://en.wikibooks.org/wiki/LaTeX/Indexing). Clicking on an index link runs occur on the buffer for the entry. The link exports to LaTeX. Some links may need to be enclosed in double brackets if they have spaces in them.
+
+
+index:hello
+index:hello!Peter
+[[index:hello!Sam@\textsl{Sam}]]
+[[index:Lin@\textbf{Lin}]]
+[[index:Joe|textit]]
+[[index:Lin@\textbf{Lin}]]
+[[index:Peter|see {hello}]]
+[[index:Jen|seealso{Jenny}]]
+
+index:encodings!input!cp850
 
 #+BEGIN_SRC emacs-lisp :tangle org-ref.el
-(defun org-ref-get-bibtex-keys ()
-  "return a list of unique keys in the buffer"
-  (interactive)
-  (let ((keys '()))
-    (org-element-map (org-element-parse-buffer) 'link
-      (lambda (link)       
-       (let ((plist (nth 1 link)))                          
-         (when (-contains? org-ref-cite-types (plist-get plist ':type))
-           (dolist 
-               (key 
-                (org-ref-split-and-strip-string (plist-get plist ':path)))
-             (when (not (-contains? keys key))
-               (setq keys (append keys (list key)))))))))
-    keys))
+(org-add-link-type
+ "index"
+ (lambda (path)
+   (occur path))
+
+ (lambda (path desc format)
+   (cond
+    ((eq format 'latex)
+      (format "\\index{%s}" path)))))
+
+;; this will generate a temporary index of entries in the file.
+(org-add-link-type
+ "printindex"
+ (lambda (path)
+   (let ((*index-links* '())
+        (*initial-letters* '()))
+
+     ;; get links
+     (org-element-map (org-element-parse-buffer) 'link
+       (lambda (link)       
+        (let ((type (nth 0 link))
+              (plist (nth 1 link)))
+           
+          (when (equal (plist-get plist ':type) "index")
+            (add-to-list
+             '*index-links* 
+             (cons (plist-get plist :path)
+                   (format
+                    "[[elisp:(progn (switch-to-buffer \"%s\") (goto-char %s))][%s]]"               
+(current-buffer)
+                    (plist-get plist :begin)  ;; position of link
+                    ;; grab a description
+                    (save-excursion
+                      (goto-char (plist-get plist :begin))
+                      (if (thing-at-point 'sentence)
+                          ;; get a sentence
+                          (replace-regexp-in-string
+                           "\n" "" (thing-at-point 'sentence))
+                        ;; or call it a link
+                        "link")))))))))
+
+     ;; sort the links
+     (setq *index-links*  (cl-sort *index-links* 'string-lessp :key 'car))
+   
+     ;; now first letters
+     (dolist (link *index-links*)
+       (add-to-list '*initial-letters* (substring (car link) 0 1) t))
+
+     ;; now create the index
+     (switch-to-buffer (get-buffer-create "*index*"))
+     (org-mode)
+     (erase-buffer)
+     (insert "#+TITLE: Index\n\n")
+     (dolist (letter *initial-letters*)
+       (insert (format "* %s\n" (upcase letter)))
+       ;; now process the links
+       (while (and
+              ,*index-links*
+              (string= letter (substring (car (car *index-links*)) 0 1)))
+        (let ((link (pop *index-links*)))
+          (insert (format "%s %s\n\n" (car link) (cdr link))))))
+     (switch-to-buffer "*index*")))
+ ;; formatting
+ (lambda (path desc format)
+   (cond
+    ((eq format 'latex)
+      (format "\\printindex")))))
 #+END_SRC
 
+#+RESULTS:
+| lambda | (path)             | (let ((*index-links* (quote nil)) (*initial-letters* (quote nil))) (org-element-map (org-element-parse-buffer) (quote link) (lambda (link) (let ((type (nth 0 link)) (plist (nth 1 link))) (when (equal (plist-get plist (quote :type)) index) (add-to-list (quote *index-links*) (cons (plist-get plist :path) (format [[elisp:(progn (switch-to-buffer "%s") (goto-char %s))][%s]] (current-buffer) (plist-get plist :begin) (save-excursion (goto-char (plist-get plist :begin)) (if (thing-at-point (quote sentence)) (replace-regexp-in-string \n  (thing-at-point (quote sentence))) link))))))))) (setq *index-links* (cl-sort *index-links* (quote string-lessp) :key (quote car))) (dolist (link *index-links*) (add-to-list (quote *initial-letters*) (substring (car link) 0 1) t)) (switch-to-buffer (get-buffer-create *index*)) (org-mode) (erase-buffer) (insert #+TITLE: Index\n\n) (dolist (letter *initial-letters*) (insert (format * %s\n (upcase letter))) (while (and *index-links* (string= letter (substring (car (car *index-links*)) 0 1))) (let ((link (pop *index-links*))) (insert (format %s %s\n\n (car link) (cdr link)))))) (switch-to-buffer *index*)) |
+| lambda | (path desc format) | (cond ((eq format (quote latex)) (format \printindex)))                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
+
+** Glossary
+org-ref provides some minimal support for a glossary. See http://en.wikibooks.org/wiki/LaTeX/Glossary for details. You need to put these lines in the header.
+#+LATEX_HEADER: \usepackage{glossaries}
+#+LATEX_HEADER: \makeglossaries
+
+And at the end of the document put \makeglossaries.
 
 #+BEGIN_SRC emacs-lisp :tangle org-ref.el
-(defun org-ref-get-bibtex-entry-html (key)
- (let ((org-ref-bibliography-files (org-ref-find-bibliography))
-       (file) (entry))
+(org-add-link-type
+ "newglossaryentry"
+ nil ;; no follow action
+ (lambda (path desc format)
+   (cond
+    ((eq format 'latex)
+     (format "\\newglossaryentry{%s}{%s}" path desc)))))
 
-   (setq file (catch 'result
-               (loop for file in org-ref-bibliography-files do
-                     (if (org-ref-key-in-file-p key (file-truename file)) 
-                         (throw 'result file)))))
-   (if file (with-temp-buffer
-              (insert-file-contents file)
-              (prog1
-                  (bibtex-search-entry key nil 0)
-                (setq entry  (org-ref-bib-html-citation)))
-              (format "<li><a id=\"%s\">[%s] %s</a></li>" key key entry)))))
-#+END_SRC
 
+;; link to entry
+(org-add-link-type
+ "gls"
+  nil ;; no follow action
+ (lambda (path desc format)
+   (cond
+    ((eq format 'latex)
+     (format "\\gls{%s}" path)))))
 
-#+BEGIN_SRC emacs-lisp :tangle org-ref.el 
-(defun org-ref-get-html-bibliography ()
-  "Create an html bibliography when there are keys"
-  (let ((keys (org-ref-get-bibtex-keys)))
-    (when keys
-      (concat "<h1>Bibliography</h1>
-<ul>"
-             (mapconcat (lambda (x) (org-ref-get-bibtex-entry-html x)) keys "\n")
-             "\n</ul>"))))
+;; plural
+(org-add-link-type
+ "glspl"
+  nil ;; no follow action
+ (lambda (path desc format)
+   (cond
+    ((eq format 'latex)
+     (format "\\glspl{%s}" path)))))
+
+;; capitalized link
+(org-add-link-type
+ "Gls"
+  nil ;; no follow action
+ (lambda (path desc format)
+   (cond
+    ((eq format 'latex)
+     (format "\\Gls{%s}" path)))))
+
+;; capitalized link
+(org-add-link-type
+ "Glspl"
+  nil ;; no follow action
+ (lambda (path desc format)
+   (cond
+    ((eq format 'latex)
+     (format "\\Glspl{%s}" path)))))
 #+END_SRC
 
+#+RESULTS:
+| Glspl             | nil                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | (lambda (path desc format) (cond ((eq format (quote latex)) (format \Glspl{%s} path))))                                                                                                                                                                                                                                                                                                                     |
+| Gls               | nil                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | (lambda (path desc format) (cond ((eq format (quote latex)) (format \Gls{%s} path))))                                                                                                                                                                                                                                                                                                                       |
+| glspl             | nil                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | (lambda (path desc format) (cond ((eq format (quote latex)) (format \glspl{%s} path))))                                                                                                                                                                                                                                                                                                                     |
+| gls               | nil                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | (lambda (path desc format) (cond ((eq format (quote latex)) (format \gls{%s} path))))                                                                                                                                                                                                                                                                                                                       |
+| newglossaryentry  | nil                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | (lambda (path desc format) (cond ((eq format (quote latex)) (format \newglossaryentry{%s}{%s} path desc))))                                                                                                                                                                                                                                                                                                 |
+| google            | (lambda (link-string) (browse-url (format http://www.google.com/search?q=%s (url-hexify-string link-string))))                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | nil                                                                                                                                                                                                                                                                                                                                                                                                         |
+| ResearcherID      | (lambda (link-string) (browse-url (format http://www.researcherid.com/rid/%s link-string)))                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | nil                                                                                                                                                                                                                                                                                                                                                                                                         |
+| orcid             | (lambda (link-string) (browse-url (format http://orcid.org/%s link-string)))                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       | nil                                                                                                                                                                                                                                                                                                                                                                                                         |
+| message           | org-mac-message-open                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | nil                                                                                                                                                                                                                                                                                                                                                                                                         |
+| mac-outlook       | org-mac-outlook-message-open                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       | nil                                                                                                                                                                                                                                                                                                                                                                                                         |
+| skim              | org-mac-skim-open                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  | nil                                                                                                                                                                                                                                                                                                                                                                                                         |
+| addressbook       | org-mac-addressbook-item-open                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      | nil                                                                                                                                                                                                                                                                                                                                                                                                         |
+| x-together-item   | org-mac-together-item-open                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         | nil                                                                                                                                                                                                                                                                                                                                                                                                         |
+| ans               | (lambda (path) (let* ((fields (split-string path ::)) (label (nth 0 fields)) (data (nth 1 fields)) (data-file (format %s-%s.dat tq-userid label))) (let ((temp-file data-file) (temp-buffer (get-buffer-create (generate-new-buffer-name  *temp file*)))) (unwind-protect (prog1 (save-current-buffer (set-buffer temp-buffer) (insert data)) (save-current-buffer (set-buffer temp-buffer) (write-region nil nil temp-file nil 0))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer)))) (mygit (format git add %s data-file)) (mygit (format git commit -m "%s" data-file)) (mygit git push origin master)))                                                                                                                                                                                              | nil                                                                                                                                                                                                                                                                                                                                                                                                         |
+| mc                | (lambda (link) (org-entry-put (point) ANSWER link) (save-restriction (save-excursion (org-narrow-to-subtree) (goto-char (point-max)) (if (bolp) nil (insert \n)) (insert (format # you chose %s link)))))                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          | nil                                                                                                                                                                                                                                                                                                                                                                                                         |
+| exercise          | (lambda (arg) (tq-check-internet) (tq-get-assignment arg))                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         | nil                                                                                                                                                                                                                                                                                                                                                                                                         |
+| solution          | (lambda (label) (tq-check-internet) (let ((default-directory (file-name-as-directory (expand-file-name tq-root-directory)))) (if (file-exists-p solutions) nil (make-directory solutions)) (let ((default-directory (file-name-as-directory (expand-file-name solutions)))) (if (file-exists-p label) (progn (find-file (concat label / label .org)) (tq-update)) (mygit (format git clone %s@%s:solutions/%s tq-current-course tq-git-server label)) (find-file (concat label / label .org))))))                                                                                                                                                                                                                                                                                                                  | nil                                                                                                                                                                                                                                                                                                                                                                                                         |
+| assignment        | (lambda (arg) (tq-check-internet) (tq-get-assignment arg))                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         | nil                                                                                                                                                                                                                                                                                                                                                                                                         |
+| doi               | doi-link-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      | nil                                                                                                                                                                                                                                                                                                                                                                                                         |
+| bibentry          | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-bibentry                                                                                                                                                                                                                                                                                                                                                                                     |
+| Autocites         | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-Autocites                                                                                                                                                                                                                                                                                                                                                                                    |
+| autocites         | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-autocites                                                                                                                                                                                                                                                                                                                                                                                    |
+| supercites        | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-supercites                                                                                                                                                                                                                                                                                                                                                                                   |
+| Textcites         | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-Textcites                                                                                                                                                                                                                                                                                                                                                                                    |
+| textcites         | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-textcites                                                                                                                                                                                                                                                                                                                                                                                    |
+| Smartcites        | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-Smartcites                                                                                                                                                                                                                                                                                                                                                                                   |
+| smartcites        | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-smartcites                                                                                                                                                                                                                                                                                                                                                                                   |
+| footcitetexts     | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-footcitetexts                                                                                                                                                                                                                                                                                                                                                                                |
+| footcites         | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-footcites                                                                                                                                                                                                                                                                                                                                                                                    |
+| Parencites        | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-Parencites                                                                                                                                                                                                                                                                                                                                                                                   |
+| parencites        | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-parencites                                                                                                                                                                                                                                                                                                                                                                                   |
+| Cites             | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-Cites                                                                                                                                                                                                                                                                                                                                                                                        |
+| cites             | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-cites                                                                                                                                                                                                                                                                                                                                                                                        |
+| fnotecite         | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-fnotecite                                                                                                                                                                                                                                                                                                                                                                                    |
+| Pnotecite         | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-Pnotecite                                                                                                                                                                                                                                                                                                                                                                                    |
+| pnotecite         | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-pnotecite                                                                                                                                                                                                                                                                                                                                                                                    |
+| Notecite          | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-Notecite                                                                                                                                                                                                                                                                                                                                                                                     |
+| notecite          | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-notecite                                                                                                                                                                                                                                                                                                                                                                                     |
+| footfullcite      | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-footfullcite                                                                                                                                                                                                                                                                                                                                                                                 |
+| fullcite          | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-fullcite                                                                                                                                                                                                                                                                                                                                                                                     |
+| citeurl           | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-citeurl                                                                                                                                                                                                                                                                                                                                                                                      |
+| citedate*         | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-citedate*                                                                                                                                                                                                                                                                                                                                                                                    |
+| citedate          | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-citedate                                                                                                                                                                                                                                                                                                                                                                                     |
+| citetitle*        | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-citetitle*                                                                                                                                                                                                                                                                                                                                                                                   |
+| citetitle         | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-citetitle                                                                                                                                                                                                                                                                                                                                                                                    |
+| Citeauthor*       | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-Citeauthor*                                                                                                                                                                                                                                                                                                                                                                                  |
+| Autocite*         | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-Autocite*                                                                                                                                                                                                                                                                                                                                                                                    |
+| autocite*         | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-autocite*                                                                                                                                                                                                                                                                                                                                                                                    |
+| Autocite          | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-Autocite                                                                                                                                                                                                                                                                                                                                                                                     |
+| autocite          | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-autocite                                                                                                                                                                                                                                                                                                                                                                                     |
+| supercite         | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-supercite                                                                                                                                                                                                                                                                                                                                                                                    |
+| parencite*        | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-parencite*                                                                                                                                                                                                                                                                                                                                                                                   |
+| cite*             | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-cite*                                                                                                                                                                                                                                                                                                                                                                                        |
+| Smartcite         | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-Smartcite                                                                                                                                                                                                                                                                                                                                                                                    |
+| smartcite         | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-smartcite                                                                                                                                                                                                                                                                                                                                                                                    |
+| Textcite          | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-Textcite                                                                                                                                                                                                                                                                                                                                                                                     |
+| textcite          | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-textcite                                                                                                                                                                                                                                                                                                                                                                                     |
+| footcitetext      | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-footcitetext                                                                                                                                                                                                                                                                                                                                                                                 |
+| footcite          | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-footcite                                                                                                                                                                                                                                                                                                                                                                                     |
+| Parencite         | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-Parencite                                                                                                                                                                                                                                                                                                                                                                                    |
+| parencite         | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-parencite                                                                                                                                                                                                                                                                                                                                                                                    |
+| Cite              | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-Cite                                                                                                                                                                                                                                                                                                                                                                                         |
+| Citeauthor        | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-Citeauthor                                                                                                                                                                                                                                                                                                                                                                                   |
+| Citealp           | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-Citealp                                                                                                                                                                                                                                                                                                                                                                                      |
+| Citealt           | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-Citealt                                                                                                                                                                                                                                                                                                                                                                                      |
+| Citep             | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-Citep                                                                                                                                                                                                                                                                                                                                                                                        |
+| Citet             | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-Citet                                                                                                                                                                                                                                                                                                                                                                                        |
+| citeyear*         | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-citeyear*                                                                                                                                                                                                                                                                                                                                                                                    |
+| citeyear          | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-citeyear                                                                                                                                                                                                                                                                                                                                                                                     |
+| citeauthor*       | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-citeauthor*                                                                                                                                                                                                                                                                                                                                                                                  |
+| citeauthor        | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-citeauthor                                                                                                                                                                                                                                                                                                                                                                                   |
+| citetext          | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-citetext                                                                                                                                                                                                                                                                                                                                                                                     |
+| citenum           | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-citenum                                                                                                                                                                                                                                                                                                                                                                                      |
+| citealp*          | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-citealp*                                                                                                                                                                                                                                                                                                                                                                                     |
+| citealp           | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-citealp                                                                                                                                                                                                                                                                                                                                                                                      |
+| citealt*          | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-citealt*                                                                                                                                                                                                                                                                                                                                                                                     |
+| citealt           | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-citealt                                                                                                                                                                                                                                                                                                                                                                                      |
+| citep*            | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-citep*                                                                                                                                                                                                                                                                                                                                                                                       |
+| citep             | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-citep                                                                                                                                                                                                                                                                                                                                                                                        |
+| citet*            | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-citet*                                                                                                                                                                                                                                                                                                                                                                                       |
+| citet             | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-citet                                                                                                                                                                                                                                                                                                                                                                                        |
+| nocite            | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-nocite                                                                                                                                                                                                                                                                                                                                                                                       |
+| cite              | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-cite                                                                                                                                                                                                                                                                                                                                                                                         |
+| eqref             | (lambda (label) on clicking goto the label. Navigate back with C-c & (org-mark-ring-push) (widen) (goto-char (point-min)) (if (or (re-search-forward (format label:%s label) nil t) (re-search-forward (format \label{%s} label) nil t) (re-search-forward (format ^#\+label:\s-*\(%s\)\b label) nil t)) nil (org-mark-ring-goto) (error %s not found label)) (message go back with (org-mark-ring-goto) `C-c &`))                                                                                                                                                                                                                                                                                                                                                                                                 | (lambda (keyword desc format) (cond ((eq format (quote html)) (format (<eqref>%s</eqref>) path)) ((eq format (quote latex)) (format \eqref{%s} keyword))))                                                                                                                                                                                                                                                  |
+| nameref           | (lambda (label) on clicking goto the label. Navigate back with C-c & (org-mark-ring-push) (widen) (if (or (progn (goto-char (point-min)) (re-search-forward (format \label{%s} label) nil t))) nil (org-mark-ring-goto) (error %s not found label)) (message go back with (org-mark-ring-goto) `C-c &`))                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           | (lambda (keyword desc format) (cond ((eq format (quote html)) (format (<nameref>%s</nameref>) path)) ((eq format (quote latex)) (format \nameref{%s} keyword))))                                                                                                                                                                                                                                            |
+| pageref           | (lambda (label) on clicking goto the label. Navigate back with C-c & (org-mark-ring-push) (widen) (if (or (progn (goto-char (point-min)) (re-search-forward (format label:%s\b label) nil t)) (progn (goto-char (point-min)) (re-search-forward (format \label{%s} label) nil t)) (progn (goto-char (point-min)) (re-search-forward (format ^#\+label:\s-*\(%s\)\b label) nil t)) (progn (goto-char (point-min)) (re-search-forward (format ^#\+tblname:\s-*\(%s\)\b label) nil t))) nil (org-mark-ring-goto) (error %s not found label)) (message go back with (org-mark-ring-goto) `C-c &`))                                                                                                                                                                                                                     | (lambda (keyword desc format) (cond ((eq format (quote html)) (format (<pageref>%s</pageref>) path)) ((eq format (quote latex)) (format \pageref{%s} keyword))))                                                                                                                                                                                                                                            |
+| ref               | (lambda (label) on clicking goto the label. Navigate back with C-c & (org-mark-ring-push) (widen) (if (or (progn (goto-char (point-min)) (re-search-forward (format label:%s\b label) nil t)) (progn (goto-char (point-min)) (re-search-forward (format \label{%s} label) nil t)) (progn (goto-char (point-min)) (re-search-forward (format ^#\+label:\s-*\(%s\)\b label) nil t)) (progn (goto-char (point-min)) (re-search-forward (format ^#\+tblname:\s-*\(%s\)\b label) nil t))) nil (org-mark-ring-goto) (error %s not found label)) (org-show-entry) (message go back with (org-mark-ring-goto) `C-c &`))                                                                                                                                                                                                    | (lambda (keyword desc format) (cond ((eq format (quote html)) (format (<ref>%s</ref>) path)) ((eq format (quote latex)) (format \ref{%s} keyword))))                                                                                                                                                                                                                                                        |
+| label             | (lambda (label) on clicking count the number of label tags used in the buffer. A number greater than one means multiple labels! (message (format %s occurences (+ (count-matches (format label:%s\b[^-:] label) (point-min) (point-max) t) (count-matches (format ^#\+tblname:\s-*%s\b[^-:] label) (point-min) (point-max) t) (count-matches (format \label{%s}\b label) (point-min) (point-max) t) (count-matches (format ^#\+label:\s-*%s\b[^-:] label) (point-min) (point-max) t)))))                                                                                                                                                                                                                                                                                                                           | (lambda (keyword desc format) (cond ((eq format (quote html)) (format (<label>%s</label>) path)) ((eq format (quote latex)) (format \label{%s} keyword))))                                                                                                                                                                                                                                                  |
+| list-of-tables    | org-ref-list-of-tables                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             | (lambda (keyword desc format) (cond ((eq format (quote latex)) (format \listoftables))))                                                                                                                                                                                                                                                                                                                    |
+| list-of-figures   | org-ref-list-of-figures                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            | (lambda (keyword desc format) (cond ((eq format (quote latex)) (format \listoffigures))))                                                                                                                                                                                                                                                                                                                   |
+| addbibresource    | (lambda (link-string) (let* ((bibfile) (object (org-element-context)) (link-string-beginning) (link-string-end)) (save-excursion (goto-char (org-element-property :begin object)) (search-forward link-string nil nil 1) (setq link-string-beginning (match-beginning 0)) (setq link-string-end (match-end 0))) (set (make-local-variable (quote reftex-default-addbibresource)) (split-string (org-element-property :path object) ,)) (save-excursion (if (search-forward , link-string-end 1 1) (setq key-end (- (match-end 0) 1)) (setq key-end (point)))) (save-excursion (if (search-backward , link-string-beginning 1 1) (setq key-beginning (+ (match-beginning 0) 1)) (setq key-beginning (point)))) (setq bibfile (org-ref-strip-string (buffer-substring key-beginning key-end))) (find-file bibfile))) | (lambda (keyword desc format) (cond ((eq format (quote html)) (format )) ((eq format (quote latex)) (format \addbibresource{%s} keyword))))                                                                                                                                                                                                                                                                 |
+| bibliographystyle | (lambda (arg) (message Nothing implemented for clicking here.))                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | (lambda (keyword desc format) (cond ((eq format (quote latex)) (format \bibliographystyle{%s} keyword))))                                                                                                                                                                                                                                                                                                   |
+| printbibliography | (lambda (arg) (message Nothing implemented for clicking here.))                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | (lambda (keyword desc format) (cond ((eq format (quote org)) (org-ref-get-org-bibliography)) ((eq format (quote html)) (org-ref-get-html-bibliography)) ((eq format (quote latex)) \printbibliography)))                                                                                                                                                                                                    |
+| nobibliography    | (lambda (link-string) (let* ((bibfile) (object (org-element-context)) (link-string-beginning) (link-string-end)) (save-excursion (goto-char (org-element-property :begin object)) (search-forward link-string nil nil 1) (setq link-string-beginning (match-beginning 0)) (setq link-string-end (match-end 0))) (set (make-local-variable (quote reftex-default-bibliography)) (split-string (org-element-property :path object) ,)) (save-excursion (if (search-forward , link-string-end 1 1) (setq key-end (- (match-end 0) 1)) (setq key-end (point)))) (save-excursion (if (search-backward , link-string-beginning 1 1) (setq key-beginning (+ (match-beginning 0) 1)) (setq key-beginning (point)))) (setq bibfile (org-ref-strip-string (buffer-substring key-beginning key-end))) (find-file bibfile)))   | (lambda (keyword desc format) (cond ((eq format (quote org)) (org-ref-get-org-bibliography)) ((eq format (quote ascii)) (org-ref-get-ascii-bibliography)) ((eq format (quote html)) (org-ref-get-html-bibliography)) ((eq format (quote latex)) (format \nobibliography{%s} (replace-regexp-in-string \.bib  (mapconcat (quote identity) (mapcar (quote expand-file-name) (split-string keyword ,)) ,)))))) |
+| bibliography      | (lambda (link-string) (let* ((bibfile) (object (org-element-context)) (link-string-beginning) (link-string-end)) (save-excursion (goto-char (org-element-property :begin object)) (search-forward link-string nil nil 1) (setq link-string-beginning (match-beginning 0)) (setq link-string-end (match-end 0))) (set (make-local-variable (quote reftex-default-bibliography)) (split-string (org-element-property :path object) ,)) (save-excursion (if (search-forward , link-string-end 1 1) (setq key-end (- (match-end 0) 1)) (setq key-end (point)))) (save-excursion (if (search-backward , link-string-beginning 1 1) (setq key-beginning (+ (match-beginning 0) 1)) (setq key-beginning (point)))) (setq bibfile (org-ref-strip-string (buffer-substring key-beginning key-end))) (find-file bibfile)))   | (lambda (keyword desc format) (cond ((eq format (quote org)) (org-ref-get-org-bibliography)) ((eq format (quote ascii)) (org-ref-get-ascii-bibliography)) ((eq format (quote html)) (org-ref-get-html-bibliography)) ((eq format (quote latex)) (format \bibliography{%s} (replace-regexp-in-string \.bib  (mapconcat (quote identity) (mapcar (quote expand-file-name) (split-string keyword ,)) ,))))))   |
+| rmail             | org-rmail-open                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | nil                                                                                                                                                                                                                                                                                                                                                                                                         |
+| mhe               | org-mhe-open                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       | nil                                                                                                                                                                                                                                                                                                                                                                                                         |
+| irc               | org-irc-visit                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      | nil                                                                                                                                                                                                                                                                                                                                                                                                         |
+| info              | org-info-open                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      | nil                                                                                                                                                                                                                                                                                                                                                                                                         |
+| gnus              | org-gnus-open                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      | nil                                                                                                                                                                                                                                                                                                                                                                                                         |
+| docview           | org-docview-open                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   | org-docview-export                                                                                                                                                                                                                                                                                                                                                                                          |
+| bibtex            | org-bibtex-open                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | nil                                                                                                                                                                                                                                                                                                                                                                                                         |
+| bbdb              | org-bbdb-open                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      | org-bbdb-export                                                                                                                                                                                                                                                                                                                                                                                             |
+| pydoc             | (lambda (link-string) (shell-command (format python -m pydoc %s link-string)))                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | nil                                                                                                                                                                                                                                                                                                                                                                                                         |
+| index             | (lambda (path) (tq-index) (occur path))                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            | nil                                                                                                                                                                                                                                                                                                                                                                                                         |
+| attachfile        | (lambda (link-string) (org-open-file link-string))                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 | (lambda (keyword desc format) (cond ((eq format (quote html)) (format )) ((eq format (quote latex)) (format \attachfile{%s} keyword))))                                                                                                                                                                                                                                                                     |
+| msx               | org-msx-open                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       | nil                                                                                                                                                                                                                                                                                                                                                                                                         |
+| id                | org-id-open                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | nil                                                                                                                                                                                                                                                                                                                                                                                                         |
+| file+emacs        | org-open-file-with-emacs                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           | nil                                                                                                                                                                                                                                                                                                                                                                                                         |
+| file+sys          | org-open-file-with-system                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          | nil                                                                                                                                                                                                                                                                                                                                                                                                         |
+
+
+
 * Utilities
 ** create simple text citation from bibtex entry
 
@@ -1657,12 +2178,14 @@ construct the heading by hand."
     
     ;; now look for entry in the notes file
     (if  org-ref-bibliography-notes
-       (find-file org-ref-bibliography-notes)
+       (find-file-other-window org-ref-bibliography-notes)
       (error "org-ref-bib-bibliography-notes is not set to anything"))
     
     (goto-char (point-min))
     ;; put new entry in notes if we don't find it.
-    (unless (re-search-forward (format ":Custom_ID: %s$" key) nil 'end)
+    (if (re-search-forward (format ":Custom_ID: %s$" key) nil 'end)
+       (funcall org-ref-open-notes-function)
+      ;; no entry found, so add one    
       (insert (format "\n** TODO %s - %s" year title))
       (insert (format"
  :PROPERTIES:
@@ -1680,6 +2203,25 @@ key author journal year volume pages doi url key org-ref-pdf-directory key))
 (save-buffer))))
 #+END_SRC
 
+#+BEGIN_SRC emacs-lisp :tangle org-ref.el
+(defun org-ref-open-notes-from-reftex ()
+  "Call reftex, and open notes for selected entry."
+  (interactive)
+  (let ((bibtex-key )))
+
+    ;; now look for entry in the notes file
+    (if  org-ref-bibliography-notes
+       (find-file-other-window org-ref-bibliography-notes)
+      (error "org-ref-bib-bibliography-notes is not set to anything"))
+    
+    (goto-char (point-min))
+    
+    (re-search-forward (format
+                       ":Custom_ID: %s$"
+                       (first (reftex-citation t)) nil 'end))
+    (funcall org-ref-open-notes-function))
+#+END_SRC
+
 ** open url in browser from bibtex
 
 We bind this to a key here [[*key%20bindings%20for%20utilities][key bindings for utilities]].
@@ -2138,7 +2680,7 @@ Sometimes it may be helpful to manually change the order of citations. These fun
          (org-ref-swap-keys i (- i 1) keys))   
        (setq keys (mapconcat 'identity keys ","))
        ;; and replace the link with the sorted keys
-       (cl--set-buffer-substring begin end (concat type ":" keys))
+       (cl--set-buffer-substring begin end (concat type ":" keys " "))
        ;; now go forward to key so we can move with the key
        (re-search-forward key) 
        (goto-char (match-beginning 0)))))
@@ -2156,6 +2698,7 @@ I like convenience. Here are some aliases for faster typing.
 (defalias 'orp 'org-ref-open-pdf-at-point)
 (defalias 'oru 'org-ref-open-url-at-point)
 (defalias 'orn 'org-ref-open-notes-at-point)
+(defalias 'ornr 'org-ref-open-notes-from-reftex)
 
 (defalias 'orib 'org-ref-insert-bibliography-link)
 (defalias 'oric 'org-ref-insert-cite-link)
@@ -2169,11 +2712,13 @@ I like convenience. Here are some aliases for faster typing.
 (provide 'org-ref)
 #+END_SRC
 
-
 * Build                                                                   :noexport:
+This code will tangle the elisp code out to org-ref.el and load it.
 
 [[elisp:(progn (org-babel-tangle) (load-file "org-ref.el"))]]
 
+Alternatively you may use:
+
 [[elisp:(org-babel-load-file "org-ref.org")]]