From a1ac29ed56473bd2b492f76588a046a537afbcd7 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Tue, 4 Mar 2014 22:50:10 -0500 Subject: ENH: Add functions to go to citekey heading --- README | 2 ++ bog-readme.org | 2 ++ bog.el | 34 +++++++++++++++++++++++++++++++++- 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/README b/README index 8a4d704..fd95694 100644 --- a/README +++ b/README @@ -206,5 +206,7 @@ and taking notes with Org, not on writing research articles with Org. | (define-key bog-map "p" 'bog-find-citekey-pdf) | (define-key bog-map "r" 'bog-rename-staged-pdf-to-citekey) | (define-key bog-map "b" 'bog-find-citekey-bib) + | (define-key bog-map "h" 'bog-goto-citekey-heading-in-buffer) + | (define-key bog-map "H" 'bog-goto-citekey-heading-in-notes) | (define-key bog-map "w" 'bog-search-citekey-on-web) `---- diff --git a/bog-readme.org b/bog-readme.org index 2a78e31..2bd6c99 100644 --- a/bog-readme.org +++ b/bog-readme.org @@ -156,5 +156,7 @@ This can be achieved by placing the code below in your .emacs file. (define-key bog-map "p" 'bog-find-citekey-pdf) (define-key bog-map "r" 'bog-rename-staged-pdf-to-citekey) (define-key bog-map "b" 'bog-find-citekey-bib) + (define-key bog-map "h" 'bog-goto-citekey-heading-in-buffer) + (define-key bog-map "H" 'bog-goto-citekey-heading-in-notes) (define-key bog-map "w" 'bog-search-citekey-on-web) #+end_src 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. -- cgit v1.2.3