(add-hook 'org-shiftleft-hook (lambda () (org-ref-swap-citation-link -1)))
#+END_SRC
-
** Lightweight messages about links
To get a lighter weight message about the label, ref and cite links, 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.
(goto-char (point-min))
(when (re-search-forward
(format "label:%s\\b" label) nil t)
- (throw 'result (thing-at-point 'paragraph)))
+ (throw 'result (buffer-substring
+ (progn
+ (previous-line)
+ (beginning-of-line)
+ (point))
+ (progn
+ (forward-line 4)
+ (point)))))
(goto-char (point-min))
(when (re-search-forward
(format "\\label{%s}" label) nil t)
- (throw 'result (thing-at-point 'paragraph)))
+ (throw 'result (buffer-substring
+ (progn
+ (previous-line)
+ (beginning-of-line)
+ (point))
+ (progn
+ (forward-line 4)
+ (point)))))
(goto-char (point-min))
(when (re-search-forward
(format "^#\\+label:\\s-*\\(%s\\)\\b" label) nil t)
- (throw 'result (thing-at-point 'paragraph)))
+ (throw 'result (buffer-substring
+ (progn
+ (previous-line)
+ (beginning-of-line)
+ (point))
+ (progn
+ (forward-line 4)
+ (point)))))
(goto-char (point-min))
(when (re-search-forward
(forward-line 4)
(point))))))))
+
(defun org-ref-link-message ()
"Print a minibuffer message about the link that point is on."
(interactive)
;; message some context about the label we are referring to
((string= type "ref")
-;; (message-box "%s" (org-element-property :path object))
+ (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))))
((string= type "label")
(let ((count (org-ref-count-labels
(org-element-property :path object))))
+ ;; get plurality on occurrence correct
(message (concat
(number-to-string count)
" occurence"
(> count 1))
"s"))))))))
+
(when org-ref-show-citation-on-enter
(add-hook 'post-command-hook 'org-ref-link-message))
#+END_SRC
(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