summaryrefslogtreecommitdiff
path: root/bog.el
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2015-03-16 22:41:04 -0400
committerKyle Meyer <kyle@kyleam.com>2015-03-16 22:41:04 -0400
commit6218b61a377e193dde9c01db59bb010e0a8b4aed (patch)
tree1c461f67c586a9b1b7eb83f28de773b7c9901287 /bog.el
parent1db31b558b8280d09fd82d8f167a6e4d73e19ead (diff)
downloadbog-6218b61a377e193dde9c01db59bb010e0a8b4aed.tar.gz
Support highlighting citekeys in non-Org buffers
Diffstat (limited to 'bog.el')
-rw-r--r--bog.el13
1 files changed, 11 insertions, 2 deletions
diff --git a/bog.el b/bog.el
index 55d63fe..bcbbb3a 100644
--- a/bog.el
+++ b/bog.el
@@ -1208,12 +1208,17 @@ Topic headings are determined by `bog-topic-heading-level'."
"Face used to highlight text that matches `bog-citekey-format'.")
(defun bog-fontify-non-heading-citekeys (limit)
+ "Highlight non-heading citekey in an Org buffer."
(let (case-fold-search)
(while (re-search-forward bog-citekey-format limit t)
(unless (save-match-data (org-at-heading-p))
(add-text-properties (match-beginning 0) (match-end 0)
'(face bog-citekey-face))))))
+(defvar bog-citekey-font-lock-keywords
+ `((,bog-citekey-format . 'bog-citekey-face))
+ "Citekey font-lock for non-Org buffers.")
+
;;; Minor mode
@@ -1265,10 +1270,14 @@ if ARG is omitted or nil.
:require 'bog
(cond
(bog-mode
- (add-hook 'org-font-lock-hook 'bog-fontify-non-heading-citekeys)
+ (if (derived-mode-p 'org-mode)
+ (add-hook 'org-font-lock-hook 'bog-fontify-non-heading-citekeys)
+ (font-lock-add-keywords nil bog-citekey-font-lock-keywords))
(font-lock-fontify-buffer))
(t
- (remove-hook 'org-font-lock-hook 'bog-fontify-non-heading-citekeys)
+ (if (derived-mode-p 'org-mode)
+ (remove-hook 'org-font-lock-hook 'bog-fontify-non-heading-citekeys)
+ (font-lock-remove-keywords nil bog-citekey-font-lock-keywords))
(font-lock-fontify-buffer)
(when (bound-and-true-p bog-view-mode)
(bog-view-mode -1)))))