(defcustom org-ref-insert-cite-function
- 'org-ref-insert-cite-link
- "Function to call to insert citation links."
+ 'helm-bibtex
+ "Function to call to insert citation links. The default is `helm-bibtex'. org-ref modifies helm-bibtex a little bit to give org-mode citations, and to reorder default actions. You may use `org-ref-insert-cite-link' if you like the reftex interface."
:type 'function)
(defcustom org-ref-cite-onclick-function
- 'org-ref-cite-onclick-minibuffer-menu
- "Function that runs when you click on a cite link. The function must take no arguments"
+ 'org-ref-cite-click-helm
+ "Function that runs when you click on a cite link. The function must take no arguments. You may also use `org-ref-cite-onclick-minibuffer-menu' if you do not like helm."
:type 'function)
#+END_SRC
Now, let us define a function that inserts the cite links:
#+BEGIN_SRC emacs-lisp :tangle org-ref.el
-
(defun helm-bibtex-format-org-ref (keys)
"insert selected KEYS as cite link. Append KEYS if you are on a link."
(let* ((object (org-element-context)))
(setq helm-bibtex-format-citation-functions
'((org-mode . helm-bibtex-format-org-ref)))
-(setq org-ref-insert-cite-function 'helm-bibtex)
-
(require 'helm-bibtex)
#+END_SRC
;; the urls
(bibtex-autokey-get-field "doi"))))
(candidates `( ;;the first candidate is a brief summary
- (,(save-excursion
- (with-temp-buffer
- (insert-file-contents bibfile)
- (bibtex-search-entry key))
- (org-ref-bib-citation)) . org-ref-citation-at-point)
+ ("Quit" . org-ref-citation-at-point)
("Open bibtex entry" . org-ref-open-citation-at-point))))
- (message-box "doi = \"%s\"" doi)
+
(when (file-exists-p pdf-file)
(add-to-list
'candidates
(add-to-list
'candidates
- '("Email" . (lambda ()
+ '("Email bibtex entry and pdf" . (lambda ()
(save-excursion
(org-ref-open-citation-at-point)
(email-bibtex-entry))))
collect (cons (format "%2s. %s" i (car cell))
(cdr cell)))))
+
+(defvar org-ref-helm-user-candidates '()
+ "List of user-defined candidates to act when clicking on a cite link.
+This is a list of cons cells '((\"description\" . action)). The action function should not take an argument, and should assume point is on the cite key of interest.
+")
+
+;; example of adding your own function
+(add-to-list
+ 'org-ref-helm-user-candidates
+ '("Example" . (lambda () (message-box "You did it!")))
+ t)
+
(defun org-ref-cite-click-helm (key)
"subtle points.
1. get name and candidates before entering helm because we need the org-buffer.
(action . (lambda (f)
(switch-to-buffer cb)
(funcall f))))
+ ((name . "User functions")
+ (candidates . ,org-ref-helm-user-candidates)
+ (action . (lambda (f)
+ (switch-to-buffer cb)
+ (funcall f))))
))))
-
-(setq org-ref-cite-onclick-function 'org-ref-cite-click-helm)
#+END_SRC
#+RESULTS: