summaryrefslogtreecommitdiff
path: root/bog.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.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.el')
-rw-r--r--bog.el23
1 files changed, 19 insertions, 4 deletions
diff --git a/bog.el b/bog.el
index 18abe4d..47d7d07 100644
--- a/bog.el
+++ b/bog.el
@@ -73,6 +73,15 @@ settings:
:group 'bog
:type 'string)
+(defcustom bog-allowed-before-citekey
+ "\\(\n\\|\\s-\\|(\\|\\[\\|{\\|<\\|,\\)"
+ "Regex that specifies characters allowed before a citekey.
+This may need to be modified if you have a custom
+`bog-citekey-format' or if you tend to used a certain character
+before citekeys that isn't included above."
+ :group 'bog
+ :type 'string)
+
(defcustom bog-citekey-property "CUSTOM_ID"
"Property name used to store citekey.
The default corresponds to the default value of
@@ -241,10 +250,16 @@ year, and the first meaningful word in the title)."
groups delim)))
(defun bog-citekey-at-point ()
- (let ((maybe-citekey (thing-at-point 'word)))
- (when (and maybe-citekey
- (bog-citekey-p maybe-citekey))
- (substring-no-properties maybe-citekey))))
+ "Return citekey at point.
+The citekey must have the format specified by
+`bog-citekey-format' and, if not at the beginning of the buffer,
+be preceded by a characters in `bog-allowed-before-citekey'."
+ (save-excursion
+ (unless (bobp)
+ (re-search-backward bog-allowed-before-citekey)
+ (forward-char 1))
+ (when (looking-at bog-citekey-format)
+ (match-string-no-properties 0))))
(defun bog-citekey-from-notes ()
"Get the citekey from the context of the Org file."