diff options
author | Kyle Meyer <kyle@kyleam.com> | 2016-01-22 02:11:13 -0500 |
---|---|---|
committer | Kyle Meyer <kyle@kyleam.com> | 2016-01-22 02:11:37 -0500 |
commit | 2cefc2c03ab152e0c8aef6152811a149d2ede5ca (patch) | |
tree | 38f431aabc1d814769eb1fe254a28bb90b362dcb | |
parent | c1a295da9b285aecb9e750392f797fde4727bc45 (diff) | |
download | bog-2cefc2c03ab152e0c8aef6152811a149d2ede5ca.tar.gz |
Don't assume font-lock-ensure is defined
Fixes #5.
Also,
* Use font-lock-flush instead of font-lock-ensure, which wasn't removing
Bog-related highlighting when turning off bog-mode.
* Check that font-lock-mode is enabled before calling font-lock
function.
-rw-r--r-- | bog.el | 32 |
1 files changed, 19 insertions, 13 deletions
@@ -1295,6 +1295,11 @@ Topic headings are determined by `bog-topic-heading-level'." `((,bog-citekey-format . 'bog-citekey-face)) "Citekey font-lock for non-Org buffers.") +(defvar bog-font-lock-function + (if (fboundp 'font-lock-flush) + #'font-lock-flush + #'font-lock-fontify-buffer)) + ;;; Minor mode @@ -1344,19 +1349,20 @@ if ARG is omitted or nil. :group 'bog :lighter " Bog" :require 'bog - (cond - (bog-mode - (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-ensure)) - (t - (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-ensure) - (when (bound-and-true-p bog-view-mode) - (bog-view-mode -1))))) + (progn + (cond + (bog-mode + (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))) + (t + (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)) + (when (bound-and-true-p bog-view-mode) + (bog-view-mode -1)))) + (when font-lock-mode + (funcall bog-font-lock-function)))) ;;; View minor mode |