Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(fix) Replace olp with heading list #2336

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hwiorn
Copy link
Contributor

@hwiorn hwiorn commented Mar 28, 2023

Motivation for this change

Closes #2335

After org-roam-capture--fill-template which actually calls (kill-buffer) inside it, strangely kill-buffer reverts buffer position from (point-min) to original. So re-search-forward loop can't find headings correct and org-roam-capture-find-or-create-olp keep creating headings if the buffer is already visited and buffer position is under below the OLP.

So I change olp to (setq headings (mapcar #'org-roam-capture--fill-template olp)) then use it in the search loop.

After this patch, below test code doesn't make new "Tasks" heading again when it exists already.

(let ((org-roam-directory (expand-file-name org-roam-dailies-directory org-roam-directory))
      (org-roam-dailies-directory "./")
      (org-roam-dailies-capture-templates
       `(("t" "Tasks" entry "* %?"
          :if-new (file+head+olp "test.org" ;; "%<%Y-%m-%d>.org"
                                 "* Notes\n\n* Tasks\n\n* Journal"
                                 ("Tasks" "[2023-03-28 Tue]"))))))
  (save-window-excursion
    (org-roam-dailies--capture (current-time) t)))

@hwiorn hwiorn changed the title Replace olp with heading list (fix) Replace olp with heading list Mar 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

org-roam-dailies-capture make OLP incorrectly when captured again
1 participant