Function: org-element-copy-buffer
org-element-copy-buffer is a byte-compiled function defined in
org-element.el.gz.
Signature
(org-element-copy-buffer &key TO-BUFFER DROP-VISIBILITY DROP-NARROWING DROP-CONTENTS DROP-LOCALS)
Documentation
Return a copy of the current buffer.
The copy preserves Org buffer-local variables, visibility and narrowing.
IMPORTANT: The buffer copy may also have variable buffer-file-name(var)/buffer-file-name(fun)
copied.
To prevent Emacs overwriting the original buffer file,
write-contents-functions is set to '(always). Do not alter this
variable and do not do anything that might alter it (like calling a
major mode) to prevent data corruption. Also, do note that Emacs may
jump into the created buffer if the original file buffer is closed and
then re-opened. Making edits in the buffer copy may also trigger
Emacs save dialog. Prefer using org-element-with-buffer-copy macro
when possible.
When optional key TO-BUFFER is non-nil, copy into BUFFER.
Optional keys DROP-VISIBILITY, DROP-NARROWING, DROP-CONTENTS, and
DROP-LOCALS are passed to org-element--generate-copy-script.
Source Code
;; Defined in /usr/src/emacs/lisp/org/org-element.el.gz
(cl-defun org-element-copy-buffer (&key to-buffer drop-visibility
drop-narrowing drop-contents
drop-locals)
"Return a copy of the current buffer.
The copy preserves Org buffer-local variables, visibility and
narrowing.
IMPORTANT: The buffer copy may also have variable `buffer-file-name'
copied.
To prevent Emacs overwriting the original buffer file,
`write-contents-functions' is set to \\='(always). Do not alter this
variable and do not do anything that might alter it (like calling a
major mode) to prevent data corruption. Also, do note that Emacs may
jump into the created buffer if the original file buffer is closed and
then re-opened. Making edits in the buffer copy may also trigger
Emacs save dialog. Prefer using `org-element-with-buffer-copy' macro
when possible.
When optional key TO-BUFFER is non-nil, copy into BUFFER.
Optional keys DROP-VISIBILITY, DROP-NARROWING, DROP-CONTENTS, and
DROP-LOCALS are passed to `org-element--generate-copy-script'."
(let ((copy-buffer-fun (org-element--generate-copy-script
(current-buffer)
:copy-unreadable 'do-not-check
:drop-visibility drop-visibility
:drop-narrowing drop-narrowing
:drop-contents drop-contents
:drop-locals drop-locals))
(new-buf (or to-buffer (generate-new-buffer (buffer-name)))))
(with-current-buffer new-buf
(funcall copy-buffer-fun)
(set-buffer-modified-p nil))
new-buf))