X-Git-Url: https://git.donarmstrong.com/?p=org-ref.git;a=blobdiff_plain;f=org-ref.org;h=e4baf37dc61040d3dde844397c8b4d1ae2650e5a;hp=ae39ab90db19d312ce8300a99a63dfab005434f9;hb=7eeb57bb2e9a7f24f881d371cd5c4700b8586087;hpb=9afe00c1615fd24ee658620990ac03448279f04a diff --git a/org-ref.org b/org-ref.org index ae39ab9..e4baf37 100644 --- a/org-ref.org +++ b/org-ref.org @@ -2652,7 +2652,6 @@ Sometimes it may be helpful to manually change the order of citations. These fun (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. @@ -2666,17 +2665,38 @@ ref:test citep:test label:rett (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 @@ -2690,20 +2710,24 @@ ref:test citep:test label:rett (forward-line 4) (point)))))))) + (defun org-ref-link-message () "Print a minibuffer message about the link that point is on." (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 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)))) @@ -2711,12 +2735,14 @@ ref:test citep:test label:rett ((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" (when (or (= count 0) (> count 1)) - "s")))))))) + "s"))))))))) + (when org-ref-show-citation-on-enter (add-hook 'post-command-hook 'org-ref-link-message)) @@ -2769,6 +2795,7 @@ Now, let us define a function that inserts the cite links: "Insert selected KEYS as cite link. Append KEYS if you are on a link. Technically, this function should return a string that is inserted by helm. This function does the insertion and gives helm an empty string to insert. This lets us handle appending to a link properly." (let* ((object (org-element-context))) + (message-box "prefix is %s" helm-current-prefix-arg) (cond ;; case where we are in a link ((and (equal (org-element-type object) 'link) @@ -2800,8 +2827,8 @@ Technically, this function should return a string that is inserted by helm. This 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))) @@ -2852,20 +2879,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