Function: org-babel-tangle-file

org-babel-tangle-file is an autoloaded, interactive and byte-compiled function defined in ob-tangle.el.gz.

Signature

(org-babel-tangle-file FILE &optional TARGET-FILE LANG-RE)

Documentation

Extract the bodies of source code blocks in FILE.

Source code blocks are extracted with org-babel-tangle.

Optional argument TARGET-FILE can be used to specify a default export file for all source blocks.

Optional argument LANG-RE can be used to limit the exported source code blocks by languages matching a regular expression.

Return list of the tangled file names.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/org/ob-tangle.el.gz
;;;###autoload
(defun org-babel-tangle-file (file &optional target-file lang-re)
  "Extract the bodies of source code blocks in FILE.
Source code blocks are extracted with `org-babel-tangle'.

Optional argument TARGET-FILE can be used to specify a default
export file for all source blocks.

Optional argument LANG-RE can be used to limit the exported
source code blocks by languages matching a regular expression.

Return list of the tangled file names."
  (interactive "fFile to tangle: \nP")
  (let* ((visited (find-buffer-visiting file))
         (buffer (or visited (find-file-noselect file))))
    (prog1
        (with-current-buffer buffer
          (org-with-wide-buffer
           (mapcar #'expand-file-name
                   (org-babel-tangle nil target-file lang-re))))
      (unless visited (kill-buffer buffer)))))