[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org f51c286716 4/7: org-export-get-footnote-definition:
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org f51c286716 4/7: org-export-get-footnote-definition: Pre-cache references in parse tree |
Date: |
Sun, 12 Jun 2022 05:57:46 -0400 (EDT) |
branch: externals/org
commit f51c286716e75c7f70b599df59e66aa7cbc67e96
Author: Ihor Radchenko <yantar92@gmail.com>
Commit: Ihor Radchenko <yantar92@gmail.com>
org-export-get-footnote-definition: Pre-cache references in parse tree
* lisp/ox.el (org-export-get-footnote-definition): Pre-process parse
tree once to filter out all non-footnote elements. This speeds up
subsequent footnote definition searches.
---
lisp/ox.el | 39 ++++++++++++++++++++++-----------------
1 file changed, 22 insertions(+), 17 deletions(-)
diff --git a/lisp/ox.el b/lisp/ox.el
index 9a8e630462..d655c621d6 100644
--- a/lisp/ox.el
+++ b/lisp/ox.el
@@ -3754,28 +3754,33 @@ definition can be found, raise an error."
(if (not label) (org-element-contents footnote-reference)
(let ((cache (or (plist-get info :footnote-definition-cache)
(let ((hash (make-hash-table :test #'equal)))
+ ;; Cache all the footnotes in document for
+ ;; later search.
+ (org-element-map (plist-get info :parse-tree)
+ '(footnote-definition footnote-reference)
+ (lambda (f)
+ ;; Skip any standard footnote reference
+ ;; since those cannot contain a
+ ;; definition.
+ (unless (eq (org-element-property :type f)
'standard)
+ (puthash
+ (cons :element (org-element-property :label f))
+ f
+ hash)))
+ info)
(plist-put info :footnote-definition-cache hash)
hash))))
(or
(gethash label cache)
(puthash label
- (org-element-map (plist-get info :parse-tree)
- '(footnote-definition footnote-reference)
- (lambda (f)
- (cond
- ;; Skip any footnote with a different label.
- ;; Also skip any standard footnote reference
- ;; with the same label since those cannot
- ;; contain a definition.
- ((not (equal (org-element-property :label f) label)) nil)
- ((eq (org-element-property :type f) 'standard) nil)
- ((org-element-contents f))
- ;; Even if the contents are empty, we can not
- ;; return nil since that would eventually raise
- ;; the error. Instead, return the equivalent
- ;; empty string.
- (t "")))
- info t)
+ (let ((hashed (gethash (cons :element label) cache)))
+ (when hashed
+ (or (org-element-contents hashed)
+ ;; Even if the contents are empty, we can not
+ ;; return nil since that would eventually raise
+ ;; the error. Instead, return the equivalent
+ ;; empty string.
+ "")))
cache)
(error "Definition not found for footnote %s" label))))))
- [elpa] externals/org updated (ed6f8dc67f -> f5c9ce8f06), ELPA Syncer, 2022/06/12
- [elpa] externals/org 147ca39750 3/7: org-in-commented-heading-p: Do not parse section unless already cached, ELPA Syncer, 2022/06/12
- [elpa] externals/org 2f8e688516 2/7: org-back-to-heading-or-point-min: Rely less on cache, ELPA Syncer, 2022/06/12
- [elpa] externals/org 8a0b03fb3b 1/7: org-element-headline-parser: Fix headings like * COMMENTnospace, ELPA Syncer, 2022/06/12
- [elpa] externals/org f51c286716 4/7: org-export-get-footnote-definition: Pre-cache references in parse tree,
ELPA Syncer <=
- [elpa] externals/org f5c9ce8f06 7/7: org-babel-exp-process-buffer: Disable edit control while processing, ELPA Syncer, 2022/06/12
- [elpa] externals/org 84c89ea7cb 6/7: org-export-resolve-id-link: Pre-cache all the ids in the parse tree, ELPA Syncer, 2022/06/12
- [elpa] externals/org 792cd4b0a6 5/7: org-export-resolve-fuzyy-link: Pre-cache all possible search cells, ELPA Syncer, 2022/06/12