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:
#+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)
(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))
((equal helm-current-prefix-arg '(16))
(insert
(format "[[#%s]]" label)))
- ))))))))
+ ))
+ ))))))
#+END_SRC
#+RESULTS:
;; bibtex format
(concat "\\" ,type (when desc (org-ref-format-citation-description desc)) "{"
(mapconcat (lambda (key) key) (org-ref-split-and-strip-string keyword) ",")
- "}"))))))
+ "}")))
+ ;; for markdown we generate pandoc citations
+ ((eq format 'md)
+ (cond
+ (desc ;; pre and or post text
+ (let* ((text (split-string desc "::"))
+ (pre (car text))
+ (post (cadr text)))
+ (concat
+ (format "[@%s," keyword)
+ (when pre (format " %s" pre))
+ (when post (format ", %s" post))
+ "]")))
+ (t
+ (format "[%s]"
+ (mapconcat
+ (lambda (key) (concat "@" key))
+ (org-ref-split-and-strip-string keyword)
+ "; "))))))))
#+END_SRC
(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
(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)."
(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"))))
helm-bibtex-fallback-options))
(setq helm-bibtex-fallback-options
- (-insert-at 1 '("Open Web of Science" . (lambda () (browse-url "http://apps.webofknowledge.com")))
- helm-bibtex-fallback-options))
+ (-insert-at 1 '("WOS" . "http://gateway.webofknowledge.com/gateway/Gateway.cgi?topic=%s&GWVersion=2&SrcApp=WEB&SrcAuth=HSB&DestApp=UA&DestLinkType=GeneralSearchSummary") helm-bibtex-fallback-options))
#+END_SRC
** A helm click menu