Function: org-src--contents-for-write-back-1
org-src--contents-for-write-back-1 is a byte-compiled function defined
in org-src.el.gz.
Signature
(org-src--contents-for-write-back-1 WRITE-BACK-BUF CONTENTS &optional INDENTATION-OFFSET PRESERVE-FL SOURCE-TAB-WIDTH WRITE-BACK)
Documentation
Populate WRITE-BACK-BUF with CONTENTS in the appropriate format.
INDENTATION-OFFSET, when non-nil is additional indentation to be applied to all the lines. PRESERVE-FL means that first line should not be indented (useful for inline blocks contents that belong to paragraph). The original indentation, if any, is not altered.
TAB-WIDTH is tab-width to be used when indenting. The value of 0
means that tabs should not be used.
WRITE-BACK, when non-nil, is a function to be called with point at WRITE-BACK-BUF after inserting the original contents, but before applying extra indentation.
Source Code
;; Defined in /usr/src/emacs/lisp/org/org-src.el.gz
(defun org-src--contents-for-write-back-1
( write-back-buf contents
&optional indentation-offset preserve-fl source-tab-width write-back)
"Populate WRITE-BACK-BUF with CONTENTS in the appropriate format.
INDENTATION-OFFSET, when non-nil is additional indentation to be applied
to all the lines. PRESERVE-FL means that first line should not be
indented (useful for inline blocks contents that belong to paragraph).
The original indentation, if any, is not altered.
TAB-WIDTH is `tab-width' to be used when indenting. The value of 0
means that tabs should not be used.
WRITE-BACK, when non-nil, is a function to be called with point at
WRITE-BACK-BUF after inserting the original contents, but before
applying extra indentation."
(let ((use-tabs? (and (> source-tab-width 0) t))
indent-str)
(with-current-buffer write-back-buf
;; Apply WRITE-BACK function on edit buffer contents.
(insert (org-no-properties contents))
(goto-char (point-min))
(when (functionp write-back) (save-excursion (funcall write-back)))
;; Add INDENTATION-OFFSET to every line in buffer,
;; unless indentation is meant to be preserved.
(when (and indentation-offset (> indentation-offset 0))
;; The exact sequence of tabs and spaces used to indent
;; up to `indentation-offset' in the Org buffer.
(setq indent-str
(with-temp-buffer
;; Reproduce indentation parameters.
(setq indent-tabs-mode use-tabs?)
(when (> source-tab-width 0)
(setq tab-width source-tab-width))
(indent-to indentation-offset)
(buffer-string)))
;; LaTeX-fragments are inline. Do not add indentation to their
;; first line.
(when preserve-fl (forward-line))
(while (not (eobp))
;; Keep empty src lines empty, even when src block is
;; indented on Org side.
;; See https://list.orgmode.org/725763.1632663635@apollo2.minshall.org/T/
(when (not (eolp)) ; not an empty line
(insert indent-str))
(forward-line))))))