forked from mirrors/org-mode
org-element: Record origin buffer when parsing
* lisp/org-element.el (org-element-parse-buffer): Resolve all the deferred values in the string. If not, we might leave pointers to killed buffer. (org-element--parse-elements): Resolve deferred in objects. (org-element--object-lex): Store :buffer property. * lisp/org-macro.el (org-macro--find-date): Do not try to print :buffer property. * lisp/org-element.el (org-element--cache-persist-before-write): (org-element--cache-persist-after-read): Clear and restore non-printable buffer objects in :buffer property.
This commit is contained in:
parent
f4aa3747e1
commit
a8286a5a9e
|
@ -545,7 +545,8 @@ value of DATUM `:parent' property."
|
||||||
|
|
||||||
(defconst org-element--cache-element-properties
|
(defconst org-element--cache-element-properties
|
||||||
'(:cached
|
'(:cached
|
||||||
:org-element--cache-sync-key)
|
:org-element--cache-sync-key
|
||||||
|
:buffer)
|
||||||
"List of element properties used internally by cache.")
|
"List of element properties used internally by cache.")
|
||||||
|
|
||||||
(defvar org-element--string-cache (obarray-make)
|
(defvar org-element--string-cache (obarray-make)
|
||||||
|
@ -1157,8 +1158,9 @@ parser (e.g. `:end' and :END:). Return value is a plist."
|
||||||
:post-blank (count-lines pos-before-blank end)
|
:post-blank (count-lines pos-before-blank end)
|
||||||
:post-affiliated begin
|
:post-affiliated begin
|
||||||
:path (buffer-file-name)
|
:path (buffer-file-name)
|
||||||
:mode 'org-data)
|
:mode 'org-data
|
||||||
properties)))))
|
:buffer (current-buffer)))
|
||||||
|
properties)))))
|
||||||
|
|
||||||
(defun org-element-org-data-interpreter (_ contents)
|
(defun org-element-org-data-interpreter (_ contents)
|
||||||
"Interpret ORG-DATA element as Org syntax.
|
"Interpret ORG-DATA element as Org syntax.
|
||||||
|
@ -4021,7 +4023,7 @@ Assume point is at the first equal sign marker."
|
||||||
(defvar org-inlinetask-min-level); Declared in org-inlinetask.el
|
(defvar org-inlinetask-min-level); Declared in org-inlinetask.el
|
||||||
(defvar org-element--cache-sync-requests); Declared later
|
(defvar org-element--cache-sync-requests); Declared later
|
||||||
(defun org-element--current-element (limit &optional granularity mode structure)
|
(defun org-element--current-element (limit &optional granularity mode structure)
|
||||||
"Parse the element starting at point.
|
"Parse the element starting at point.
|
||||||
|
|
||||||
Return value is a list like (TYPE PROPS) where TYPE is the type
|
Return value is a list like (TYPE PROPS) where TYPE is the type
|
||||||
of the element and PROPS a plist of properties associated to the
|
of the element and PROPS a plist of properties associated to the
|
||||||
|
@ -4047,174 +4049,175 @@ computed.
|
||||||
|
|
||||||
This function assumes point is always at the beginning of the
|
This function assumes point is always at the beginning of the
|
||||||
element it has to parse."
|
element it has to parse."
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(let ((case-fold-search t)
|
(let ((case-fold-search t)
|
||||||
;; Determine if parsing depth allows for secondary strings
|
;; Determine if parsing depth allows for secondary strings
|
||||||
;; parsing. It only applies to elements referenced in
|
;; parsing. It only applies to elements referenced in
|
||||||
;; `org-element-secondary-value-alist'.
|
;; `org-element-secondary-value-alist'.
|
||||||
(raw-secondary-p (and granularity (not (eq granularity 'object))))
|
(raw-secondary-p (and granularity (not (eq granularity 'object))))
|
||||||
result at-task?)
|
result at-task?)
|
||||||
(setq
|
(setq
|
||||||
result
|
result
|
||||||
;; Regexp matches below should avoid modifying match data,
|
;; Regexp matches below should avoid modifying match data,
|
||||||
;; if possible. Doing it unnecessarily degrades regexp
|
;; if possible. Doing it unnecessarily degrades regexp
|
||||||
;; matching performance an order of magnitude, which
|
;; matching performance an order of magnitude, which
|
||||||
;; becomes important when parsing large buffers with huge
|
;; becomes important when parsing large buffers with huge
|
||||||
;; amount of elements to be parsed.
|
;; amount of elements to be parsed.
|
||||||
;;
|
;;
|
||||||
;; In general, the checks below should be as efficient as
|
;; In general, the checks below should be as efficient as
|
||||||
;; possible, especially early in the `cond' form. (The
|
;; possible, especially early in the `cond' form. (The
|
||||||
;; early checks will contribute to al subsequent parsers as
|
;; early checks will contribute to al subsequent parsers as
|
||||||
;; well).
|
;; well).
|
||||||
(cond
|
(cond
|
||||||
;; Item.
|
;; Item.
|
||||||
((eq mode 'item) (org-element-item-parser limit structure raw-secondary-p))
|
((eq mode 'item) (org-element-item-parser limit structure raw-secondary-p))
|
||||||
;; Table Row.
|
;; Table Row.
|
||||||
((eq mode 'table-row) (org-element-table-row-parser limit))
|
((eq mode 'table-row) (org-element-table-row-parser limit))
|
||||||
;; Node Property.
|
;; Node Property.
|
||||||
((eq mode 'node-property) (org-element-node-property-parser limit))
|
((eq mode 'node-property) (org-element-node-property-parser limit))
|
||||||
;; Headline.
|
;; Headline.
|
||||||
((and (looking-at-p "^\\*+ ")
|
((and (looking-at-p "^\\*+ ")
|
||||||
(setq at-task? t)
|
(setq at-task? t)
|
||||||
(or (not (featurep 'org-inlinetask))
|
(or (not (featurep 'org-inlinetask))
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(< (skip-chars-forward "*")
|
(< (skip-chars-forward "*")
|
||||||
(if org-odd-levels-only
|
(if org-odd-levels-only
|
||||||
(1- (* org-inlinetask-min-level 2))
|
(1- (* org-inlinetask-min-level 2))
|
||||||
org-inlinetask-min-level)))))
|
org-inlinetask-min-level)))))
|
||||||
(org-element-headline-parser limit raw-secondary-p))
|
(org-element-headline-parser limit raw-secondary-p))
|
||||||
;; Sections (must be checked after headline).
|
;; Sections (must be checked after headline).
|
||||||
((memq mode '(section first-section)) (org-element-section-parser nil))
|
((memq mode '(section first-section)) (org-element-section-parser nil))
|
||||||
;; Comments.
|
;; Comments.
|
||||||
((looking-at-p "^[ \t]*#\\(?: \\|$\\)") (org-element-comment-parser limit))
|
((looking-at-p "^[ \t]*#\\(?: \\|$\\)") (org-element-comment-parser limit))
|
||||||
;; Planning.
|
;; Planning.
|
||||||
((and (eq mode 'planning)
|
((and (eq mode 'planning)
|
||||||
(eq ?* (char-after (line-beginning-position 0)))
|
(eq ?* (char-after (line-beginning-position 0)))
|
||||||
(looking-at-p org-element-planning-line-re))
|
(looking-at-p org-element-planning-line-re))
|
||||||
(org-element-planning-parser limit))
|
(org-element-planning-parser limit))
|
||||||
;; Property drawer.
|
;; Property drawer.
|
||||||
((and (pcase mode
|
((and (pcase mode
|
||||||
(`planning (eq ?* (char-after (line-beginning-position 0))))
|
(`planning (eq ?* (char-after (line-beginning-position 0))))
|
||||||
((or `property-drawer `top-comment)
|
((or `property-drawer `top-comment)
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(beginning-of-line 0)
|
(beginning-of-line 0)
|
||||||
(not (looking-at-p "[[:blank:]]*$"))))
|
(not (looking-at-p "[[:blank:]]*$"))))
|
||||||
(_ nil))
|
(_ nil))
|
||||||
(looking-at-p org-property-drawer-re))
|
(looking-at-p org-property-drawer-re))
|
||||||
(org-element-property-drawer-parser limit))
|
(org-element-property-drawer-parser limit))
|
||||||
;; When not at bol, point is at the beginning of an item or
|
;; When not at bol, point is at the beginning of an item or
|
||||||
;; a footnote definition: next item is always a paragraph.
|
;; a footnote definition: next item is always a paragraph.
|
||||||
((not (bolp)) (org-element-paragraph-parser limit (list (point))))
|
((not (bolp)) (org-element-paragraph-parser limit (list (point))))
|
||||||
;; Clock.
|
;; Clock.
|
||||||
((looking-at-p org-element-clock-line-re) (org-element-clock-parser limit))
|
((looking-at-p org-element-clock-line-re) (org-element-clock-parser limit))
|
||||||
;; Inlinetask.
|
;; Inlinetask.
|
||||||
(at-task? (org-element-inlinetask-parser limit raw-secondary-p))
|
(at-task? (org-element-inlinetask-parser limit raw-secondary-p))
|
||||||
;; From there, elements can have affiliated keywords.
|
;; From there, elements can have affiliated keywords.
|
||||||
(t (let ((affiliated (org-element--collect-affiliated-keywords
|
(t (let ((affiliated (org-element--collect-affiliated-keywords
|
||||||
limit (memq granularity '(nil object)))))
|
limit (memq granularity '(nil object)))))
|
||||||
|
(cond
|
||||||
|
;; Jumping over affiliated keywords put point off-limits.
|
||||||
|
;; Parse them as regular keywords.
|
||||||
|
((and (cdr affiliated) (>= (point) limit))
|
||||||
|
(goto-char (car affiliated))
|
||||||
|
(org-element-keyword-parser limit nil))
|
||||||
|
;; LaTeX Environment.
|
||||||
|
((looking-at-p org-element--latex-begin-environment)
|
||||||
|
(org-element-latex-environment-parser limit affiliated))
|
||||||
|
;; Drawer.
|
||||||
|
((looking-at-p org-element-drawer-re)
|
||||||
|
(org-element-drawer-parser limit affiliated))
|
||||||
|
;; Fixed Width
|
||||||
|
((looking-at-p "[ \t]*:\\( \\|$\\)")
|
||||||
|
(org-element-fixed-width-parser limit affiliated))
|
||||||
|
;; Inline Comments, Blocks, Babel Calls, Dynamic Blocks and
|
||||||
|
;; Keywords.
|
||||||
|
((looking-at "[ \t]*#\\+")
|
||||||
|
(goto-char (match-end 0))
|
||||||
(cond
|
(cond
|
||||||
;; Jumping over affiliated keywords put point off-limits.
|
((looking-at "BEGIN_\\(\\S-+\\)")
|
||||||
;; Parse them as regular keywords.
|
(beginning-of-line)
|
||||||
((and (cdr affiliated) (>= (point) limit))
|
(funcall (pcase (upcase (match-string 1))
|
||||||
(goto-char (car affiliated))
|
("CENTER" #'org-element-center-block-parser)
|
||||||
(org-element-keyword-parser limit nil))
|
("COMMENT" #'org-element-comment-block-parser)
|
||||||
;; LaTeX Environment.
|
("EXAMPLE" #'org-element-example-block-parser)
|
||||||
((looking-at-p org-element--latex-begin-environment)
|
("EXPORT" #'org-element-export-block-parser)
|
||||||
(org-element-latex-environment-parser limit affiliated))
|
("QUOTE" #'org-element-quote-block-parser)
|
||||||
;; Drawer.
|
("SRC" #'org-element-src-block-parser)
|
||||||
((looking-at-p org-element-drawer-re)
|
("VERSE" #'org-element-verse-block-parser)
|
||||||
(org-element-drawer-parser limit affiliated))
|
(_ #'org-element-special-block-parser))
|
||||||
;; Fixed Width
|
limit
|
||||||
((looking-at-p "[ \t]*:\\( \\|$\\)")
|
affiliated))
|
||||||
(org-element-fixed-width-parser limit affiliated))
|
((looking-at-p "CALL:")
|
||||||
;; Inline Comments, Blocks, Babel Calls, Dynamic Blocks and
|
(beginning-of-line)
|
||||||
;; Keywords.
|
(org-element-babel-call-parser limit affiliated))
|
||||||
((looking-at "[ \t]*#\\+")
|
((save-excursion
|
||||||
(goto-char (match-end 0))
|
(beginning-of-line)
|
||||||
(cond
|
(looking-at-p org-element-dynamic-block-open-re))
|
||||||
((looking-at "BEGIN_\\(\\S-+\\)")
|
(beginning-of-line)
|
||||||
(beginning-of-line)
|
(org-element-dynamic-block-parser limit affiliated))
|
||||||
(funcall (pcase (upcase (match-string 1))
|
((looking-at-p "\\S-+:")
|
||||||
("CENTER" #'org-element-center-block-parser)
|
(beginning-of-line)
|
||||||
("COMMENT" #'org-element-comment-block-parser)
|
(org-element-keyword-parser limit affiliated))
|
||||||
("EXAMPLE" #'org-element-example-block-parser)
|
(t
|
||||||
("EXPORT" #'org-element-export-block-parser)
|
(beginning-of-line)
|
||||||
("QUOTE" #'org-element-quote-block-parser)
|
(org-element-paragraph-parser limit affiliated))))
|
||||||
("SRC" #'org-element-src-block-parser)
|
;; Footnote Definition.
|
||||||
("VERSE" #'org-element-verse-block-parser)
|
((looking-at-p org-footnote-definition-re)
|
||||||
(_ #'org-element-special-block-parser))
|
(org-element-footnote-definition-parser limit affiliated))
|
||||||
limit
|
;; Horizontal Rule.
|
||||||
affiliated))
|
((looking-at-p "[ \t]*-\\{5,\\}[ \t]*$")
|
||||||
((looking-at-p "CALL:")
|
(org-element-horizontal-rule-parser limit affiliated))
|
||||||
(beginning-of-line)
|
;; Diary Sexp.
|
||||||
(org-element-babel-call-parser limit affiliated))
|
((looking-at-p "%%(")
|
||||||
((save-excursion
|
(org-element-diary-sexp-parser limit affiliated))
|
||||||
(beginning-of-line)
|
;; Table.
|
||||||
(looking-at-p org-element-dynamic-block-open-re))
|
((or (looking-at-p "[ \t]*|")
|
||||||
(beginning-of-line)
|
;; There is no strict definition of a table.el
|
||||||
(org-element-dynamic-block-parser limit affiliated))
|
;; table. Try to prevent false positive while being
|
||||||
((looking-at-p "\\S-+:")
|
;; quick.
|
||||||
(beginning-of-line)
|
(let ((rule-regexp
|
||||||
(org-element-keyword-parser limit affiliated))
|
(rx (zero-or-more (any " \t"))
|
||||||
(t
|
"+"
|
||||||
(beginning-of-line)
|
(one-or-more (one-or-more "-") "+")
|
||||||
(org-element-paragraph-parser limit affiliated))))
|
(zero-or-more (any " \t"))
|
||||||
;; Footnote Definition.
|
eol))
|
||||||
((looking-at-p org-footnote-definition-re)
|
(non-table.el-line
|
||||||
(org-element-footnote-definition-parser limit affiliated))
|
(rx bol
|
||||||
;; Horizontal Rule.
|
(zero-or-more (any " \t"))
|
||||||
((looking-at-p "[ \t]*-\\{5,\\}[ \t]*$")
|
(or eol (not (any "+| \t")))))
|
||||||
(org-element-horizontal-rule-parser limit affiliated))
|
(next (line-beginning-position 2)))
|
||||||
;; Diary Sexp.
|
;; Start with a full rule.
|
||||||
((looking-at-p "%%(")
|
(and
|
||||||
(org-element-diary-sexp-parser limit affiliated))
|
(looking-at-p rule-regexp)
|
||||||
;; Table.
|
(< next limit) ;no room for a table.el table
|
||||||
((or (looking-at-p "[ \t]*|")
|
(save-excursion
|
||||||
;; There is no strict definition of a table.el
|
(end-of-line)
|
||||||
;; table. Try to prevent false positive while being
|
(cond
|
||||||
;; quick.
|
;; Must end with a full rule.
|
||||||
(let ((rule-regexp
|
((not (re-search-forward non-table.el-line limit 'move))
|
||||||
(rx (zero-or-more (any " \t"))
|
(if (bolp) (forward-line -1) (beginning-of-line))
|
||||||
"+"
|
(looking-at-p rule-regexp))
|
||||||
(one-or-more (one-or-more "-") "+")
|
;; Ignore pseudo-tables with a single
|
||||||
(zero-or-more (any " \t"))
|
;; rule.
|
||||||
eol))
|
((= next (line-beginning-position))
|
||||||
(non-table.el-line
|
nil)
|
||||||
(rx bol
|
;; Must end with a full rule.
|
||||||
(zero-or-more (any " \t"))
|
(t
|
||||||
(or eol (not (any "+| \t")))))
|
(forward-line -1)
|
||||||
(next (line-beginning-position 2)))
|
(looking-at-p rule-regexp)))))))
|
||||||
;; Start with a full rule.
|
(org-element-table-parser limit affiliated))
|
||||||
(and
|
;; List.
|
||||||
(looking-at-p rule-regexp)
|
((looking-at-p (org-item-re))
|
||||||
(< next limit) ;no room for a table.el table
|
(org-element-plain-list-parser
|
||||||
(save-excursion
|
limit affiliated
|
||||||
(end-of-line)
|
(or structure (org-element--list-struct limit))))
|
||||||
(cond
|
;; Default element: Paragraph.
|
||||||
;; Must end with a full rule.
|
(t (org-element-paragraph-parser limit affiliated)))))))
|
||||||
((not (re-search-forward non-table.el-line limit 'move))
|
(when result
|
||||||
(if (bolp) (forward-line -1) (beginning-of-line))
|
(org-element-put-property result :buffer (current-buffer))
|
||||||
(looking-at-p rule-regexp))
|
(org-element-put-property result :mode mode)
|
||||||
;; Ignore pseudo-tables with a single
|
(org-element-put-property result :granularity granularity))
|
||||||
;; rule.
|
result)))
|
||||||
((= next (line-beginning-position))
|
|
||||||
nil)
|
|
||||||
;; Must end with a full rule.
|
|
||||||
(t
|
|
||||||
(forward-line -1)
|
|
||||||
(looking-at-p rule-regexp)))))))
|
|
||||||
(org-element-table-parser limit affiliated))
|
|
||||||
;; List.
|
|
||||||
((looking-at-p (org-item-re))
|
|
||||||
(org-element-plain-list-parser
|
|
||||||
limit affiliated
|
|
||||||
(or structure (org-element--list-struct limit))))
|
|
||||||
;; Default element: Paragraph.
|
|
||||||
(t (org-element-paragraph-parser limit affiliated)))))))
|
|
||||||
(when result
|
|
||||||
(org-element-put-property result :mode mode)
|
|
||||||
(org-element-put-property result :granularity granularity))
|
|
||||||
result)))
|
|
||||||
|
|
||||||
|
|
||||||
;; Most elements can have affiliated keywords. When looking for an
|
;; Most elements can have affiliated keywords. When looking for an
|
||||||
|
@ -4680,117 +4683,121 @@ Elements are accumulated into ACC."
|
||||||
RESTRICTION is a list of object types, as symbols, that should be
|
RESTRICTION is a list of object types, as symbols, that should be
|
||||||
looked after. This function assumes that the buffer is narrowed
|
looked after. This function assumes that the buffer is narrowed
|
||||||
to an appropriate container (e.g., a paragraph)."
|
to an appropriate container (e.g., a paragraph)."
|
||||||
(cond
|
(let (result)
|
||||||
((memq 'table-cell restriction) (org-element-table-cell-parser))
|
(setq
|
||||||
((memq 'citation-reference restriction)
|
result
|
||||||
(org-element-citation-reference-parser))
|
(cond
|
||||||
(t
|
((memq 'table-cell restriction) (org-element-table-cell-parser))
|
||||||
(let* ((start (point))
|
((memq 'citation-reference restriction)
|
||||||
(limit
|
(org-element-citation-reference-parser))
|
||||||
;; Object regexp sometimes needs to have a peek at
|
(t
|
||||||
;; a character ahead. Therefore, when there is a hard
|
(let* ((start (point))
|
||||||
;; limit, make it one more than the true beginning of the
|
(limit
|
||||||
;; radio target.
|
;; Object regexp sometimes needs to have a peek at
|
||||||
(save-excursion
|
;; a character ahead. Therefore, when there is a hard
|
||||||
(cond ((not org-target-link-regexp) nil)
|
;; limit, make it one more than the true beginning of the
|
||||||
((not (memq 'link restriction)) nil)
|
;; radio target.
|
||||||
((progn
|
(save-excursion
|
||||||
(unless (bolp) (forward-char -1))
|
(cond ((not org-target-link-regexp) nil)
|
||||||
(not (re-search-forward org-target-link-regexp nil t)))
|
((not (memq 'link restriction)) nil)
|
||||||
nil)
|
((progn
|
||||||
;; Since we moved backward, we do not want to
|
(unless (bolp) (forward-char -1))
|
||||||
;; match again an hypothetical 1-character long
|
(not (re-search-forward org-target-link-regexp nil t)))
|
||||||
;; radio link before us. Realizing that this can
|
nil)
|
||||||
;; only happen if such a radio link starts at
|
;; Since we moved backward, we do not want to
|
||||||
;; beginning of line, we prevent this here.
|
;; match again an hypothetical 1-character long
|
||||||
((and (= start (1+ (line-beginning-position)))
|
;; radio link before us. Realizing that this can
|
||||||
(= start (match-end 1)))
|
;; only happen if such a radio link starts at
|
||||||
(and (re-search-forward org-target-link-regexp nil t)
|
;; beginning of line, we prevent this here.
|
||||||
(1+ (match-beginning 1))))
|
((and (= start (1+ (line-beginning-position)))
|
||||||
(t (1+ (match-beginning 1))))))
|
(= start (match-end 1)))
|
||||||
found)
|
(and (re-search-forward org-target-link-regexp nil t)
|
||||||
(save-excursion
|
(1+ (match-beginning 1))))
|
||||||
(while (and (not found)
|
(t (1+ (match-beginning 1))))))
|
||||||
(re-search-forward org-element--object-regexp limit 'move))
|
found)
|
||||||
(goto-char (match-beginning 0))
|
(save-excursion
|
||||||
(let ((result (match-string 0)))
|
(while (and (not found)
|
||||||
(setq found
|
(re-search-forward org-element--object-regexp limit 'move))
|
||||||
(cond
|
(goto-char (match-beginning 0))
|
||||||
((string-prefix-p "call_" result t)
|
(let ((result (match-string 0)))
|
||||||
(and (memq 'inline-babel-call restriction)
|
(setq found
|
||||||
(org-element-inline-babel-call-parser)))
|
(cond
|
||||||
((string-prefix-p "src_" result t)
|
((string-prefix-p "call_" result t)
|
||||||
(and (memq 'inline-src-block restriction)
|
(and (memq 'inline-babel-call restriction)
|
||||||
(org-element-inline-src-block-parser)))
|
(org-element-inline-babel-call-parser)))
|
||||||
(t
|
((string-prefix-p "src_" result t)
|
||||||
(pcase (char-after)
|
(and (memq 'inline-src-block restriction)
|
||||||
(?^ (and (memq 'superscript restriction)
|
(org-element-inline-src-block-parser)))
|
||||||
(org-element-superscript-parser)))
|
(t
|
||||||
(?_ (or (and (memq 'subscript restriction)
|
(pcase (char-after)
|
||||||
(org-element-subscript-parser))
|
(?^ (and (memq 'superscript restriction)
|
||||||
(and (memq 'underline restriction)
|
(org-element-superscript-parser)))
|
||||||
(org-element-underline-parser))))
|
(?_ (or (and (memq 'subscript restriction)
|
||||||
(?* (and (memq 'bold restriction)
|
(org-element-subscript-parser))
|
||||||
(org-element-bold-parser)))
|
(and (memq 'underline restriction)
|
||||||
(?/ (and (memq 'italic restriction)
|
(org-element-underline-parser))))
|
||||||
(org-element-italic-parser)))
|
(?* (and (memq 'bold restriction)
|
||||||
(?~ (and (memq 'code restriction)
|
(org-element-bold-parser)))
|
||||||
(org-element-code-parser)))
|
(?/ (and (memq 'italic restriction)
|
||||||
(?= (and (memq 'verbatim restriction)
|
(org-element-italic-parser)))
|
||||||
(org-element-verbatim-parser)))
|
(?~ (and (memq 'code restriction)
|
||||||
(?+ (and (memq 'strike-through restriction)
|
(org-element-code-parser)))
|
||||||
(org-element-strike-through-parser)))
|
(?= (and (memq 'verbatim restriction)
|
||||||
(?@ (and (memq 'export-snippet restriction)
|
(org-element-verbatim-parser)))
|
||||||
(org-element-export-snippet-parser)))
|
(?+ (and (memq 'strike-through restriction)
|
||||||
(?{ (and (memq 'macro restriction)
|
(org-element-strike-through-parser)))
|
||||||
(org-element-macro-parser)))
|
(?@ (and (memq 'export-snippet restriction)
|
||||||
(?$ (and (memq 'latex-fragment restriction)
|
(org-element-export-snippet-parser)))
|
||||||
(org-element-latex-fragment-parser)))
|
(?{ (and (memq 'macro restriction)
|
||||||
(?<
|
(org-element-macro-parser)))
|
||||||
(if (eq (aref result 1) ?<)
|
(?$ (and (memq 'latex-fragment restriction)
|
||||||
(or (and (memq 'radio-target restriction)
|
(org-element-latex-fragment-parser)))
|
||||||
(org-element-radio-target-parser))
|
(?<
|
||||||
(and (memq 'target restriction)
|
(if (eq (aref result 1) ?<)
|
||||||
(org-element-target-parser)))
|
(or (and (memq 'radio-target restriction)
|
||||||
(or (and (memq 'timestamp restriction)
|
(org-element-radio-target-parser))
|
||||||
(org-element-timestamp-parser))
|
(and (memq 'target restriction)
|
||||||
(and (memq 'link restriction)
|
(org-element-target-parser)))
|
||||||
(org-element-link-parser)))))
|
(or (and (memq 'timestamp restriction)
|
||||||
(?\\
|
(org-element-timestamp-parser))
|
||||||
(if (eq (aref result 1) ?\\)
|
(and (memq 'link restriction)
|
||||||
(and (memq 'line-break restriction)
|
(org-element-link-parser)))))
|
||||||
(org-element-line-break-parser))
|
(?\\
|
||||||
(or (and (memq 'entity restriction)
|
(if (eq (aref result 1) ?\\)
|
||||||
(org-element-entity-parser))
|
(and (memq 'line-break restriction)
|
||||||
(and (memq 'latex-fragment restriction)
|
(org-element-line-break-parser))
|
||||||
(org-element-latex-fragment-parser)))))
|
(or (and (memq 'entity restriction)
|
||||||
(?\[
|
(org-element-entity-parser))
|
||||||
(pcase (aref result 1)
|
(and (memq 'latex-fragment restriction)
|
||||||
((and ?\[
|
(org-element-latex-fragment-parser)))))
|
||||||
(guard (memq 'link restriction)))
|
(?\[
|
||||||
(org-element-link-parser))
|
(pcase (aref result 1)
|
||||||
((and ?f
|
((and ?\[
|
||||||
(guard (memq 'footnote-reference restriction)))
|
(guard (memq 'link restriction)))
|
||||||
(org-element-footnote-reference-parser))
|
(org-element-link-parser))
|
||||||
((and ?c
|
((and ?f
|
||||||
(guard (memq 'citation restriction)))
|
(guard (memq 'footnote-reference restriction)))
|
||||||
(org-element-citation-parser))
|
(org-element-footnote-reference-parser))
|
||||||
((and (or ?% ?/)
|
((and ?c
|
||||||
(guard (memq 'statistics-cookie restriction)))
|
(guard (memq 'citation restriction)))
|
||||||
(org-element-statistics-cookie-parser))
|
(org-element-citation-parser))
|
||||||
(_
|
((and (or ?% ?/)
|
||||||
(or (and (memq 'timestamp restriction)
|
(guard (memq 'statistics-cookie restriction)))
|
||||||
(org-element-timestamp-parser))
|
(org-element-statistics-cookie-parser))
|
||||||
(and (memq 'statistics-cookie restriction)
|
(_
|
||||||
(org-element-statistics-cookie-parser))))))
|
(or (and (memq 'timestamp restriction)
|
||||||
;; This is probably a plain link.
|
(org-element-timestamp-parser))
|
||||||
(_ (and (memq 'link restriction)
|
(and (memq 'statistics-cookie restriction)
|
||||||
(org-element-link-parser)))))))
|
(org-element-statistics-cookie-parser))))))
|
||||||
(or (eobp) (forward-char))))
|
;; This is probably a plain link.
|
||||||
(cond (found)
|
(_ (and (memq 'link restriction)
|
||||||
(limit (forward-char -1)
|
(org-element-link-parser)))))))
|
||||||
(org-element-link-parser)) ;radio link
|
(or (eobp) (forward-char))))
|
||||||
(t nil)))))))
|
(cond (found)
|
||||||
|
(limit (forward-char -1)
|
||||||
|
(org-element-link-parser)) ;radio link
|
||||||
|
(t nil)))))))
|
||||||
|
(org-element-put-property result :buffer (current-buffer))))
|
||||||
|
|
||||||
(defun org-element--parse-objects (beg end acc restriction &optional parent)
|
(defun org-element--parse-objects (beg end acc restriction &optional parent)
|
||||||
"Parse objects between BEG and END and return recursive structure.
|
"Parse objects between BEG and END and return recursive structure.
|
||||||
|
@ -7049,10 +7056,15 @@ The element is: %S\n The real element is: %S\n Cache around :begin:\n%S\n%S\n%S"
|
||||||
(org-with-wide-buffer
|
(org-with-wide-buffer
|
||||||
(org-element--cache-sync (current-buffer) (point-max))
|
(org-element--cache-sync (current-buffer) (point-max))
|
||||||
;; Cleanup cache request keys to avoid collisions during next
|
;; Cleanup cache request keys to avoid collisions during next
|
||||||
;; Emacs session.
|
;; Emacs session. Cleanup known non-printable objects.
|
||||||
(avl-tree-mapc
|
(avl-tree-mapc
|
||||||
(lambda (el)
|
(lambda (el)
|
||||||
(org-element-put-property el :org-element--cache-sync-key nil))
|
(org-element-put-property el :org-element--cache-sync-key nil)
|
||||||
|
(org-element-map el t
|
||||||
|
(lambda (el2)
|
||||||
|
(unless (eq 'plain-text (org-element-type el2))
|
||||||
|
(org-element-put-property el2 :buffer nil)))
|
||||||
|
nil nil nil 'with-affiliated 'no-undefer))
|
||||||
org-element--cache)
|
org-element--cache)
|
||||||
nil)
|
nil)
|
||||||
'forbid))
|
'forbid))
|
||||||
|
@ -7079,6 +7091,15 @@ The element is: %S\n The real element is: %S\n Cache around :begin:\n%S\n%S\n%S"
|
||||||
(with-current-buffer (get-file-buffer (plist-get associated :file))
|
(with-current-buffer (get-file-buffer (plist-get associated :file))
|
||||||
(when (and org-element-use-cache org-element-cache-persistent)
|
(when (and org-element-use-cache org-element-cache-persistent)
|
||||||
(when (and (equal container '(elisp org-element--cache)) org-element--cache)
|
(when (and (equal container '(elisp org-element--cache)) org-element--cache)
|
||||||
|
;; Restore `:buffer' property.
|
||||||
|
(avl-tree-mapc
|
||||||
|
(lambda (el)
|
||||||
|
(org-element-map el t
|
||||||
|
(lambda (el2)
|
||||||
|
(unless (eq 'plain-text (org-element-type el2))
|
||||||
|
(org-element-put-property el2 :buffer (current-buffer))))
|
||||||
|
nil nil nil 'with-affiliated 'no-undefer))
|
||||||
|
org-element--cache)
|
||||||
(setq-local org-element--cache-size (avl-tree-size org-element--cache)))
|
(setq-local org-element--cache-size (avl-tree-size org-element--cache)))
|
||||||
(when (and (equal container '(elisp org-element--headline-cache)) org-element--headline-cache)
|
(when (and (equal container '(elisp org-element--headline-cache)) org-element--headline-cache)
|
||||||
(setq-local org-element--headline-cache-size (avl-tree-size org-element--headline-cache)))))))
|
(setq-local org-element--headline-cache-size (avl-tree-size org-element--headline-cache)))))))
|
||||||
|
|
|
@ -369,7 +369,10 @@ Return value as a string."
|
||||||
(eq 'timestamp (org-element-type (car date))))
|
(eq 'timestamp (org-element-type (car date))))
|
||||||
(format "(eval (if (org-string-nw-p $1) %s %S))"
|
(format "(eval (if (org-string-nw-p $1) %s %S))"
|
||||||
(format "(org-format-timestamp '%S $1)"
|
(format "(org-format-timestamp '%S $1)"
|
||||||
(org-element-copy (car date)))
|
(org-element-put-property
|
||||||
|
(org-element-copy (car date))
|
||||||
|
;; Remove non-printable.
|
||||||
|
:buffer nil))
|
||||||
value)
|
value)
|
||||||
value)))
|
value)))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue