diff options
-rw-r--r-- | NEWS | 4 | ||||
-rw-r--r-- | README.org | 6 | ||||
-rw-r--r-- | bog.el | 13 |
3 files changed, 19 insertions, 4 deletions
@@ -22,6 +22,10 @@ - All Bog commands now work outside of Org buffers. To access them, bind =bog-command= a global key. +- When Bog mode is turned on in non-Org buffers, text matching + bog-citekey-format is now highlighted, without relying on + Org-specific font-lock mechanisms. + - New command =bog-citekey-tree-to-indirect-buffer= opens the subtree for a citekey in an indirect buffer. The citekey is either taken from at point or selected from all heading citekeys. @@ -143,8 +143,10 @@ The variables below are important for specifying how Bog behaves. A keymap is defined for Bog under the prefix =C-c "=. If you prefer something else (like =C-c b=), set =bog-keymap-prefix=. -Many of the Bog functions are useful outside of an Org buffer, so you -can also bind =bog-command-map= to a global key. +Many of the Bog functions are useful outside of an Org buffer. You +can turn Bog minor mode on (=bog-mode=) in non-Org buffers to get +access to the keymap and citekey highlighting. To make Bog commands +available from any buffer, bind =bog-command-map= to a global key. * Other approaches @@ -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))))) |