X-Git-Url: https://git.donarmstrong.com/?p=org-ref.git;a=blobdiff_plain;f=org-ref.org;h=c1cebb2676be63d352c1244071429f7b435e6c07;hp=d2674294649c8282d73beab5fbde3c8ce130247e;hb=a049a93ecdd9983b343f26ba3d9a6f0da8721347;hpb=43e5b01ab93725dd43204248a80edd30ce04e7de diff --git a/org-ref.org b/org-ref.org index d267429..c1cebb2 100644 --- a/org-ref.org +++ b/org-ref.org @@ -12,6 +12,7 @@ This document is an experiment at creating a literate program to provide similar 4. Exportable links to LaTeX 5. Utility functions for dealing with bibtex files and org-files +Some additional features include 1. Get minibuffer messages for the cite/ref/label link under point With helm integration (default) you can: @@ -484,7 +485,7 @@ This code provides some functions to generate a simple sorted bibliography in ht #+BEGIN_SRC emacs-lisp :tangle org-ref.el (defun org-ref-get-bibtex-keys () - "return a list of unique keys in the buffer." + "Return a list of unique keys in the buffer." (let ((keys '())) (org-element-map (org-element-parse-buffer) 'link (lambda (link) @@ -494,7 +495,9 @@ This code provides some functions to generate a simple sorted bibliography in ht (key (org-ref-split-and-strip-string (plist-get plist ':path))) (when (not (-contains? keys key)) - (setq keys (append keys (list key))))))))) + (setq keys (append keys (list key)))))))) + ;; set with-affiliated to get keys in captions + nil nil nil t) ;; Sort keys alphabetically (setq keys (cl-sort keys 'string-lessp :key 'downcase)) keys)) @@ -1296,7 +1299,8 @@ Use C-u C-u to insert a [[#custom-id]] link ((equal helm-current-prefix-arg '(16)) (insert (format "[[#%s]]" label))) - )))))))) + )) + )))))) #+END_SRC #+RESULTS: @@ -2610,13 +2614,21 @@ Makes a new buffer with clickable links." (org-element-map (org-element-parse-buffer) 'link (lambda (link) (let ((plist (nth 1 link))) - (when (equal (plist-get plist ':type) "cite") - (dolist (key (org-ref-split-and-strip-string (plist-get plist ':path)) ) + (when (-contains? org-ref-cite-types (plist-get plist :type)) + (dolist (key (org-ref-split-and-strip-string (plist-get plist :path))) (when (not (index key bibtex-keys)) - (setq bad-citations (append bad-citations - `(,(format "%s [[elisp:(progn (switch-to-buffer-other-frame \"%s\")(goto-char %s))][not found here]]\n" - key (buffer-name)(plist-get plist ':begin))))) - )))))) + (message-box "%s" link) + (setq + bad-citations + (append + bad-citations + `(,(format "%s [[elisp:(progn (switch-to-buffer-other-frame \"%s\")(goto-char %s))][not found here]]\n" + key + (buffer-name) + (plist-get plist :begin))))) + ))))) + ;; set with-affilates to t to get citations in a caption + nil nil nil t) (if bad-citations (progn @@ -2655,46 +2667,18 @@ Here we develop a similar idea, but instead of an org-buffer with links, we crea (org-element-map (org-element-parse-buffer) 'link (lambda (link) (let ((plist (nth 1 link))) - (when (-contains? org-ref-cite-types (plist-get plist ':type)) - (dolist (key (org-ref-split-and-strip-string (plist-get plist ':path)) ) + (when (-contains? org-ref-cite-types (plist-get plist :type)) + (dolist (key (org-ref-split-and-strip-string (plist-get plist :path)) ) (when (not (index key bibtex-keys)) - (goto-char (plist-get plist ':begin)) + (goto-char (plist-get plist :begin)) (re-search-forward key) (push (cons key (point-marker)) bad-citations))) - )))) + ))) + ;; add with-affiliates to get cites in caption + nil nil nil t) (goto-char cp) bad-citations)) -;; It seems I forgot I already defined this earlier! -;; (defun org-ref-get-labels () -;; "Returns a list of known labels in the org document. These include label links, latex labels, label tags, and table names. The list contains all labels, not just unique ones. -;; " -;; (let ((cp (point)) -;; (labels '())) -;; (goto-char (point-min)) -;; (while (re-search-forward "[^#+]label:\\(.*\\)\\s-" nil t) -;; (push (match-string 1) labels)) - -;; (goto-char (point-min)) -;; (while (re-search-forward "\\label{\\(.*\\)}\\s-?" nil t) -;; (push (match-string 1) labels)) - -;; (goto-char (point-min)) -;; (while (re-search-forward "^#\\+label:\\s-*\\(.*\\)" nil t) -;; (push (match-string 1) labels)) - -;; (goto-char (point-min)) -;; (while (re-search-forward "^#\\+tblname:\\s-*\\(.*\\)" nil t) -;; (push (match-string 1) labels)) -;; ;; check for CUSTOM_ID -;; (org-map-entries -;; (lambda () -;; (when (org-entry-get (point) "CUSTOM_ID") -;; (push (org-entry-get (point) "CUSTOM_ID") labels)))) -;; ;; return to original place -;; (goto-char cp) -;; labels)) - (defun org-ref-bad-ref-candidates () "Returns a list of conses (ref . marker) where ref is a ref link that does not point to anything (i.e. a label)." @@ -3272,10 +3256,12 @@ C-u C-u will change the key at point to the selected keys. (replace-regexp-in-string (car (org-ref-get-bibtex-key-and-file)) ; key (mapconcat 'identity keys ",") ; new keys - (org-element-property :raw-link object) - ) + (org-element-property :raw-link object)) ;; replace space at end to avoid collapsing into next word. - last-char))) + last-char)) + ;; and we want to go to the end of the new link + (goto-char + (org-element-property :end (org-element-context)))) (t (message "Not found"))))