summaryrefslogtreecommitdiff
path: root/bog.el
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2014-12-11 23:45:51 -0500
committerKyle Meyer <kyle@kyleam.com>2014-12-11 23:45:51 -0500
commitce74785920d6234072eb2ebef63bd140a25534c2 (patch)
tree237e499a625028bcfb5e8fdf04477acdc56a0afa /bog.el
parent06697a74f6725202b7afe67d4eec28343f365bad (diff)
downloadbog-ce74785920d6234072eb2ebef63bd140a25534c2.tar.gz
Add function to get citekeys in buffer
Diffstat (limited to 'bog.el')
-rw-r--r--bog.el18
1 files changed, 12 insertions, 6 deletions
diff --git a/bog.el b/bog.el
index 0d353c7..20d1f32 100644
--- a/bog.el
+++ b/bog.el
@@ -320,13 +320,19 @@ word constituents."
(defun bog-citekeys-in-file (file)
"Return all citekeys in FILE."
- (let (refs
- case-fold-search)
- (with-temp-buffer
- (insert-file-contents file)
+ (with-temp-buffer
+ (insert-file-contents file)
+ (bog-citekeys-in-buffer)))
+
+(defun bog-citekeys-in-buffer ()
+ "Return all citekeys in current buffer."
+ (save-excursion
+ (let (refs
+ case-fold-search)
+ (goto-char (point-min))
(while (re-search-forward bog-citekey-format nil t)
- (push (match-string-no-properties 0) refs)))
- (-distinct refs)))
+ (push (match-string-no-properties 0) refs))
+ (-distinct refs))))
(defun bog-heading-citekeys-in-file (file)
"Return all citekeys in headings of FILE."