Function: org-export-copy-buffer
org-export-copy-buffer is a byte-compiled function defined in
ox.el.gz.
Signature
(org-export-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 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-export-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-export--generate-copy-script.
Source Code
;; Defined in /usr/src/emacs/lisp/org/ox.el.gz
;;; Core functions
;;
;; This is the room for the main function, `org-export-as', along with
;; its derivative, `org-export-string-as'.
;; `org-export--copy-to-kill-ring-p' determines if output of these
;; function should be added to kill ring.
;;
;; Note that `org-export-as' doesn't really parse the current buffer,
;; but a copy of it (with the same buffer-local variables and
;; visibility), where macros and include keywords are expanded and
;; Babel blocks are executed, if appropriate.
;; `org-export-with-buffer-copy' macro prepares that copy.
;;
;; File inclusion is taken care of by
;; `org-export-expand-include-keyword' and
;; `org-export--prepare-file-contents'. Structure wise, including
;; a whole Org file in a buffer often makes little sense. For
;; example, if the file contains a headline and the include keyword
;; was within an item, the item should contain the headline. That's
;; why file inclusion should be done before any structure can be
;; associated to the file, that is before parsing.
;;
;; `org-export-insert-default-template' is a command to insert
;; a default template (or a back-end specific template) at point or in
;; current subtree.
(cl-defun org-export-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 `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-export-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-export--generate-copy-script'."
(let ((copy-buffer-fun (org-export--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))