Hello everyone, I found if you org-fold-hide-entry on a heading without content but with subtrees, the first subtree will be folded, for example (>|< meas cursor):
* H>|<EADING ** subheading1 ** subheading2 if you press TAB on the above text, it will be: * H>|<EADING ** subheading2 I changed a little of the code of org-fold-hide-entry (diff file enclosed), and it seems good to me now. Emacs : GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.33, cairo version 1.17.6) of 2022-05-21 Package: Org mode version 9.5.5 (9.5.5-gcb1359 @ /home/user/meow-emacs/straight/build/org/) ===File ~/org-fold-hide-entry.diff========================== diff --git a/lisp/org-fold.el b/lisp/org-fold.el index 495f431cb..35b645a8c 100644 --- a/lisp/org-fold.el +++ b/lisp/org-fold.el @@ -319,10 +319,10 @@ When ENTRY is non-nil, show the entire entry." (interactive) (save-excursion (org-back-to-heading-or-point-min t) - (when (org-at-heading-p) (forward-line)) + (when (org-at-heading-p) (end-of-line)) (unless (eobp) ; Current headline is empty and ends at the end of buffer. (org-fold-region - (line-end-position 0) + (line-end-position) (save-excursion (if (re-search-forward (concat "[\r\n]" (org-get-limited-outline-regexp)) nil t) ============================================================