From d8fa3ce5873819eed0760b174226ce780178e4d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20K=C3=B6hn?= Date: Fri, 4 Jan 2019 11:46:01 +0100 Subject: [PATCH 1/2] Notes: narrow to the complete template instead of last org-heading Before, a note template consisting of sub-headings would result in only showing that sub-heading, e.g. using a template like this: * Author (XXX): Title ** takeaways ** new questions ** additional literature would only narrow to additional literature. Now we narrow to the complete template instead. A side-effect is that for non-org templates the point is now at the start of the template instead of the end. --- bibtex-completion.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bibtex-completion.el b/bibtex-completion.el index 9801ad9..081c54d 100644 --- a/bibtex-completion.el +++ b/bibtex-completion.el @@ -1327,9 +1327,9 @@ line." (bibtex-completion-notes-mode 1)) ; Create a new entry: (goto-char (point-max)) - (insert (s-format bibtex-completion-notes-template-one-file - 'bibtex-completion-apa-get-value - entry))) + (save-excursion (insert (s-format bibtex-completion-notes-template-one-file + 'bibtex-completion-apa-get-value + entry)))) (when (eq major-mode 'org-mode) (org-narrow-to-subtree) (re-search-backward "^\*+ " nil t) From 03fac83bf2cde4fa798c6bbed0f92deee4c4e70c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20K=C3=B6hn?= Date: Fri, 4 Jan 2019 12:02:36 +0100 Subject: [PATCH 2/2] fix note narrowing to actually narrow to the correct subtree --- bibtex-completion.el | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/bibtex-completion.el b/bibtex-completion.el index 081c54d..a85df3b 100644 --- a/bibtex-completion.el +++ b/bibtex-completion.el @@ -1329,13 +1329,14 @@ line." (goto-char (point-max)) (save-excursion (insert (s-format bibtex-completion-notes-template-one-file 'bibtex-completion-apa-get-value - entry)))) - (when (eq major-mode 'org-mode) - (org-narrow-to-subtree) - (re-search-backward "^\*+ " nil t) - (org-cycle-hide-drawers nil) - (goto-char (point-max)) - (bibtex-completion-notes-mode 1)))))) + entry))) + (re-search-forward "^*+ " nil t)) + (when (eq major-mode 'org-mode) + (org-narrow-to-subtree) + (re-search-backward "^\*+ " nil t) + (org-cycle-hide-drawers nil) + (goto-char (point-max)) + (bibtex-completion-notes-mode 1)))))) (defun bibtex-completion-buffer-visiting (file) (or (get-file-buffer file)