X-Git-Url: https://git.donarmstrong.com/?p=org-ref.git;a=blobdiff_plain;f=org-ref.org;h=1e03bdfb64fddae469e20ef88c1c759abdfd7da4;hp=0561f76a7d583075264fdd1d2099a3f18fa679fe;hb=b23aa62a179b619eaf100f77567db087fe48c712;hpb=d832a3f74c8f41017016f79f3b6e2ad1677b4c0c diff --git a/org-ref.org b/org-ref.org index 0561f76..1e03bdf 100644 --- a/org-ref.org +++ b/org-ref.org @@ -218,11 +218,35 @@ We setup reftex here. We use a custom insert cite link function defined here: [[ ;; I do not remember why I put this next line in. It doesn't ;; work for org-files. Nothing very bad happens, but it gives ;; an annoying error. Commenting it out for now. - ;(reftex-parse-all) + ;(reftex-parse-all ) (make-local-variable 'reftex-cite-format) - (setq reftex-cite-format 'org) - (define-key org-mode-map (kbd org-ref-insert-cite-key) org-ref-insert-cite-function)) + (setq reftex-cite-format 'org)) + +;; define key for inserting citations +(define-key org-mode-map + (kbd org-ref-insert-cite-key) + org-ref-insert-cite-function) + +(when org-ref-show-citation-on-enter + (setq org-ref-message-timer + (run-with-idle-timer 0.5 t 'org-ref-link-message))) + +(defun org-ref-show-link-messages () + "Turn on link messages. You will see a message in the +minibuffer when on a cite, ref or label link." + (interactive) + (setq org-ref-message-timer + (run-with-idle-timer 0.5 t 'org-ref-link-message)) + ) +(defun org-ref-cancel-link-messages () + "Stop showing messages in minibuffer when on a link." + (interactive) + (cancel-timer org-ref-message-timer)) + +;; this approach caused the selected region to not be highlighted any more. +; (add-hook 'post-command-hook 'org-ref-link-message)) +; (remove-hook 'post-command-hook 'org-ref-link-message)) (add-hook 'org-mode-hook 'org-mode-reftex-setup) @@ -2716,8 +2740,8 @@ ref:test citep:test label:rett (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))) @@ -2727,6 +2751,10 @@ ref:test citep:test label:rett (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 @@ -2737,11 +2765,7 @@ ref:test citep:test label:rett " occurence" (when (or (= count 0) (> count 1)) - "s")))))))) - - -(when org-ref-show-citation-on-enter - (add-hook 'post-command-hook 'org-ref-link-message)) + "s"))))))))) #+END_SRC * Aliases @@ -2818,12 +2842,14 @@ Technically, this function should return a string that is inserted by helm. This (t (insert (concat (if helm-current-prefix-arg - (ido-completing-read "Type: " org-ref-cite-types) + (helm :sources `((name . "link types") + (candidates . ,org-ref-cite-types) + (action . (lambda (x) x)))) 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))) @@ -2874,20 +2900,33 @@ Checks for pdf and doi, and add appropriate functions." (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