+** A helm click menu
+
+#+BEGIN_SRC emacs-lisp :tangle org-ref.el
+(defun org-ref-get-citation-string-at-point ()
+ (interactive)
+ (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)))))
+
+(defun org-ref-cite-candidates ()
+ "Generate the list of possible candidates.
+Check for pdf and doi, and add appropriate functions."
+ (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"))))
+ (candidates `( ;;the first candidate is a brief summary
+ ("Quit" . org-ref-citation-at-point)
+ ("Open bibtex entry" . org-ref-open-citation-at-point))))
+
+
+ (when (file-exists-p pdf-file)
+ (add-to-list
+ 'candidates
+ '("Open pdf" . org-ref-open-pdf-at-point)
+ t
+ ))
+
+ (add-to-list
+ 'candidates
+ '("Open notes" . org-ref-open-notes-at-point)
+ t)
+
+ (when (or url doi)
+ (add-to-list
+ 'candidates
+ '("Open in browser" . org-ref-open-url-at-point)
+ t))
+
+ (when doi
+ (mapc (lambda (x)
+ (add-to-list 'candidates x t))
+ `(("WOS" . org-ref-wos-at-point)
+ ("Related articles in WOS" . org-ref-wos-related-at-point)
+ ("Citing articles in WOS" . org-ref-wos-citing-at-point)
+ ("Google Scholar" . org-ref-google-scholar-at-point)
+ ("Pubmed" . org-ref-pubmed-at-point)
+ ("Crossref" . org-ref-crossref-at-point)
+ )))
+
+ (add-to-list
+ 'candidates
+ '("Copy formatted citation to clipboard" . org-ref-copy-entry-as-summary)
+ t)
+
+ (add-to-list
+ 'candidates
+ '("Copy key to clipboard" . (lambda ()
+ (kill-new
+ (car (org-ref-get-bibtex-key-and-file)))))
+ t)
+
+ (add-to-list
+ 'candidates
+ '("Copy bibtex entry to file" . org-ref-copy-entry-at-point-to-file)
+ t)
+
+ (add-to-list
+ 'candidates
+ '("Email bibtex entry and pdf" . (lambda ()
+ (save-excursion
+ (org-ref-open-citation-at-point)
+ (email-bibtex-entry))))
+ t)
+ ;; finally return a numbered list of the candidates
+ (loop for i from 0
+ for cell in candidates
+ 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.
+2. switch back to the org buffer before evaluating the action. most of them need the point and buffer."
+ (interactive)
+ (let ((name (org-ref-get-citation-string-at-point))
+ (candidates (org-ref-cite-candidates))
+ (cb (current-buffer)))
+
+ (helm :sources `(((name . ,name)
+ (candidates . ,candidates)
+ (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))))
+ ))))
+#+END_SRC
+
+#+RESULTS:
+: org-ref-cite-click-helm
+
+To get a lighter weight message about the cite link, we define a function that gives us the minibuffer message, without the menu. We add it to a hook that updates after every command, including cursor movements.
+
+#+BEGIN_SRC emacs-lisp :tangle org-ref.el
+(defun org-ref-cite-link-p () (interactive)
+ (let* ((object (org-element-context))
+ (type (org-element-property :type object)))
+ ;; We only want this to work on citation links
+ (when (-contains? org-ref-cite-types type)
+ (message (org-ref-get-citation-string-at-point)))))
+
+(when org-ref-show-citation-on-enter
+ (add-hook 'post-command-hook 'org-ref-cite-link-p))
+#+END_SRC