3

When calling org-sort-entries on an outline item, I get the error

Region to sort contains a level above the first entry

with no indication of what or where the problem is.

What does this error mean, and how do you fix it?

2 Answers 2

3

Take an example like this, with a TAB before the 'd' - if you call org-sort-entries on the 'a', you'll get the error - the '*[TAB]d' seems to confuse the function.

* a
** c
*   d
** b

You can do a regexp search through the file to find problems like this, e.g. put this at the top of your file and hit C-x C-e after it (eval-last-sexp):

(re-search-forward "^[*]+[\t]")
3
  • 1
    I've got the same problem, but when I try the expression above I get (void-function find-regexp). Am I missing something or is this function not part of emacs? If the latter one please provide the function. Besides that, I find the whole issue rediculous. Why is org-mode not more robust? Either skipping the error or point to the problem line, so it can be fixed manually.
    – Jens Lange
    Commented Jan 13, 2019 at 20:35
  • @JensLange ah, I forgot that was an alias I had made for re-search-forward - was trying to make things easier to remember and discover. But yes, maybe there's something we could do to patch org-mode for this error... Commented Jan 15, 2019 at 8:26
  • I just got this even though the search failed: Lisp error: (search-failed "^[*]+[\11]"). What should be done to fix the problem in that case ?
    – serv-inc
    Commented Nov 1, 2022 at 10:27
0

Simplified: Org thinks that your file has several top-level entries. As written above, this can happen if you have an org-file like

* task 1
** subtask 1
* task 2
** subtask 3

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.