summaryrefslogtreecommitdiff
path: root/bog.el
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2014-03-04 22:50:10 -0500
committerKyle Meyer <kyle@kyleam.com>2014-03-04 23:08:19 -0500
commita1ac29ed56473bd2b492f76588a046a537afbcd7 (patch)
tree4fdd17497ffb3000ab10200fbed96f053279acf6 /bog.el
parentdd98bb5e11f04b83f2c72e2e8c3c49e2ecd82100 (diff)
downloadbog-a1ac29ed56473bd2b492f76588a046a537afbcd7.tar.gz
ENH: Add functions to go to citekey heading
Diffstat (limited to 'bog.el')
-rw-r--r--bog.el34
1 files changed, 33 insertions, 1 deletions
diff --git a/bog.el b/bog.el
index f754c31..654341d 100644
--- a/bog.el
+++ b/bog.el
@@ -432,7 +432,39 @@ The citekey is split by groups in `bog-citekey-format' and joined by
(format bog-web-search-url query)))
-;;; Refiling
+;;; Notes-related
+
+(defun bog-goto-citekey-heading-in-buffer ()
+ "Find citekey heading in this buffer.
+The citekey will be taken from the text under point if it matches
+`bog-citekey-format'."
+ (interactive)
+ (let* ((citekey (or (bog-citekey-at-point)
+ (read-string "Enter citekey: ")))
+ (pos (org-find-exact-headline-in-buffer citekey nil t)))
+ (if pos
+ (progn
+ (org-mark-ring-push)
+ (goto-char pos)
+ (org-show-context))
+ (message "Heading for %s not found in buffer" citekey))))
+
+(defun bog-goto-citekey-heading-in-notes ()
+ "Find citekey heading in all Bog notes.
+All org files in `bog-notes-directory' will be searched. The
+citekey will be taken from the text under point if it matches
+`bog-citekey-format'."
+ (interactive)
+ (let* ((citekey (or (bog-citekey-at-point)
+ (read-string "Enter citekey: ")))
+ (marker
+ (org-find-exact-heading-in-directory citekey bog-notes-directory)))
+ (if marker
+ (progn
+ (switch-to-buffer (marker-buffer marker))
+ (goto-char (marker-position marker))
+ (org-show-context))
+ (message "Heading for %s not found in notes" citekey))))
(defun bog-refile ()
"Refile heading with note files.