summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS6
-rw-r--r--README1
-rw-r--r--README.md1
-rw-r--r--bog.el23
4 files changed, 31 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index 6bbf533..f6afb72 100644
--- a/NEWS
+++ b/NEWS
@@ -25,6 +25,12 @@
- New command =bog-insert-heading-citekey= prompts with all heading
citekeys and inserts the selected one at point.
+- New command =bog-open-first-citekey-link= opens the first link found
+ under the subtree of a citekey. This is particularly useful if you
+ place the main link for the study (usually a DOI link) as the first
+ link in the citekey's subtree. The citekey is either taken from at
+ point or selected from all heading citekeys.
+
** Other changes
- =bog-goto-citekey-heading-in-buffer= and
diff --git a/README b/README
index 314b3b5..3e6eb3c 100644
--- a/README
+++ b/README
@@ -106,6 +106,7 @@ Other useful functions include
- =bog-sort-topic-headings-in-buffer=
- =bog-sort-topic-headings-in-notes=
- =bog-insert-heading-citekey=
+- =bog-open-first-citekey-link=
* Variables
diff --git a/README.md b/README.md
index 75246bd..ebf8698 100644
--- a/README.md
+++ b/README.md
@@ -95,6 +95,7 @@ Other useful functions include
- `bog-sort-topic-headings-in-buffer`
- `bog-sort-topic-headings-in-notes`
- `bog-insert-heading-citekey`
+- `bog-open-first-citekey-link`
# Variables
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)