summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2015-03-16 22:23:25 -0400
committerKyle Meyer <kyle@kyleam.com>2015-03-16 22:23:25 -0400
commit5a5d372a06c7bbd2572944a8291822b395d24b7a (patch)
tree740dc67ce8537c15d3f4deb686b959101ea4bd39
parent82525179e283b9eb35bad87490babf132a6fff1d (diff)
downloadbog-5a5d372a06c7bbd2572944a8291822b395d24b7a.tar.gz
Make context-functions check if in Org mode
This will allow commands that use the context functions to work outside of Org.
-rw-r--r--bog.el31
1 files changed, 17 insertions, 14 deletions
diff --git a/bog.el b/bog.el
index a3823a5..17dc3c7 100644
--- a/bog.el
+++ b/bog.el
@@ -316,14 +316,15 @@ word constituents."
(defun bog-citekey-from-tree ()
"Retrieve citekey from first parent heading associated with citekey."
- (org-with-wide-buffer
- (let (maybe-citekey)
- (while (and (not (setq maybe-citekey (bog-citekey-from-heading)))
- ;; This isn't actually safe in Org mode <= 8.2.10.
- ;; Fixed in Org mode commit
- ;; 9ba9f916e87297d863c197cb87199adbb39da894.
- (ignore-errors (org-up-heading-safe))))
- maybe-citekey)))
+ (when (derived-mode-p 'org-mode)
+ (org-with-wide-buffer
+ (let (maybe-citekey)
+ (while (and (not (setq maybe-citekey (bog-citekey-from-heading)))
+ ;; This isn't actually safe in Org mode <= 8.2.10.
+ ;; Fixed in Org mode commit
+ ;; 9ba9f916e87297d863c197cb87199adbb39da894.
+ (ignore-errors (org-up-heading-safe))))
+ maybe-citekey))))
(defun bog-citekey-from-heading ()
"Retrieve citekey from current heading title or property."
@@ -332,15 +333,17 @@ word constituents."
(defun bog-citekey-from-heading-title ()
"Retrieve citekey from heading title."
- (unless (org-before-first-heading-p)
- (let ((heading (org-no-properties (org-get-heading t t))))
- (and (bog-citekey-p heading)
- heading))))
+ (when (derived-mode-p 'org-mode)
+ (unless (org-before-first-heading-p)
+ (let ((heading (org-no-properties (org-get-heading t t))))
+ (and (bog-citekey-p heading)
+ heading)))))
(defun bog-citekey-from-property ()
"Retrieve citekey from `bog-citekey-property'."
- (let ((ck (org-entry-get (point) bog-citekey-property)))
- (and ck (bog-citekey-p ck) ck)))
+ (when (derived-mode-p 'org-mode)
+ (let ((ck (org-entry-get (point) bog-citekey-property)))
+ (and ck (bog-citekey-p ck) ck))))
(defun bog-citekey-p (text)
"Return non-nil if TEXT matches `bog-citekey-format'."