1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-11-21 06:55:35 +00:00

org-element-parse-buffer: New optional argument to not force undefer

* lisp/org-element.el (org-element-parse-buffer): Do not force-undefer
when new optional argument is provided.
* lisp/org-lint.el (org-lint--generate-reports):
* lisp/org.el (org-unindent-buffer):
* lisp/ox.el (org-export--missing-definitions):
(org-export--annotate-info): Do not undefer when unnecessary.

Adjust all the declare forms.
This commit is contained in:
Ihor Radchenko 2023-05-02 11:00:16 +02:00
parent 244cc7d560
commit 44baf8f2b8
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
7 changed files with 16 additions and 13 deletions

View File

@ -82,7 +82,7 @@
(declare-function org-element-lineage "org-element-ast" (datum &optional types with-self))
(declare-function org-element-map "org-element" (data types fun &optional info first-match no-recursion with-affiliated))
(declare-function org-element-normalize-string "org-element" (s))
(declare-function org-element-parse-buffer "org-element" (&optional granularity visible-only))
(declare-function org-element-parse-buffer "org-element" (&optional granularity visible-only keep-deferred))
(declare-function org-element-parse-secondary-string "org-element" (string restriction &optional parent))
(declare-function org-element-context "org-element" (&optional element))
(declare-function org-element-property "org-element-ast" (property node))

View File

@ -4460,7 +4460,7 @@ When PARSE is non-nil, values from keywords belonging to
;; resulting values. In an export situation, it also skips unneeded
;; parts of the parse tree.
(defun org-element-parse-buffer (&optional granularity visible-only)
(defun org-element-parse-buffer (&optional granularity visible-only keep-deferred)
"Recursively parse the buffer and return structure.
If narrowing is in effect, only parse the visible part of the
buffer.
@ -4478,6 +4478,8 @@ recursion. It can be set to the following symbols:
When VISIBLE-ONLY is non-nil, don't parse contents of hidden
elements.
When KEEP-DEFERRED is non-nil, do not resolve deferred properties.
An element or object is represented as a list with the
pattern (TYPE PROPERTIES CONTENTS), where :
@ -4515,10 +4517,11 @@ This function assumes that current major mode is `org-mode'."
;; Start in `first-section' mode so text before the first
;; headline belongs to a section.
'first-section nil granularity visible-only org-data))
(org-element-map ; undefer
org-data t
(lambda (el) (org-element-properties-resolve el t))
nil nil nil t)
(unless keep-deferred
(org-element-map ; undefer
org-data t
(lambda (el) (org-element-properties-resolve el t))
nil nil nil t))
org-data)))
(defun org-element-parse-secondary-string (string restriction &optional parent)

View File

@ -195,7 +195,7 @@ for `tabulated-list-printer'."
(with-current-buffer buffer
(save-excursion
(goto-char (point-min))
(let ((ast (org-element-parse-buffer))
(let ((ast (org-element-parse-buffer nil nil 'defer))
(id 0)
(last-line 1)
(last-pos 1))

View File

@ -115,7 +115,7 @@
(declare-function org-element-macro-interpreter "org-element" (macro ##))
(declare-function org-element-map "org-element" (data types fun &optional info first-match no-recursion with-affiliated))
(declare-function org-element-normalize-string "org-element" (s))
(declare-function org-element-parse-buffer "org-element" (&optional granularity visible-only))
(declare-function org-element-parse-buffer "org-element" (&optional granularity visible-only keep-deferred))
(declare-function org-element-property "org-element-ast" (property node))
(declare-function org-element-put-property "org-element-ast" (node property value))
(declare-function org-element-set "org-element-ast" (old new))

View File

@ -57,7 +57,7 @@
(declare-function org-element-interpret-data "org-element" (data))
(declare-function org-element-lineage "org-element-ast" (blob &optional types with-self))
(declare-function org-element-map "org-element" (data types fun &optional info first-match no-recursion with-affiliated))
(declare-function org-element-parse-buffer "org-element" (&optional granularity visible-only))
(declare-function org-element-parse-buffer "org-element" (&optional granularity visible-only keep-deferred))
(declare-function org-element-property "org-element-ast" (property node))
(declare-function org-element-type-p "org-element-ast" (node types))
(declare-function org-element-cache-reset "org-element" (&optional all no-persistence))

View File

@ -183,7 +183,7 @@ Stars are put in group 1 and the trimmed body in group 2.")
(declare-function org-element-link-parser "org-element" ())
(declare-function org-element-map "org-element" (data types fun &optional info first-match no-recursion with-affiliated))
(declare-function org-element-nested-p "org-element" (elem-a elem-b))
(declare-function org-element-parse-buffer "org-element" (&optional granularity visible-only))
(declare-function org-element-parse-buffer "org-element" (&optional granularity visible-only keep-deferred))
(declare-function org-element-parse-secondary-string "org-element" (string restriction &optional parent))
(declare-function org-element-property "org-element-ast" (property node))
(declare-function org-element-put-property "org-element-ast" (node property value))
@ -21506,7 +21506,7 @@ modified."
(interactive)
(unless (eq major-mode 'org-mode)
(user-error "Cannot un-indent a buffer not in Org mode"))
(letrec ((parse-tree (org-element-parse-buffer 'greater-element))
(letrec ((parse-tree (org-element-parse-buffer 'greater-element nil 'defer))
(unindent-tree
(lambda (contents)
(dolist (element (reverse contents))

View File

@ -2893,7 +2893,7 @@ a list of footnote definitions or in the widened buffer."
(narrow-to-region
(org-element-property :begin datum)
(org-element-property :end datum))
(org-element-map (org-element-parse-buffer)
(org-element-map (org-element-parse-buffer nil nil 'defer)
'footnote-definition #'identity nil t))))))
(_ nil)))
(t (user-error "Definition not found for footnote %s" label)))))
@ -3212,7 +3212,7 @@ still inferior to file-local settings."
(let ((result (funcall filter info backend-name)))
(when result (setq info result)))))
;; Parse buffer.
(setq tree (org-element-parse-buffer nil visible-only))
(setq tree (org-element-parse-buffer nil visible-only 'defer))
;; Prune tree from non-exported elements and transform
;; uninterpreted elements or objects in both parse tree and
;; communication channel.