When I use org-sort (Ctrl-^) all the to-be-sorted subtrees are expanded including their properties. I kind of lose orientation. I have to collapse them manually again or use overview (Shift-Tab) and expand manually from there.

  • Is this a standard behavior?
    I tried a fresh emacs install on a new machine and this behaves the same. So I assume the answer here is "yes".
  • Can I change this behavior somehow? The focus on a subtree should not change when sorting or archiving.
  • You can close everything automatically cycling visibility with S-TAB / backtab. Not an answer, but less of a PITA on consequences :)
    – Muihlinn
    May 2, 2020 at 16:45

1 Answer 1


I have not found a way to disable that behaviour, but I found a way to not loose orientation while sorting.

I modified this answer and added a hook to run after every sorting of headings. This basically automates the folding I had to do manually every time after sorting.

(defun ess/org-show-just-me (&rest _)
"Fold all other trees, then show direct children of current org-heading."

(add-hook 'org-after-sorting-entries-or-items-hook 'ess/org-show-just-me)

I don't understand the code fully ( eg. &rest_), but for now it works.

  • 1
    In the linked answer the function was used in an advice, and such functions needs a &rest parameter (see documentation of add-function). However I did not use the &rest parameter, and when parameters aren't used inside a function the code standard in Emacs lisp is to prefix the parameters with _ or simply name them _. In your answer here you could simply have an empty argument list instead. Sep 19, 2020 at 21:59

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.