summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2015-02-15 22:11:43 -0500
committerKyle Meyer <kyle@kyleam.com>2015-02-15 22:11:43 -0500
commit83fa0e4993ed620e46906cbde9f3ccd1d760aed5 (patch)
treee0d7728afd318ea2c3815a01bae42ab022ba548f
parentc49d398dd64638944db9dd5e54e41918f7485159 (diff)
downloadbog-83fa0e4993ed620e46906cbde9f3ccd1d760aed5.tar.gz
Use variable to store citekey syntax table
-rw-r--r--bog.el23
1 files changed, 12 insertions, 11 deletions
diff --git a/bog.el b/bog.el
index 3034356..e060e9f 100644
--- a/bog.el
+++ b/bog.el
@@ -197,6 +197,15 @@ added citekeys, clear the cache with `bog-clear-citekey-cache'."
:group 'bog
:type 'boolean)
+(defvar bog-citekey-syntax-table
+ (let ((st (make-syntax-table org-mode-syntax-table)))
+ (modify-syntax-entry ?- "w" st)
+ (modify-syntax-entry ?_ "w" st)
+ st)
+ "Syntax table used when working with citekeys.
+Like `org-mode-syntax-table', but hyphens and underscores are
+treated as word characters.")
+
;;; Citekey methods
@@ -241,21 +250,13 @@ If NO-CONTEXT is non-nil, immediately fall back."
"Prompt for citekey from CITEKEYS."
(org-icompleting-read "Select citekey: " citekeys))
-(defmacro bog--with-citekey-syntax (&rest body)
- "Execute BODY with hyphen and underscore as word constituents."
- (declare (indent 0))
- `(with-syntax-table (copy-syntax-table (syntax-table))
- (modify-syntax-entry ?- "w")
- (modify-syntax-entry ?_ "w")
- ,@body))
-
(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."
(save-excursion
- (bog--with-citekey-syntax
+ (with-syntax-table bog-citekey-syntax-table
(skip-syntax-backward "w")
(let (case-fold-search)
(and (looking-at bog-citekey-format)
@@ -998,7 +999,7 @@ With argument ARG, do it ARG times."
(or arg (setq arg 1))
(if (< arg 0)
(bog-previous-non-heading-citekey (- arg))
- (bog--with-citekey-syntax
+ (with-syntax-table bog-citekey-syntax-table
(skip-syntax-forward "w")
(let (case-fold-search)
(while (and (> arg 0)
@@ -1012,7 +1013,7 @@ With argument ARG, do it ARG times."
With argument ARG, do it ARG times."
(interactive "p")
(or arg (setq arg 1))
- (bog--with-citekey-syntax
+ (with-syntax-table bog-citekey-syntax-table
(let (case-fold-search)
(while (and (> arg 0)
(re-search-backward bog-citekey-format nil t))