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))
;; for tblname, it is not enough to get word boundary
;; tab-little and tab-little-2 match then.
(count-matches (format "^#\\+tblname:\\s-*%s\\b[^-:]" label) (point-min) (point-max))
- (count-matches (format "\\label{%s}\\b" label) (point-min) (point-max))
+ (count-matches (format "\\label{%s}" label) (point-min) (point-max))
;; this is the org-format #+label:
(count-matches (format "^#\\+label:\\s-*%s\\b[^-:]" label) (point-min) (point-max))
(let ((custom-id-count 0))
((equal helm-current-prefix-arg '(16))
(insert
(format "[[#%s]]" label)))
- ))))))))
+ ))
+ ))))))
#+END_SRC
#+RESULTS:
;; message some context about the label we are referring to
((string= type "ref")
- (message (org-ref-get-label-context
- (org-element-property :path object))))
+ (message "%scount: %s"
+ (org-ref-get-label-context
+ (org-element-property :path object))
+ (org-ref-count-labels
+ (org-element-property :path object))))
((string= type "eqref")
- (message (org-ref-get-label-context
- (org-element-property :path object))))
+ (message "%scount: %s"
+ (org-ref-get-label-context
+ (org-element-property :path object))
+ (org-ref-count-labels
+ (org-element-property :path object))))
;; message the count
((string= type "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"))))