emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v2 14/38] Support extra org-fold optimisations for huge buffers


From: Ihor Radchenko
Subject: [PATCH v2 14/38] Support extra org-fold optimisations for huge buffers
Date: Wed, 20 Apr 2022 21:25:45 +0800

---
 lisp/org.el | 26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index ca0a99681..f5936b67c 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -5788,6 +5788,7 @@ (defun org-unfontify-region (beg end &optional 
_maybe_loudly)
                            '(mouse-face t keymap t org-linked-text t
                                         invisible t intangible t
                                         org-emphasis t))
+    (org-fold-core-update-optimisation beg end)
     (org-remove-font-lock-display-properties beg end)))
 
 (defconst org-script-display  '(((raise -0.3) (height 0.7))
@@ -6158,7 +6159,11 @@ (defun org-get-heading (&optional no-tags no-todo 
no-priority no-comment)
       (org-back-to-heading t)
       (let ((case-fold-search nil))
        (looking-at org-complex-heading-regexp)
-       (let ((todo (and (not no-todo) (match-string 2)))
+        ;; When using `org-fold-core--optimise-for-huge-buffers',
+        ;; returned text may be invisible.  Clear it up.
+        (save-match-data
+          (org-fold-core-remove-optimisation (match-beginning 0) (match-end 
0)))
+        (let ((todo (and (not no-todo) (match-string 2)))
              (priority (and (not no-priority) (match-string 3)))
              (headline (pcase (match-string 4)
                          (`nil "")
@@ -6169,6 +6174,8 @@ (defun org-get-heading (&optional no-tags no-todo 
no-priority no-comment)
                            "" h))
                          (h h)))
              (tags (and (not no-tags) (match-string 5))))
+          ;; Restore cleared optimisation.
+          (org-fold-core-update-optimisation (match-beginning 0) (match-end 0))
          (mapconcat #'identity
                     (delq nil (list todo priority headline tags))
                     " "))))))
@@ -6185,18 +6192,21 @@ (defun org-heading-components ()
   (save-excursion
     (org-back-to-heading t)
     (when (let (case-fold-search) (looking-at org-complex-heading-regexp))
-      (list (length (match-string 1))
-           (org-reduced-level (length (match-string 1)))
-           (match-string-no-properties 2)
-           (and (match-end 3) (aref (match-string 3) 2))
-           (match-string-no-properties 4)
-           (match-string-no-properties 5)))))
+      (org-fold-core-remove-optimisation (match-beginning 0) (match-end 0))
+      (prog1
+          (list (length (match-string 1))
+               (org-reduced-level (length (match-string 1)))
+               (match-string-no-properties 2)
+               (and (match-end 3) (aref (match-string 3) 2))
+               (match-string-no-properties 4)
+               (match-string-no-properties 5))
+        (org-fold-core-update-optimisation (match-beginning 0) (match-end 
0))))))
 
 (defun org-get-entry ()
   "Get the entry text, after heading, entire subtree."
   (save-excursion
     (org-back-to-heading t)
-    (buffer-substring (point-at-bol 2) (org-end-of-subtree t))))
+    (filter-buffer-substring (point-at-bol 2) (org-end-of-subtree t))))
 
 (defun org-edit-headline (&optional heading)
   "Edit the current headline.
-- 
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: yantar92@gmail.com, ihor_radchenko@alumni.sutd.edu.sg



reply via email to

[Prev in Thread] Current Thread [Next in Thread]