summaryrefslogtreecommitdiff
path: root/bog.el
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2014-11-23 15:55:51 -0500
committerKyle Meyer <kyle@kyleam.com>2014-11-23 15:55:51 -0500
commit4229bcb6942584549b3a446b7660548781fca832 (patch)
treeebad078a83fa9a4fa3f08e4bb4974106796f32ea /bog.el
parentbb5ba9e30500baaec922c57ea271b27967bd3d4f (diff)
downloadbog-4229bcb6942584549b3a446b7660548781fca832.tar.gz
Add command to open first citekey heading link
Diffstat (limited to 'bog.el')
-rw-r--r--bog.el23
1 files changed, 23 insertions, 0 deletions
diff --git a/bog.el b/bog.el
index 62722d8..3840ea4 100644
--- a/bog.el
+++ b/bog.el
@@ -767,6 +767,28 @@ current buffer."
'bog-all-heading-citekeys)))
(insert (bog-select-citekey (funcall citekey-func)))))
+(defun bog-open-first-citekey-link (&optional no-context)
+ "Open first link under citekey heading.
+
+The citekey will be taken from the text under point if it matches
+`bog-citekey-format' or from the current tree.
+
+With prefix argument NO-CONTEXT, a prompt will open to select
+from all citekeys for headings in notes. This same prompt will be
+opened if locating a citekey from context fails."
+ (interactive "P")
+ (let* ((citekey (bog-citekey-from-point-or-all-headings no-context))
+ (marker
+ (org-find-exact-heading-in-directory citekey bog-notes-directory)))
+ (if marker
+ (with-current-buffer (marker-buffer marker)
+ (org-with-wide-buffer
+ (goto-char marker)
+ (org-narrow-to-subtree)
+ (org-next-link)
+ (org-open-at-point)))
+ (message "Heading for %s not found in notes" citekey))))
+
;;; Font-lock
@@ -873,6 +895,7 @@ chosen."
(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 "i" 'bog-citekey-tree-to-indirect-buffer)
+ (define-key prefix-map "l" 'bog-open-first-citekey-link)
(define-key prefix-map "r" 'bog-rename-staged-file-to-citekey)
(define-key prefix-map "s" 'bog-search-notes)
(define-key prefix-map "w" 'bog-refile)