This is the final version of the patch. I am going to merge it this weekend. If there are any comments, please send them ASAP.
This version is basically the same as previous, but (1) Rebased onto current main; (2) org-agenda.el can be native compiled; (3) Fixed some edge cases with fontification. Best, Ihor Anders Johansson (3): Fix typo: delete-duplicates → delete-dups Fix bug in org-get-heading Rename remaining org-force-cycle-archived → org-cycle-force-archived Ihor Radchenko (35): Add org-fold-core: new folding engine Separate folding functions from org.el into new library: org-fold Separate cycling functions from org.el into new library: org-cycle Remove functions from org.el that are now moved elsewhere Disable native-comp in agenda org-macs: New function org-find-text-property-region org-at-heading-p: Accept optional argument org-string-width: Reimplement to work with new folding Rename old function call to use org-fold Implement link folding Implement overlay- and text-property-based versions of some functions org-fold: Handle indirect buffer visibility Fix subtle differences between overlays and invisible text properties Support extra org-fold optimisations for huge buffers Alias new org-fold functions to their old shorter names Obsolete old function names that are now in org-fold org-compat: Work around some third-party packages using outline-* functions Move `org-buffer-list' to org-macs.el Restore old visibility behaviour of org-refile Add org-fold-related tests org-manual: Update to new org-fold function names ORG-NEWS: Add list of changes Backport contributed commits Fix org-fold--hide-drawers--overlays org-string-width: Handle undefined behaviour in older Emacs org-string-width: Work around `window-pixel-width' bug in old Emacs org-fold-show-set-visibility: Fix edge case when folded region is at BOB org-fold-core: Fix fontification inside folded regions test-org/string-width: Add tests for strings with prefix properties org--string-from-props: Fix handling folds in Emacs <28 org-link-make-string: Throw error when both LINK and DESCRIPTION are empty test-ol/org-toggle-link-display: Fix compatibility with old Emacs org-macs.el: Fix fontification checks take 2 org-fold-core-fontify-region: Fix cases when fontification is not registered org-agenda.el: Re-enable native compilation doc/org-manual.org | 14 +- etc/ORG-NEWS | 104 ++ lisp/ob-core.el | 14 +- lisp/ob-lilypond.el | 4 +- lisp/ob-ref.el | 4 +- lisp/ol.el | 59 +- lisp/org-agenda.el | 48 +- lisp/org-archive.el | 12 +- lisp/org-capture.el | 7 +- lisp/org-clock.el | 126 +- lisp/org-colview.el | 10 +- lisp/org-compat.el | 189 ++- lisp/org-crypt.el | 8 +- lisp/org-cycle.el | 818 +++++++++++ lisp/org-element.el | 55 +- lisp/org-feed.el | 4 +- lisp/org-fold-core.el | 1506 +++++++++++++++++++ lisp/org-fold.el | 1132 +++++++++++++++ lisp/org-footnote.el | 6 +- lisp/org-goto.el | 6 +- lisp/org-id.el | 4 +- lisp/org-inlinetask.el | 26 +- lisp/org-keys.el | 26 +- lisp/org-lint.el | 3 +- lisp/org-list.el | 84 +- lisp/org-macs.el | 294 +++- lisp/org-mobile.el | 2 +- lisp/org-mouse.el | 4 +- lisp/org-refile.el | 3 +- lisp/org-src.el | 6 +- lisp/org-timer.el | 2 +- lisp/org.el | 2550 +++++++++++---------------------- lisp/ox-org.el | 2 +- lisp/ox.el | 4 +- testing/lisp/test-ob.el | 12 +- testing/lisp/test-ol.el | 24 + testing/lisp/test-org-list.el | 75 +- testing/lisp/test-org-macs.el | 6 +- testing/lisp/test-org.el | 258 +++- 39 files changed, 5480 insertions(+), 2031 deletions(-) create mode 100644 lisp/org-cycle.el create mode 100644 lisp/org-fold-core.el create mode 100644 lisp/org-fold.el -- 2.35.1 -- Ihor Radchenko, PhD, Center for Advancing Materials Performance from the Nanoscale (CAMP-nano) State Key Laboratory for Mechanical Behavior of Materials, Xi'an Jiaotong University, Xi'an, China Email: yanta...@gmail.com, ihor_radche...@alumni.sutd.edu.sg