(interactive)
(let* ((object (org-element-context))
(type (org-element-property :type object)))
-
- (cond
+ (save-excursion
+ (cond
;; cite links
((-contains? org-ref-cite-types type)
(message (org-ref-get-citation-string-at-point)))
(message (org-ref-get-label-context
(org-element-property :path object))))
+ ((string= type "eqref")
+ (message (org-ref-get-label-context
+ (org-element-property :path object))))
+
;; message the count
((string= type "label")
(let ((count (org-ref-count-labels
" occurence"
(when (or (= count 0)
(> count 1))
- "s"))))))))
+ "s")))))))))
(when org-ref-show-citation-on-enter
(t
(insert
(concat (if helm-current-prefix-arg
+ (helm :sources `((name . "link types")
+ (candidates . ,org-ref-cite-types)
+ (action . (lambda (x) x))))
(ido-completing-read "Type: " org-ref-cite-types)
org-ref-default-citation-link)
":"
(s-join "," keys))))))
-;; return empty string for helm
-"")
+ ;; return empty string for helm
+ "")
(setq helm-bibtex-format-citation-functions
'((org-mode . helm-bibtex-format-org-ref)))
(bibtex-autokey-get-field "doi"))))
(candidates `(("Quit" . org-ref-citation-at-point)
("Open bibtex entry" . org-ref-open-citation-at-point))))
+ ;; for some reason, when there is no doi or url, they are returned as "". I
+ ;; prefer nil so we correct this here.
+ (when (string= doi "") (setq doi nil))
+ (when (string= url "") (setq url nil))
-
- (when (file-exists-p pdf-file)
+ ;; Conditional pdf functions
+ (if (file-exists-p pdf-file)
+ (add-to-list
+ 'candidates
+ '("Open pdf" . org-ref-open-pdf-at-point)
+ t)
(add-to-list
'candidates
- '("Open pdf" . org-ref-open-pdf-at-point)
- t
- ))
+ '("Try to get pdf" . (lambda ()
+ (save-window-excursion
+ (org-ref-open-citation-at-point)
+ (bibtex-beginning-of-entry)
+ (doi-utils-get-bibtex-entry-pdf))))
+ t))
+
(add-to-list
'candidates
'("Open notes" . org-ref-open-notes-at-point)
t)
+ ;; conditional url and doi functions
(when (or url doi)
(add-to-list
'candidates