1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-11-22 07:09:47 +00:00

tangle: ob-tangle now tangles only the current block when called with a prefix argument

* lisp/ob-tangle.el (org-babel-tangle-file): Use the new argument list
  to org-babel-tangle.
  (org-babel-tangle): Now when called with a prefix argument, only the
  current code block is tangled.
This commit is contained in:
Eric Schulte 2011-06-17 16:41:50 -07:00
parent db1c3f6a3e
commit e4204fc3fe

View File

@ -154,7 +154,7 @@ used to limit the exported source code blocks by language."
(save-window-excursion
(find-file file)
(setq to-be-removed (current-buffer))
(org-babel-tangle target-file lang))
(org-babel-tangle nil target-file lang))
(unless visited-p
(kill-buffer to-be-removed))))
@ -163,15 +163,24 @@ used to limit the exported source code blocks by language."
(mapc (lambda (el) (copy-file el pub-dir t)) (org-babel-tangle-file filename)))
;;;###autoload
(defun org-babel-tangle (&optional target-file lang)
(defun org-babel-tangle (&optional only-this-block target-file lang)
"Write code blocks to source-specific files.
Extract the bodies of all source code blocks from the current
file into their own source-specific files. Optional argument
TARGET-FILE can be used to specify a default export file for all
source blocks. Optional argument LANG can be used to limit the
exported source code blocks by language."
(interactive)
(interactive "P")
(run-hooks 'org-babel-pre-tangle-hook)
;; possibly restrict the buffer to the current code block
(save-restriction
(when only-this-block
(unless (org-babel-where-is-src-block-head)
(error "Point is not currently inside of a code block"))
(unless target-file
(setq target-file
(read-from-minibuffer "Tangle to: " (buffer-file-name))))
(narrow-to-region (match-beginning 0) (match-end 0)))
(save-excursion
(let ((block-counter 0)
(org-babel-default-header-args
@ -252,7 +261,7 @@ exported source code blocks by language."
(org-babel-with-temp-filebuffer file
(run-hooks 'org-babel-post-tangle-hook)))
path-collector))
path-collector)))
path-collector))))
(defun org-babel-tangle-clean ()
"Remove comments inserted by `org-babel-tangle'.