I am using the diary both to save my calendar appointments and to write notes. Consequently I always read and write my diary file (on the same window, which means I open the real diary file), and I appreciate to have the entries chronologically ordered when I am about to write something.

I use the function that allows to write diary entries from Calendar (e.g. with i d) because it avoids mistakes when typing the date. But adding diary entries this way only appends the entry at the end of the diary file, and I would like them to be automatically put at the right chronological place in this file.

I did not find any solution in the manual. Is there a way to do this ?

1 Answer 1


Have you looked at org-sort-entries? That can sort a subtree of org items by a variety of means -- it prompts you if you call this interactively.

You'd have to manually call that rather than inserting them in your preferred order. It would be reasonably straightforward to automate that sorting on a hook if you required.

  • 1
    It sounds like the OP is using just the built in calendar/diary of emacs, not org-mode. Feb 8, 2017 at 17:09
  • @Stuart Hickinbottom I know this question is several months old, but could you please be more specific on how to use org-sort-entries in a diary file? I have tried it in org-mode, by using dates surrounded by < and >, but is it possible to do a similar thing with dates in the diary format (without any character that I would need to type)? Would it work in diary-mode?
    – Giuseppe
    Sep 5, 2017 at 13:23
  • As @AndrewSwann says above, I jumped to conclusions and assumed org-mode. As far as I know you wouldn't be able to use org-sort-entries for anything that is not formatted with org-mode syntax -- looking in the source it's heavily dependent on org-mode headings (since that's actually what it is sorting) and the diary format does not match that. Sorry for the misinterpretation. Sep 7, 2017 at 7:07
  • @Stuart Hickinbottom Ok thank you, so the simplest solution would be to format dates with < and > and to use org-mode, is that right?
    – Giuseppe
    Sep 7, 2017 at 8:05

Your Answer

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

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