diff options
author | Kyle Meyer <kyle@kyleam.com> | 2014-03-30 02:12:09 -0400 |
---|---|---|
committer | Kyle Meyer <kyle@kyleam.com> | 2014-03-30 02:24:45 -0400 |
commit | b173d8a2414180c6183fd3906996936a35ecb253 (patch) | |
tree | 8fe4a279fa21172c2d36abfeeb3c0b2166d1c851 /bog.el | |
parent | 72287d6dc7d7319cc401aa605526ca1ba4dc4886 (diff) | |
download | bog-b173d8a2414180c6183fd3906996936a35ecb253.tar.gz |
Define minor mode for Bog
Diffstat (limited to 'bog.el')
-rw-r--r-- | bog.el | 50 |
1 files changed, 41 insertions, 9 deletions
@@ -176,6 +176,11 @@ It should contain the placeholder \"%s\" for the query." :group 'bog :type 'integer) +(defcustom bog-keymap-prefix (kbd "C-c \"") + "Bog keymap prefix." + :group 'bog + :type 'string) + ;;; General utilities @@ -542,23 +547,50 @@ level `bog-refile-maxlevel' are considered." (and (re-search-forward bog-citekey-format limit t) (not (org-at-heading-p)))) -(font-lock-add-keywords 'org-mode - '((bog-non-heading-citekey-p . 'bog-citekey-face))) +(defun bog-add-fontlock () + (font-lock-add-keywords nil + '((bog-non-heading-citekey-p . 'bog-citekey-face))) + (font-lock-fontify-buffer)) + +(defun bog-remove-fontlock () + (font-lock-remove-keywords nil + '((bog-non-heading-citekey-p . 'bog-citekey-face))) + (font-lock-fontify-buffer)) -;;; Keymap +;;; Minor mode (defvar bog-mode-map (let ((map (make-sparse-keymap))) - (define-key map "p" 'bog-find-citekey-pdf) - (define-key map "r" 'bog-rename-staged-pdf-to-citekey) - (define-key map "b" 'bog-find-citekey-bib) - (define-key map "h" 'bog-goto-citekey-heading-in-buffer) - (define-key map "H" 'bog-goto-citekey-heading-in-notes) - (define-key map "w" 'bog-search-citekey-on-web) + (let ((prefix-map (make-sparse-keymap))) + (define-key prefix-map "p" 'bog-find-citekey-pdf) + (define-key prefix-map "r" 'bog-rename-staged-pdf-to-citekey) + (define-key prefix-map "b" 'bog-find-citekey-bib) + (define-key prefix-map "h" 'bog-goto-citekey-heading-in-buffer) + (define-key prefix-map "H" 'bog-goto-citekey-heading-in-notes) + (define-key prefix-map "w" 'bog-search-citekey-on-web) + (define-key map bog-keymap-prefix prefix-map)) map) "Keymap for Bog.") +;;;###autoload +(define-minor-mode bog-mode + "Toggle Bog in this buffer. +With a prefix argument ARG, enable `bog-mode' if ARG is positive, +and disable it otherwise. If called from Lisp, enable the mode if +ARG is omitted or nil. + +\\{bog-mode-map}" + :keymap bog-mode-map + :group 'bog + :lighter " Bog" + :require 'bog + (cond + (bog-mode + (bog-add-fontlock)) + (t + (bog-remove-fontlock)))) + (provide 'bog) ;; bog.el ends here |