aboutsummaryrefslogtreecommitdiffhomepage
path: root/generic
diff options
context:
space:
mode:
authorGravatar David Aspinall <da@inf.ed.ac.uk>2007-08-19 11:52:22 +0000
committerGravatar David Aspinall <da@inf.ed.ac.uk>2007-08-19 11:52:22 +0000
commit0e69b71eb94e5fb073d66800240fc3d27e7af6f5 (patch)
treeb2a44cb82f32f1e7faef3d752bccfbcfd6c33615 /generic
parent5e1f6305ec93d9cbc855ba662ec6da951d0d7629 (diff)
pg-assoc-strip-subterm-markup-buf: cache pg-assoc-ann-regexp
Diffstat (limited to 'generic')
-rw-r--r--generic/pg-assoc.el22
1 files changed, 13 insertions, 9 deletions
diff --git a/generic/pg-assoc.el b/generic/pg-assoc.el
index 546aae3b..f212fbc3 100644
--- a/generic/pg-assoc.el
+++ b/generic/pg-assoc.el
@@ -77,21 +77,25 @@ If pg-subterm-first-special-char is unset, return STRING unchanged."
(substring out 0 op))
string))
+(defvar pg-assoc-ann-regexp nil
+ "Cache of regexp for `pg-assoc-strip-subterm-markup-buf'.")
+
(defun pg-assoc-strip-subterm-markup-buf (start end)
"Remove subterm and pbp annotations from region."
- ;; FIXME: create these regexps ahead of time.
(if pg-subterm-start-char
- (let ((ann-regexp
- (concat
- (regexp-quote (char-to-string pg-subterm-start-char))
- "[^"
- (regexp-quote (char-to-string pg-subterm-sep-char))
- "]*"
- (regexp-quote (char-to-string pg-subterm-sep-char)))))
+ (progn
+ (unless pg-assoc-ann-regexp
+ (setq pg-assoc-ann-regexp
+ (concat
+ (regexp-quote (char-to-string pg-subterm-start-char))
+ "[^"
+ (regexp-quote (char-to-string pg-subterm-sep-char))
+ "]*"
+ (regexp-quote (char-to-string pg-subterm-sep-char)))))
(save-restriction
(narrow-to-region start end)
(goto-char start)
- (proof-replace-regexp ann-regexp "")
+ (proof-replace-regexp pg-assoc-ann-regexp "")
(goto-char start)
(proof-replace-string (char-to-string pg-subterm-end-char) "")
(goto-char start)