5

I was just wondering if there is a way to create a standard set of sections for my daily journal entry. So if I want a section for Todos, and another section for meetings, etc. Is it possible to just create a standard template in emacs that gets built when a new journal file is created?

UPDATED TO CLARIFY:

I just wanted to clarify any ambiguity. Org-journal will create a new empty journal file for each day. The file is usually named with the date, so "20151106". The file is empty when it is created.

So I wanted to create a set of org bulletted sections that were created in the new file. So they should include:

  • Tasks
  • Exercise
  • Meal Plan

That way I don't have to manually create these each time a new journal entry is created.

2 Answers 2

6

I have a hack that uses a hook on org-journal-after-entry-create-hook to insert a daily template

  (defun pc/new-buffer-p ()
    (not (file-exists-p (buffer-file-name))))

  (defun pc/insert-journal-template ()
    (let ((template-file (expand-file-name "template.org" org-directory)))
      (when (pc/new-buffer-p)
        (save-excursion
          (goto-char (point-min))
          (insert-file-contents template-file)))))

  (add-hook 'org-journal-after-entry-create-hook #'pc/insert-journal-template)
1
  • 1
    Thank you @punchagan. It's working perfectly fine. Just the pain part is I don't know much about elisp. I think now it's the time to learn bit by bit.
    – Ashfaq
    Feb 17, 2020 at 9:23
1

Updated answer

Here's a capture template that will get you started. You may want to change org-directory into the directory where you want to store the journal files.

(setq org-capture-templates '(("j" "Journal" entry (file
                                                (expand-file-name (concat (format-time-string "%Y%m%d") ".org") org-directory))
                           "* Tasks%?\n* Exercise\n* Meal plan")))
1
  • Hey @Erik thanks for trying to help. Sorry I was ambiguous. I tried to clarify the OP above. I need is to create a template for an org-journal entry and then save new capture requests to the current org-journal entry. Let me explain. So org-journal will create a new empty file for each day with the C-c C-j keystrokes. On creation of the new journal entry, I would like these sections created in the current journal entry file--so I can't hard code the filename for the capture template--as you did above with "myfile.org." Let me know if anything is still unclear, and thanks again for your help.
    – krishnab
    Nov 6, 2015 at 22:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.