Function: org-export-format-code
org-export-format-code is a byte-compiled function defined in
ox.el.gz.
Signature
(org-export-format-code CODE FUN &optional NUM-LINES REF-ALIST)
Documentation
Format CODE by applying FUN line-wise and return it.
CODE is a string representing the code to format. FUN is a function. It must accept three arguments: a line of code (string), the current line number (integer) or nil and the reference associated to the current line (string) or nil.
Optional argument NUM-LINES can be an integer representing the
number of code lines accumulated until the current code. Line
numbers passed to FUN will take it into account. If it is nil,
FUN's second argument will always be nil. This number can be
obtained with org-export-get-loc function.
Optional argument REF-ALIST can be an alist between relative line
number (i.e. ignoring NUM-LINES) and the name of the code
reference on it. If it is nil, FUN's third argument will always
be nil. It can be obtained through the use of
org-export-unravel-code function.
Source Code
;; Defined in /usr/src/emacs/lisp/org/ox.el.gz
(defun org-export-format-code (code fun &optional num-lines ref-alist)
"Format CODE by applying FUN line-wise and return it.
CODE is a string representing the code to format. FUN is
a function. It must accept three arguments: a line of
code (string), the current line number (integer) or nil and the
reference associated to the current line (string) or nil.
Optional argument NUM-LINES can be an integer representing the
number of code lines accumulated until the current code. Line
numbers passed to FUN will take it into account. If it is nil,
FUN's second argument will always be nil. This number can be
obtained with `org-export-get-loc' function.
Optional argument REF-ALIST can be an alist between relative line
number (i.e. ignoring NUM-LINES) and the name of the code
reference on it. If it is nil, FUN's third argument will always
be nil. It can be obtained through the use of
`org-export-unravel-code' function."
(let ((--locs (split-string code "\n"))
(--line 0))
(concat
(mapconcat
(lambda (--loc)
(cl-incf --line)
(let ((--ref (cdr (assq --line ref-alist))))
(funcall fun --loc (and num-lines (+ num-lines --line)) --ref)))
--locs "\n")
"\n")))