org-journal sort entries by date at insert time

Emacs Asked by user57623 on November 27, 2020

I want to switch from daily files to monthly (or even yearly). The problem I’m facing is: org-journal-new-entry and org-journal-new-scheduled-entry simply append at the bottom of a file. This can result in unsorted days – can this be sorted?.

(extreme) example:

(use-package org-journal
  :ensure t
  :defer t
  ("C-c n j" . org-journal-new-entry)
  ("C-c n s" . org-journal-new-scheduled-entry)
  (org-journal-file-format "")
  (org-journal-enable-agenda-integration t)
  (setq org-journal-dir org-journal-directory)
  (setq org-journal-file-type 'monthly)
  (setq org-journal-date-format " %d/%m/%y - %A")
  (setq org-journal-file-header "#+title: %B Journal")


  1. Add new scheduled in the future
  2. Add new entry today
  3. Add new entry in the past


#+title: October Journal
*  08/10/20 - Thursday
  :CREATED:  20201008
** First: New Scheduled
*  06/10/20 - Tuesday
  :CREATED:  20201006
** 12:46 Second: new Entry
*  05/10/20 - Monday
  :CREATED:  20201005
** Third: new scheduled in past

my goal
would be to have entries in the file correctly sorted from top to bottom (basically the oppositve of my result)

One Answer

I'm not sure how this is handled in org-journal, by base orgmode provides datetree as an option for capture templates. These are created and inserted in sorted order. This allows you to define an appropriate capture element to add entries to your file.

From the org manual, (org) Template elements:

 ‘(file+olp+datetree "filename" [ "Level 1 heading" ...])’
      This target(1) creates a heading in a date tree(2) for today’s
      date.  If the optional outline path is given, the tree will be
      built under the node it is pointing to, instead of at top
      level.  Check out the ‘:time-prompt’ and ‘:tree-type’
      properties below for additional options.

(2) A date tree is an outline structure with years on the highest
level, months or ISO weeks as sublevels and then dates on the lowest
level.  Tags are allowed in the tree structure.

Answered by Tyler on November 27, 2020

Add your own answers!

Related Questions

Adding Spacemacs documented layers fails

1  Asked on September 2, 2021 by samusz


Easily accessing org files

1  Asked on September 2, 2021 by fraxture


View multiple emails at the same time with mu4e

1  Asked on September 2, 2021 by tyler


How can I set default paths for INCLUDE blocks under each heading in orgmode?

0  Asked on September 2, 2021 by scientific_explorer


In-line latex fragment position in org-mode

0  Asked on September 2, 2021 by a-blizzard


Filter list by regexps

2  Asked on September 2, 2021 by lorem-ipsum


Get a table of org-mode file from elisp to be passed to R

1  Asked on September 2, 2021 by omar113


Styling lists in org-export (html)

1  Asked on March 5, 2021 by user2699


Is there a way to show/open a file from a URI/URL

3  Asked on February 27, 2021 by carsten


cursor color depending on insert or overwrite mode

1  Asked on February 19, 2021 by tamifo


Syntax highlighting in C++ fails in user-defined literals

1  Asked on February 19, 2021 by vroomfondel


org-set-effort fast effort selection?

1  Asked on February 19, 2021 by whoever


Ask a Question

Get help from others!

© 2022 All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir