[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org 8868f0f 3/4: org-archive-subtree: Speed up archivin
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org 8868f0f 3/4: org-archive-subtree: Speed up archiving |
Date: |
Tue, 30 Nov 2021 07:57:26 -0500 (EST) |
branch: externals/org
commit 8868f0fdddd38e2ccdda88e835e3730cb320be98
Author: Ihor Radchenko <yantar92@gmail.com>
Commit: Ihor Radchenko <yantar92@gmail.com>
org-archive-subtree: Speed up archiving
* lisp/org-element.el
(org-element--cache-avoid-synchronous-headline-re-parsing):
New internal variable controlling latency of cache
`after-change-functions'.
(org-element--cache-for-removal): Use
`org-element--cache-avoid-synchronous-headline-re-parsing' to decide
if we re-parse changed headlines immidiately.
* lisp/org-archive.el (org-archive-subtree): Let-bind
`org-element--cache-avoid-synchronous-headline-re-parsing' to t while
archiving for better speed.
---
lisp/org-archive.el | 7 ++++++-
lisp/org-element.el | 14 ++++++++++++++
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/lisp/org-archive.el b/lisp/org-archive.el
index 0943869..8b4547a 100644
--- a/lisp/org-archive.el
+++ b/lisp/org-archive.el
@@ -35,6 +35,9 @@
(declare-function org-datetree-find-date-create "org-datetree" (date &optional
keep-restriction))
(declare-function org-inlinetask-remove-END-maybe "org-inlinetask" ())
+;; From org-element.el
+(defvar org-element--cache-avoid-synchronous-headline-re-parsing)
+
(defcustom org-archive-default-command 'org-archive-subtree
"The default archiving command."
:group 'org-archive
@@ -253,7 +256,9 @@ direct children of this heading."
(if (local-variable-p 'org-odd-levels-only (current-buffer))
org-odd-levels-only
tr-org-odd-levels-only))
- level datetree-date datetree-subheading-p)
+ level datetree-date datetree-subheading-p
+ ;; Suppress on-the-fly headline updates.
+ (org-element--cache-avoid-synchronous-headline-re-parsing t))
(when (string-match "\\`datetree/\\(\\**\\)" heading)
;; "datetree/" corresponds to 3 levels of headings.
(let ((nsub (length (match-string 1 heading))))
diff --git a/lisp/org-element.el b/lisp/org-element.el
index 0b4dd22..6a20135 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -6583,6 +6583,19 @@ that range. See `after-change-functions' for more
information."
;; Activate a timer to process the request during idle time.
(org-element--cache-set-timer (current-buffer))))))
+(defvar org-element--cache-avoid-synchronous-headline-re-parsing nil
+ "This variable controls how buffer changes are handled by the cache.
+
+By default (when this variable is nil), cache re-parses modified
+headlines immidiately after modification preserving all the unaffected
+elements inside the headline.
+
+The default behaviour works best when users types inside Org buffer of
+when buffer modifications are mixed with cache requests. However,
+large automated edits inserting/deleting many headlines are somewhat
+slower by default (as in `org-archive-subtree'). Let-binding this
+variable to non-nil will reduce cache latency after every singular edit
+(`after-change-functions') at the cost of slower cache queries.")
(defun org-element--cache-for-removal (beg end offset)
"Return first element to remove from cache.
@@ -6674,6 +6687,7 @@ known element in cache (it may start after END)."
;; its boundaries could have extended to shrinked - we
;; will re-parent and shift them anyway.
(and (eq 'headline (org-element-type up))
+ (not
org-element--cache-avoid-synchronous-headline-re-parsing)
;; The change is not inside headline. Not
;; updating here.
(not (<= beg (org-element-property :begin up)))