0

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.
NickD
  • 27,023
  • 3
  • 23
  • 42
  • You can close everything automatically cycling visibility with `S-TAB` / backtab. Not an answer, but less of a PITA on consequences :) – Muihlinn May 02 '20 at 16:45

1 Answers1

0

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."
  (interactive)
  (org-overview)
  (org-reveal)
  (org-show-children))

(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. – Erik Sjöstrand Sep 19 '20 at 21:59