4

The manual says

For the daily/weekly agenda, the items for each day are sorted. The default order is to first collect all items containing an explicit time-of-day specification.

    8:30-13:00 Arthur Dent lies in front of the bulldozer
    12:45...... Ford Prefect arrives and takes Arthur to the pub
    14:00-15:00 TODO Call John regarding memo
    19:00...... The Vogon reads his poem
    20:30-22:15 Marvin escorts the Hitchhikers to the bridge
    TODO send newsletter to mailing list
    TODO buy John birthday gift           :errands:
    Internship period for Alex

How can I tweak `org-agenda-sorting-strategy' so that I can first display all items containing no time-of-day specification like in

    Internship period for Alex
    TODO send newsletter to mailing list
    TODO buy John birthday gift           :errands:
    8:30-13:00 Arthur Dent lies in front of the bulldozer
    12:45...... Ford Prefect arrives and takes Arthur to the pub
    14:00-15:00 TODO Call John regarding memo
    19:00...... The Vogon reads his poem
    20:30-22:15 Marvin escorts the Hitchhikers to the bridge

2 Answers 2

3

You have to set org-sort-agenda-notime-is-late to nil. It is defined in org-agenda.el and, by default, the value is t (see also it's use in org-cmp-time).

Non-nil means items without time are considered late. This is only relevant for sorting. When t, items which have no explicit time like 15:30 will be considered as 99:01, i.e. later than any items which do have a time. When nil, the default time is before 0:00. You can use this option to decide if the schedule for today should come before or after timeless agenda entries.

1

Check the current setting of org-agenda-sorting-strategy. It should be something like this:

((agenda time-up priority-down category-keep)
 (todo priority-down category-keep)
 (tags priority-down category-keep)
 (search category-keep))

Changing the order of sorting strategies for the agenda should do what you want:

(setq org-agenda-sorting-strategy 
    '((agenda priority-down category-keep time-up)
      (todo priority-down category-keep)
      (tags priority-down category-keep)
      (search category-keep)))

Read the documentation of the variable for more information.

EDIT: As the OP points out in the comments, this does not work. It should be possible to do what he wants using a user-defined comparison function as described in my comment below, but that is TBD.

6
  • Doesn't seem to be compatible with time-grid.
    – Rene
    Commented Feb 27, 2017 at 4:17
  • You are right: the categories/priorities force the entries out of time order in the grid. The only other possibility I can think of is to set org-agenda-sorting-strategy to e.g. user-defined-up and then write your own org-agenda-cmp-user-defined function to impose the order that you want. Unfortunately, I don't have the time to do that now, but it should not be too difficult. If nobody comes up with one (or perhaps another method), I'll try to do one next weekend.
    – NickD
    Commented Feb 27, 2017 at 16:50
  • (agenda todo-state-up time-up) pretty much does what I want. Except for the fact that I would like to see appointment with no time specification at the top of the list and not at the bottom. I'll have a look at org-agenda-sorting-strategy
    – Rene
    Commented Feb 28, 2017 at 8:41
  • @Rene: Place your cursor on the agenda entry that you wish to sort and see what text properties (in the agenda buffer) are present -- those are used for sorting. If a particular property is missing, that value may need to be assigned during the gathering of data just prior to the population of the agenda buffer. In my own setup, I assigned properties and so forth so that it's backed into the code. There was an answer a few months ago that used org-get-entry ... and the 'org-marker to extract a value from the original buffer during the data gathering process. . . .; so that's an idea.
    – lawlist
    Commented Mar 3, 2017 at 16:40
  • 1
    Just found that using C-u C-x = on some entry let me see the list of available text properties that you can manipulate.
    – Rene
    Commented May 17, 2018 at 2:07

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.