org-element--parse-to: Fix limit when pasting top-comment and no cache
* lisp/org-element.el (org-element--parse-to): Manually parse org-data and set appropriate parser mode when POS is before first headline and cache is disabled. (org-element-org-data-parser--recurse): New variable flagging if `org-element-data-parser' is called recursively. (org-element-org-data-parser): Handle recursive calls from inside `org-element-at-point-no-context'. This also fixes false-positives in `org-element--cache-verify-element'.
This commit is contained in:
parent
1537bb4029
commit
6631b3f7bb
|
@ -1253,6 +1253,8 @@ parser (e.g. `:end' and :END:). Return value is a plist."
|
||||||
(while (and (org-at-comment-p) (bolp)) (forward-line))
|
(while (and (org-at-comment-p) (bolp)) (forward-line))
|
||||||
(org-element--get-node-properties t)))
|
(org-element--get-node-properties t)))
|
||||||
|
|
||||||
|
|
||||||
|
(defvar org-element-org-data-parser--recurse nil)
|
||||||
(defun org-element-org-data-parser (&optional _)
|
(defun org-element-org-data-parser (&optional _)
|
||||||
"Parse org-data."
|
"Parse org-data."
|
||||||
(org-with-wide-buffer
|
(org-with-wide-buffer
|
||||||
|
@ -1286,13 +1288,17 @@ parser (e.g. `:end' and :END:). Return value is a plist."
|
||||||
((symbolp org-category) (symbol-name org-category))
|
((symbolp org-category) (symbol-name org-category))
|
||||||
(t org-category)))
|
(t org-category)))
|
||||||
(category (catch 'buffer-category
|
(category (catch 'buffer-category
|
||||||
(org-with-point-at end
|
(unless org-element-org-data-parser--recurse
|
||||||
(while (re-search-backward "^[ \t]*#\\+CATEGORY:" (point-min) t)
|
(org-with-point-at end
|
||||||
(org-element-with-disabled-cache
|
;; Avoid recusrive calls from
|
||||||
(let ((element (org-element-at-point-no-context)))
|
;; `org-element-at-point-no-context'.
|
||||||
(when (eq (org-element-type element) 'keyword)
|
(let ((org-element-org-data-parser--recurse t))
|
||||||
(throw 'buffer-category
|
(while (re-search-backward "^[ \t]*#\\+CATEGORY:" (point-min) t)
|
||||||
(org-element-property :value element)))))))
|
(org-element-with-disabled-cache
|
||||||
|
(let ((element (org-element-at-point-no-context)))
|
||||||
|
(when (eq (org-element-type element) 'keyword)
|
||||||
|
(throw 'buffer-category
|
||||||
|
(org-element-property :value element)))))))))
|
||||||
category))
|
category))
|
||||||
(properties (org-element--get-global-node-properties)))
|
(properties (org-element--get-global-node-properties)))
|
||||||
(unless (plist-get properties :CATEGORY)
|
(unless (plist-get properties :CATEGORY)
|
||||||
|
@ -6378,7 +6384,8 @@ the expected result."
|
||||||
(setq element (org-element-headline-parser nil 'fast))
|
(setq element (org-element-headline-parser nil 'fast))
|
||||||
(setq mode 'planning)
|
(setq mode 'planning)
|
||||||
(forward-line))
|
(forward-line))
|
||||||
(setq mode 'top-comment))
|
(setq element (org-element-org-data-parser))
|
||||||
|
(setq mode 'org-data))
|
||||||
(org-skip-whitespace)
|
(org-skip-whitespace)
|
||||||
(beginning-of-line))
|
(beginning-of-line))
|
||||||
;; Check if CACHED or any of its ancestors contain point.
|
;; Check if CACHED or any of its ancestors contain point.
|
||||||
|
|
Loading…
Reference in New Issue