emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/org 2ae8d6c1cf: org-babel-tangle-collect-blocks: Use ca


From: ELPA Syncer
Subject: [elpa] externals/org 2ae8d6c1cf: org-babel-tangle-collect-blocks: Use cache
Date: Wed, 26 Jan 2022 06:57:42 -0500 (EST)

branch: externals/org
commit 2ae8d6c1cf7f6adec7922eefc6277f8ba066ea13
Author: Ihor Radchenko <yantar92@gmail.com>
Commit: Ihor Radchenko <yantar92@gmail.com>

    org-babel-tangle-collect-blocks: Use cache
    
    * lisp/ob-tangle.el (org-babel-tangle-collect-blocks): Use element
    cache to find the containing headline instead of regexp search.
    Direct regexp search sometimes causes quadratic scaling.
    
    See https://lists.gnu.org/r/emacs-orgmode/2022-01/msg00484.html
---
 lisp/ob-tangle.el | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el
index c4b69dfd3a..5dc365e679 100644
--- a/lisp/ob-tangle.el
+++ b/lisp/ob-tangle.el
@@ -37,6 +37,9 @@
 (declare-function org-babel-update-block-body "ob-core" (new-body))
 (declare-function org-back-to-heading "org" (&optional invisible-ok))
 (declare-function org-before-first-heading-p "org" ())
+(declare-function org-element--cache-active-p "org-element" ())
+(declare-function org-element-lineage "org-element" (datum &optional types 
with-self))
+(declare-function org-element-property "org-element" (property element))
 (declare-function org-element-at-point "org-element" (&optional pom 
cached-only))
 (declare-function org-element-type "org-element" (element))
 (declare-function org-heading-components "org" ())
@@ -425,8 +428,10 @@ code blocks by target file."
   (let ((counter 0) last-heading-pos blocks)
     (org-babel-map-src-blocks (buffer-file-name)
       (let ((current-heading-pos
-            (org-with-wide-buffer
-             (org-with-limited-levels (outline-previous-heading)))))
+             (if (org-element--cache-active-p)
+                 (or (org-element-property :begin (org-element-lineage 
(org-element-at-point) '(headline) t)) 1)
+              (org-with-wide-buffer
+               (org-with-limited-levels (outline-previous-heading))))))
        (if (eq last-heading-pos current-heading-pos) (cl-incf counter)
          (setq counter 1)
          (setq last-heading-pos current-heading-pos)))



reply via email to

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