summaryrefslogtreecommitdiff
path: root/bog-tests.el
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2014-10-29 21:38:19 -0400
committerKyle Meyer <kyle@kyleam.com>2014-10-29 21:38:19 -0400
commit08d71bf1b687f6cd9be78489369a8e276714f808 (patch)
tree0dd3c037639652c3c84f5412da5fc84a2c5a96cf /bog-tests.el
parent3dcb4aa8b0546b1ac397f14c289952cc1d73eeb0 (diff)
downloadbog-08d71bf1b687f6cd9be78489369a8e276714f808.tar.gz
Fix bog-citekey-at-point for hyphenated citekeys
Because bog-citekey-at-point used "(thing-at-point 'word)", it didn't handle hyphenated citekeys properly. Now the function relies on a set of characters that are allowed to precede citekeys.
Diffstat (limited to 'bog-tests.el')
-rw-r--r--bog-tests.el29
1 files changed, 28 insertions, 1 deletions
diff --git a/bog-tests.el b/bog-tests.el
index 6a261f4..c1c98a2 100644
--- a/bog-tests.el
+++ b/bog-tests.el
@@ -41,13 +41,40 @@
;; `bog-citekey-at-point'
-(ert-deftest bog-citekey-at-point ()
+(ert-deftest bog-citekey-at-point-bob ()
(let ((citekey "name2010word"))
(with-temp-buffer
(insert citekey)
(goto-char (point-min))
(should (equal (bog-citekey-at-point) citekey)))))
+(ert-deftest bog-citekey-at-point-newline ()
+ (let ((citekey "name2010word"))
+ (with-temp-buffer
+ (insert "\n" citekey)
+ (should (equal (bog-citekey-at-point) citekey)))))
+
+(ert-deftest bog-citekey-at-point-parens ()
+ (let ((citekey "name2010word"))
+ (with-temp-buffer
+ (insert "\n(" citekey ")")
+ (backward-char 2)
+ (should (equal (bog-citekey-at-point) citekey)))))
+
+(ert-deftest bog-citekey-at-point-spaces ()
+ (let ((citekey "name2010word"))
+ (with-temp-buffer
+ (insert "\n " citekey " ")
+ (backward-char 2)
+ (should (equal (bog-citekey-at-point) citekey)))))
+
+(ert-deftest bog-citekey-at-point-with-hyphen ()
+ (let ((citekey "hyphen-name2010word"))
+ (with-temp-buffer
+ (insert citekey)
+ (goto-char (point-min))
+ (should (equal (bog-citekey-at-point) citekey)))))
+
;; `bog-citekey-from-tree'
(ert-deftest bog-citekey-from-heading-title-current-level ()