org-element-plain-list-interpreter: Do not run mode hooks

* lisp/org-element.el (org-element-plain-list-interpreter): Use
`org-element-with-buffer-copy' and make sure that we do not run user
hooks.  User hooks are often not designed to work in temporary
buffers.  The changed approach also follows similar code elsewhere in
Org code.
This commit is contained in:
Ihor Radchenko 2023-12-20 17:07:18 +01:00
parent 571186631a
commit e469636a6d
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
1 changed files with 14 additions and 6 deletions

View File

@ -1987,12 +1987,20 @@ Assume point is at the beginning of the list."
(defun org-element-plain-list-interpreter (_ contents)
"Interpret plain-list element as Org syntax.
CONTENTS is the contents of the element."
(with-temp-buffer
(org-mode)
(insert contents)
(goto-char (point-min))
(org-list-repair)
(buffer-string)))
(org-element-with-buffer-copy
:to-buffer (org-get-buffer-create " *Org parse*" t)
:drop-contents t
:drop-visibility t
:drop-narrowing t
:drop-locals nil
;; Transferring local variables may put the temporary buffer
;; into a read-only state. Make sure we can insert CONTENTS.
(let ((inhibit-read-only t)) (erase-buffer) (insert contents))
(goto-char (point-min))
(org-list-repair)
;; Prevent "Buffer *temp* modified; kill anyway?".
(restore-buffer-modified-p nil)
(buffer-string)))
;;;; Property Drawer