1

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
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.

  • Doesn't seem to be compatible with time-grid. – Rene Feb 27 '17 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 Feb 27 '17 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 Feb 28 '17 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 Mar 3 '17 at 16:40
  • @Rene -- here is the link to the thread I was thinking of in the previous comment: "Custom sorting for agenda" emacs.stackexchange.com/a/26369/2287 – lawlist Mar 3 '17 at 16:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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