+* Helm interface
+[[https://github.com/tmalsburg/helm-bibtex][helm-bibtex]] is a very cool interface to bibtex files. Out of the box though, it is not super convenient for org-ref. Here, we modify it to make it fit our workflow and extend it where needed.
+
+1. Make the default action to insert selected keys.
+2. Make open entry second action
+#+BEGIN_SRC emacs-lisp :tangle org-ref.el
+(setq helm-source-bibtex
+ '((name . "BibTeX entries")
+ (init . helm-bibtex-init)
+ (candidates . helm-bibtex-candidates)
+ (filtered-candidate-transformer . helm-bibtex-candidates-formatter)
+ (action . (("Insert citation" . helm-bibtex-insert-citation)
+ ("Show entry" . helm-bibtex-show-entry)
+ ("Open PDF file (if present)" . helm-bibtex-open-pdf)
+ ("Open URL or DOI in browser" . helm-bibtex-open-url-or-doi)
+ ("Insert reference" . helm-bibtex-insert-reference)
+ ("Insert BibTeX key" . helm-bibtex-insert-key)
+ ("Insert BibTeX entry" . helm-bibtex-insert-bibtex)
+ ("Attach PDF to email" . helm-bibtex-add-PDF-attachment)
+ ("Edit notes" . helm-bibtex-edit-notes)
+ ))))
+#+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)))
+ (cond
+ ;; case where we are in a link
+ ((and (equal (org-element-type object) 'link)
+ (-contains? org-ref-cite-types (org-element-property :type object)))
+ (goto-char link-string-end)
+ ;; sometimes there are spaces at the end of the link
+ ;; this code moves point pack until no spaces are there
+ (while (looking-back " ") (backward-char))
+ (insert (concat "," (mapconcat 'identity keys ","))))
+
+ ;; We are next to a link, and we want to append
+ ((save-excursion
+ (backward-char)
+ (and (equal (org-element-type (org-element-context)) 'link)
+ (-contains? org-ref-cite-types (org-element-property :type (org-element-context)))))
+ (while (looking-back " ") (backward-char))
+ (insert (concat "," (mapconcat 'identity keys ","))))
+
+ ;; insert fresh link
+ (t
+ (insert
+ (concat org-ref-default-citation-link
+ ":"
+ (s-join keys ",")))))))
+
+(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
+
+