summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2016-05-23 01:47:20 -0400
committerKyle Meyer <kyle@kyleam.com>2016-05-23 01:47:20 -0400
commit11d6dce0d8e40ed90eceabbd4db9e4995a18ee45 (patch)
tree52159c6a7bd98df2e4254492c7662aac62944ba7
parenta6b8946e81e07d4dd845c28e5ae136cd78105cd8 (diff)
downloadbog-11d6dce0d8e40ed90eceabbd4db9e4995a18ee45.tar.gz
Add bog-citekey-format-allow-at option
-rw-r--r--NEWS8
-rw-r--r--bog.el29
2 files changed, 31 insertions, 6 deletions
diff --git a/NEWS b/NEWS
index 0ad3767..1f1a63b 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,13 @@
Bog NEWS -- history of user-visible changes -*- mode: org; -*-
+* master (unreleased)
+
+** New features
+
+- New option ~bog-citekey-format-allow-at~, which can be disabled to
+ make it easier to use Bog commands on citekeys that use Pandoc's
+ @citekey format.
+
* v1.2.0
** New features
diff --git a/bog.el b/bog.el
index 9e868ba..e0a2dbe 100644
--- a/bog.el
+++ b/bog.el
@@ -63,6 +63,8 @@ then lower case letters.
The format should be restricted to word characters and anchored
by word boundaries (i.e. '\\b..\\b' or '\\\\=<..\\>').
+`bog-citekey-format-allow-at' controls whether '@' is considered
+a word character.
This is case-sensitive (i.e., `case-fold-search' will be set to
nil).
@@ -77,6 +79,23 @@ settings:
bibtex-autokey-year-title-separator \"\")"
:type 'regexp)
+(defcustom bog-citekey-format-allow-at t
+ "Treat '@' as a word charcter, as it is in Org mode.
+
+If this value is nil, Bog functions treat '@' as a punctuation
+character, which allows them to work on Pandoc's @citekey format.
+
+Warning: Setting this variable after Bog is loaded does not have
+an effect. However, it can be changed at any time through the
+Customize interface."
+ :package-version '(bog . "1.3.0")
+ :set (lambda (var val)
+ (set var val)
+ (when (boundp 'bog-citekey-syntax-table)
+ (modify-syntax-entry ?@ (if val "w" ".")
+ bog-citekey-syntax-table)))
+ :type 'boolean)
+
(defcustom bog-citekey-web-search-groups '(1 2 3)
"List of citekey subexpressions to use for web search.
The default groups correspond to the last name of the first
@@ -237,14 +256,15 @@ kills the indirect buffer created by the previous call."
(let ((st (make-syntax-table text-mode-syntax-table)))
(modify-syntax-entry ?- "w" st)
(modify-syntax-entry ?_ "w" st)
- (modify-syntax-entry ?@ "w" st)
+ (modify-syntax-entry ?@ (if bog-citekey-format-allow-at "w" ".") st)
(modify-syntax-entry ?\" "\"" st)
(modify-syntax-entry ?\\ "_" st)
(modify-syntax-entry ?~ "_" st)
st)
"Syntax table used when working with citekeys.
Like `org-mode-syntax-table', but hyphens and underscores are
-treated as word characters.")
+treated as word characters. '@' will be considered a word
+character if `bog-citekey-format-allow-at' is non-nil.")
;;; Citekey methods
@@ -256,10 +276,7 @@ treated as word characters.")
(string-match-p (format "\\`%s\\'" bog-citekey-format) text))))
(defun bog-citekey-at-point ()
- "Return citekey at point.
-The citekey must have the format specified by
-`bog-citekey-format'. Hyphens and underscores are considered as
-word constituents."
+ "Return citekey at point."
(save-excursion
(with-syntax-table bog-citekey-syntax-table
(skip-syntax-backward "w")