ob-tangle.el 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  1. ;;; ob-tangle.el --- extract source code from org-mode files
  2. ;; Copyright (C) 2009-2014 Free Software Foundation, Inc.
  3. ;; Author: Eric Schulte
  4. ;; Keywords: literate programming, reproducible research
  5. ;; Homepage: http://orgmode.org
  6. ;; This file is part of GNU Emacs.
  7. ;; GNU Emacs is free software: you can redistribute it and/or modify
  8. ;; it under the terms of the GNU General Public License as published by
  9. ;; the Free Software Foundation, either version 3 of the License, or
  10. ;; (at your option) any later version.
  11. ;; GNU Emacs is distributed in the hope that it will be useful,
  12. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. ;; GNU General Public License for more details.
  15. ;; You should have received a copy of the GNU General Public License
  16. ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  17. ;;; Commentary:
  18. ;; Extract the code from source blocks out into raw source-code files.
  19. ;;; Code:
  20. (require 'org-src)
  21. (eval-when-compile
  22. (require 'cl))
  23. (declare-function org-edit-special "org" (&optional arg))
  24. (declare-function org-link-escape "org" (text &optional table))
  25. (declare-function org-store-link "org" (arg))
  26. (declare-function org-open-link-from-string "org" (s &optional arg reference-buffer))
  27. (declare-function org-heading-components "org" ())
  28. (declare-function org-back-to-heading "org" (invisible-ok))
  29. (declare-function org-fill-template "org" (template alist))
  30. (declare-function org-babel-update-block-body "org" (new-body))
  31. (declare-function make-directory "files" (dir &optional parents))
  32. (defcustom org-babel-tangle-lang-exts
  33. '(("emacs-lisp" . "el"))
  34. "Alist mapping languages to their file extensions.
  35. The key is the language name, the value is the string that should
  36. be inserted as the extension commonly used to identify files
  37. written in this language. If no entry is found in this list,
  38. then the name of the language is used."
  39. :group 'org-babel-tangle
  40. :version "24.1"
  41. :type '(repeat
  42. (cons
  43. (string "Language name")
  44. (string "File Extension"))))
  45. (defcustom org-babel-post-tangle-hook nil
  46. "Hook run in code files tangled by `org-babel-tangle'."
  47. :group 'org-babel
  48. :version "24.1"
  49. :type 'hook)
  50. (defcustom org-babel-pre-tangle-hook '(save-buffer)
  51. "Hook run at the beginning of `org-babel-tangle'."
  52. :group 'org-babel
  53. :version "24.1"
  54. :type 'hook)
  55. (defcustom org-babel-tangle-body-hook nil
  56. "Hook run over the contents of each code block body."
  57. :group 'org-babel
  58. :version "24.1"
  59. :type 'hook)
  60. (defcustom org-babel-tangle-comment-format-beg "[[%link][%source-name]]"
  61. "Format of inserted comments in tangled code files.
  62. The following format strings can be used to insert special
  63. information into the output using `org-fill-template'.
  64. %start-line --- the line number at the start of the code block
  65. %file --------- the file from which the code block was tangled
  66. %link --------- Org-mode style link to the code block
  67. %source-name -- name of the code block
  68. Whether or not comments are inserted during tangling is
  69. controlled by the :comments header argument."
  70. :group 'org-babel
  71. :version "24.1"
  72. :type 'string)
  73. (defcustom org-babel-tangle-comment-format-end "%source-name ends here"
  74. "Format of inserted comments in tangled code files.
  75. The following format strings can be used to insert special
  76. information into the output using `org-fill-template'.
  77. %start-line --- the line number at the start of the code block
  78. %file --------- the file from which the code block was tangled
  79. %link --------- Org-mode style link to the code block
  80. %source-name -- name of the code block
  81. Whether or not comments are inserted during tangling is
  82. controlled by the :comments header argument."
  83. :group 'org-babel
  84. :version "24.1"
  85. :type 'string)
  86. (defcustom org-babel-process-comment-text #'org-babel-trim
  87. "Function called to process raw Org-mode text collected to be
  88. inserted as comments in tangled source-code files. The function
  89. should take a single string argument and return a string
  90. result. The default value is `org-babel-trim'."
  91. :group 'org-babel
  92. :version "24.1"
  93. :type 'function)
  94. (defun org-babel-find-file-noselect-refresh (file)
  95. "Find file ensuring that the latest changes on disk are
  96. represented in the file."
  97. (find-file-noselect file 'nowarn)
  98. (with-current-buffer (get-file-buffer file)
  99. (revert-buffer t t t)))
  100. (defmacro org-babel-with-temp-filebuffer (file &rest body)
  101. "Open FILE into a temporary buffer execute BODY there like
  102. `progn', then kill the FILE buffer returning the result of
  103. evaluating BODY."
  104. (declare (indent 1))
  105. (let ((temp-path (make-symbol "temp-path"))
  106. (temp-result (make-symbol "temp-result"))
  107. (temp-file (make-symbol "temp-file"))
  108. (visited-p (make-symbol "visited-p")))
  109. `(let* ((,temp-path ,file)
  110. (,visited-p (get-file-buffer ,temp-path))
  111. ,temp-result ,temp-file)
  112. (org-babel-find-file-noselect-refresh ,temp-path)
  113. (setf ,temp-file (get-file-buffer ,temp-path))
  114. (with-current-buffer ,temp-file
  115. (setf ,temp-result (progn ,@body)))
  116. (unless ,visited-p (kill-buffer ,temp-file))
  117. ,temp-result)))
  118. (def-edebug-spec org-babel-with-temp-filebuffer (form body))
  119. ;;;###autoload
  120. (defun org-babel-tangle-file (file &optional target-file lang)
  121. "Extract the bodies of source code blocks in FILE.
  122. Source code blocks are extracted with `org-babel-tangle'.
  123. Optional argument TARGET-FILE can be used to specify a default
  124. export file for all source blocks. Optional argument LANG can be
  125. used to limit the exported source code blocks by language.
  126. Return a list whose CAR is the tangled file name."
  127. (interactive "fFile to tangle: \nP")
  128. (let ((visited-p (get-file-buffer (expand-file-name file)))
  129. to-be-removed)
  130. (prog1
  131. (save-window-excursion
  132. (find-file file)
  133. (setq to-be-removed (current-buffer))
  134. (org-babel-tangle nil target-file lang))
  135. (unless visited-p
  136. (kill-buffer to-be-removed)))))
  137. (defun org-babel-tangle-publish (_ filename pub-dir)
  138. "Tangle FILENAME and place the results in PUB-DIR."
  139. (mapc (lambda (el) (copy-file el pub-dir t)) (org-babel-tangle-file filename)))
  140. ;;;###autoload
  141. (defun org-babel-tangle (&optional arg target-file lang)
  142. "Write code blocks to source-specific files.
  143. Extract the bodies of all source code blocks from the current
  144. file into their own source-specific files.
  145. With one universal prefix argument, only tangle the block at point.
  146. When two universal prefix arguments, only tangle blocks for the
  147. tangle file of the block at point.
  148. Optional argument TARGET-FILE can be used to specify a default
  149. export file for all source blocks. Optional argument LANG can be
  150. used to limit the exported source code blocks by language."
  151. (interactive "P")
  152. (run-hooks 'org-babel-pre-tangle-hook)
  153. ;; Possibly Restrict the buffer to the current code block
  154. (save-restriction
  155. (when (equal arg '(4))
  156. (let ((head (org-babel-where-is-src-block-head)))
  157. (if head
  158. (goto-char head)
  159. (user-error "Point is not in a source code block"))))
  160. (save-excursion
  161. (let ((block-counter 0)
  162. (org-babel-default-header-args
  163. (if target-file
  164. (org-babel-merge-params org-babel-default-header-args
  165. (list (cons :tangle target-file)))
  166. org-babel-default-header-args))
  167. (tangle-file
  168. (when (equal arg '(16))
  169. (or (cdr (assoc :tangle (nth 2 (org-babel-get-src-block-info 'light))))
  170. (user-error "Point is not in a source code block"))))
  171. path-collector)
  172. (mapc ;; map over all languages
  173. (lambda (by-lang)
  174. (let* ((lang (car by-lang))
  175. (specs (cdr by-lang))
  176. (ext (or (cdr (assoc lang org-babel-tangle-lang-exts)) lang))
  177. (lang-f (intern
  178. (concat
  179. (or (and (cdr (assoc lang org-src-lang-modes))
  180. (symbol-name
  181. (cdr (assoc lang org-src-lang-modes))))
  182. lang)
  183. "-mode")))
  184. she-banged)
  185. (mapc
  186. (lambda (spec)
  187. (let ((get-spec (lambda (name) (cdr (assoc name (nth 4 spec))))))
  188. (let* ((tangle (funcall get-spec :tangle))
  189. (she-bang (let ((sheb (funcall get-spec :shebang)))
  190. (when (> (length sheb) 0) sheb)))
  191. (tangle-mode (funcall get-spec :tangle-mode))
  192. (base-name (cond
  193. ((string= "yes" tangle)
  194. (file-name-sans-extension
  195. (buffer-file-name)))
  196. ((string= "no" tangle) nil)
  197. ((> (length tangle) 0) tangle)))
  198. (file-name (when base-name
  199. ;; decide if we want to add ext to base-name
  200. (if (and ext (string= "yes" tangle))
  201. (concat base-name "." ext) base-name))))
  202. (when file-name
  203. ;; Possibly create the parent directories for file.
  204. (let ((m (funcall get-spec :mkdirp))
  205. (fnd (file-name-directory file-name)))
  206. (and m fnd (not (string= m "no"))
  207. (make-directory fnd 'parents)))
  208. ;; delete any old versions of file
  209. (and (file-exists-p file-name)
  210. (not (member file-name (mapcar #'car path-collector)))
  211. (delete-file file-name))
  212. ;; drop source-block to file
  213. (with-temp-buffer
  214. (when (fboundp lang-f) (ignore-errors (funcall lang-f)))
  215. (when (and she-bang (not (member file-name she-banged)))
  216. (insert (concat she-bang "\n"))
  217. (setq she-banged (cons file-name she-banged)))
  218. (org-babel-spec-to-string spec)
  219. ;; We avoid append-to-file as it does not work with tramp.
  220. (let ((content (buffer-string)))
  221. (with-temp-buffer
  222. (if (file-exists-p file-name)
  223. (insert-file-contents file-name))
  224. (goto-char (point-max))
  225. (insert content)
  226. (write-region nil nil file-name))))
  227. ;; if files contain she-bangs, then make the executable
  228. (when she-bang
  229. (unless tangle-mode (setq tangle-mode #o755)))
  230. ;; update counter
  231. (setq block-counter (+ 1 block-counter))
  232. (add-to-list 'path-collector
  233. (cons file-name tangle-mode)
  234. nil
  235. (lambda (a b) (equal (car a) (car b))))))))
  236. specs)))
  237. (if (equal arg '(4))
  238. (org-babel-tangle-single-block 1 t)
  239. (org-babel-tangle-collect-blocks lang tangle-file)))
  240. (message "Tangled %d code block%s from %s" block-counter
  241. (if (= block-counter 1) "" "s")
  242. (file-name-nondirectory
  243. (buffer-file-name
  244. (or (buffer-base-buffer) (current-buffer)))))
  245. ;; run `org-babel-post-tangle-hook' in all tangled files
  246. (when org-babel-post-tangle-hook
  247. (mapc
  248. (lambda (file)
  249. (org-babel-with-temp-filebuffer file
  250. (run-hooks 'org-babel-post-tangle-hook)))
  251. (mapcar #'car path-collector)))
  252. ;; set permissions on tangled files
  253. (mapc (lambda (pair)
  254. (when (cdr pair) (set-file-modes (car pair) (cdr pair))))
  255. path-collector)
  256. (mapcar #'car path-collector)))))
  257. (defun org-babel-tangle-clean ()
  258. "Remove comments inserted by `org-babel-tangle'.
  259. Call this function inside of a source-code file generated by
  260. `org-babel-tangle' to remove all comments inserted automatically
  261. by `org-babel-tangle'. Warning, this comment removes any lines
  262. containing constructs which resemble org-mode file links or noweb
  263. references."
  264. (interactive)
  265. (goto-char (point-min))
  266. (while (or (re-search-forward "\\[\\[file:.*\\]\\[.*\\]\\]" nil t)
  267. (re-search-forward (org-babel-noweb-wrap) nil t))
  268. (delete-region (save-excursion (beginning-of-line 1) (point))
  269. (save-excursion (end-of-line 1) (forward-char 1) (point)))))
  270. (defvar org-stored-links)
  271. (defvar org-bracket-link-regexp)
  272. (defun org-babel-spec-to-string (spec)
  273. "Insert SPEC into the current file.
  274. Insert the source-code specified by SPEC into the current source
  275. code file. This function uses `comment-region' which assumes
  276. that the appropriate major-mode is set. SPEC has the form:
  277. \(start-line file link source-name params body comment)"
  278. (let* ((start-line (nth 0 spec))
  279. (file (nth 1 spec))
  280. (link (nth 2 spec))
  281. (source-name (nth 3 spec))
  282. (body (nth 5 spec))
  283. (comment (nth 6 spec))
  284. (comments (cdr (assoc :comments (nth 4 spec))))
  285. (padline (not (string= "no" (cdr (assoc :padline (nth 4 spec))))))
  286. (link-p (or (string= comments "both") (string= comments "link")
  287. (string= comments "yes") (string= comments "noweb")))
  288. (link-data (mapcar (lambda (el)
  289. (cons (symbol-name el)
  290. (let ((le (eval el)))
  291. (if (stringp le) le (format "%S" le)))))
  292. '(start-line file link source-name)))
  293. (insert-comment (lambda (text)
  294. (when (and comments (not (string= comments "no"))
  295. (> (length text) 0))
  296. (when padline (insert "\n"))
  297. (comment-region (point) (progn (insert text) (point)))
  298. (end-of-line nil) (insert "\n")))))
  299. (when comment (funcall insert-comment comment))
  300. (when link-p
  301. (funcall
  302. insert-comment
  303. (org-fill-template org-babel-tangle-comment-format-beg link-data)))
  304. (when padline (insert "\n"))
  305. (insert
  306. (format
  307. "%s\n"
  308. (org-unescape-code-in-string
  309. (org-babel-trim body (if org-src-preserve-indentation "[\f\n\r\v]")))))
  310. (when link-p
  311. (funcall
  312. insert-comment
  313. (org-fill-template org-babel-tangle-comment-format-end link-data)))))
  314. (defvar org-comment-string) ;; Defined in org.el
  315. (defun org-babel-tangle-collect-blocks (&optional language tangle-file)
  316. "Collect source blocks in the current Org-mode file.
  317. Return an association list of source-code block specifications of
  318. the form used by `org-babel-spec-to-string' grouped by language.
  319. Optional argument LANGUAGE can be used to limit the collected
  320. source code blocks by language. Optional argument TANGLE-FILE
  321. can be used to limit the collected code blocks by target file."
  322. (let ((block-counter 1) (current-heading "") blocks by-lang)
  323. (org-babel-map-src-blocks (buffer-file-name)
  324. (lambda (new-heading)
  325. (if (not (string= new-heading current-heading))
  326. (progn
  327. (setq block-counter 1)
  328. (setq current-heading new-heading))
  329. (setq block-counter (+ 1 block-counter))))
  330. (replace-regexp-in-string "[ \t]" "-"
  331. (condition-case nil
  332. (or (nth 4 (org-heading-components))
  333. "(dummy for heading without text)")
  334. (error (buffer-file-name))))
  335. (let* ((info (org-babel-get-src-block-info 'light))
  336. (src-lang (nth 0 info))
  337. (src-tfile (cdr (assoc :tangle (nth 2 info)))))
  338. (unless (or (string-match (concat "^" org-comment-string) current-heading)
  339. (string= (cdr (assoc :tangle (nth 2 info))) "no")
  340. (and tangle-file (not (equal tangle-file src-tfile))))
  341. (unless (and language (not (string= language src-lang)))
  342. ;; Add the spec for this block to blocks under it's language
  343. (setq by-lang (cdr (assoc src-lang blocks)))
  344. (setq blocks (delq (assoc src-lang blocks) blocks))
  345. (setq blocks (cons
  346. (cons src-lang
  347. (cons
  348. (org-babel-tangle-single-block
  349. block-counter)
  350. by-lang)) blocks))))))
  351. ;; Ensure blocks are in the correct order
  352. (setq blocks
  353. (mapcar
  354. (lambda (by-lang) (cons (car by-lang) (reverse (cdr by-lang))))
  355. blocks))
  356. blocks))
  357. (defun org-babel-tangle-single-block
  358. (block-counter &optional only-this-block)
  359. "Collect the tangled source for current block.
  360. Return the list of block attributes needed by
  361. `org-babel-tangle-collect-blocks'.
  362. When ONLY-THIS-BLOCK is non-nil, return the full association
  363. list to be used by `org-babel-tangle' directly."
  364. (let* ((info (org-babel-get-src-block-info))
  365. (start-line
  366. (save-restriction (widen)
  367. (+ 1 (line-number-at-pos (point)))))
  368. (file (buffer-file-name))
  369. (src-lang (nth 0 info))
  370. (params (nth 2 info))
  371. (extra (nth 3 info))
  372. (cref-fmt (or (and (string-match "-l \"\\(.+\\)\"" extra)
  373. (match-string 1 extra))
  374. org-coderef-label-format))
  375. (link (let ((link (org-no-properties
  376. (org-store-link nil))))
  377. (and (string-match org-bracket-link-regexp link)
  378. (match-string 1 link))))
  379. (source-name
  380. (intern (or (nth 4 info)
  381. (format "%s:%d"
  382. (or (ignore-errors (nth 4 (org-heading-components)))
  383. "No heading")
  384. block-counter))))
  385. (expand-cmd
  386. (intern (concat "org-babel-expand-body:" src-lang)))
  387. (assignments-cmd
  388. (intern (concat "org-babel-variable-assignments:" src-lang)))
  389. (body
  390. ;; Run the tangle-body-hook.
  391. (let* ((body ;; Expand the body in language specific manner.
  392. (if (org-babel-noweb-p params :tangle)
  393. (org-babel-expand-noweb-references info)
  394. (nth 1 info)))
  395. (body
  396. (if (assoc :no-expand params)
  397. body
  398. (if (fboundp expand-cmd)
  399. (funcall expand-cmd body params)
  400. (org-babel-expand-body:generic
  401. body params
  402. (and (fboundp assignments-cmd)
  403. (funcall assignments-cmd params)))))))
  404. (with-temp-buffer
  405. (insert body)
  406. (when (string-match "-r" extra)
  407. (goto-char (point-min))
  408. (while (re-search-forward
  409. (replace-regexp-in-string "%s" ".+" cref-fmt) nil t)
  410. (replace-match "")))
  411. (run-hooks 'org-babel-tangle-body-hook)
  412. (buffer-string))))
  413. (comment
  414. (when (or (string= "both" (cdr (assoc :comments params)))
  415. (string= "org" (cdr (assoc :comments params))))
  416. ;; From the previous heading or code-block end
  417. (funcall
  418. org-babel-process-comment-text
  419. (buffer-substring
  420. (max (condition-case nil
  421. (save-excursion
  422. (org-back-to-heading t) ; Sets match data
  423. (match-end 0))
  424. (error (point-min)))
  425. (save-excursion
  426. (if (re-search-backward
  427. org-babel-src-block-regexp nil t)
  428. (match-end 0)
  429. (point-min))))
  430. (point)))))
  431. (result
  432. (list start-line file link source-name params body comment)))
  433. (if only-this-block
  434. (list (cons src-lang (list result)))
  435. result)))
  436. (defun org-babel-tangle-comment-links ( &optional info)
  437. "Return a list of begin and end link comments for the code block at point."
  438. (let* ((start-line (org-babel-where-is-src-block-head))
  439. (file (buffer-file-name))
  440. (link (org-link-escape (progn (call-interactively 'org-store-link)
  441. (org-no-properties
  442. (car (pop org-stored-links))))))
  443. (source-name (nth 4 (or info (org-babel-get-src-block-info 'light))))
  444. (link-data (mapcar (lambda (el)
  445. (cons (symbol-name el)
  446. (let ((le (eval el)))
  447. (if (stringp le) le (format "%S" le)))))
  448. '(start-line file link source-name))))
  449. (list (org-fill-template org-babel-tangle-comment-format-beg link-data)
  450. (org-fill-template org-babel-tangle-comment-format-end link-data))))
  451. ;; de-tangling functions
  452. (defvar org-bracket-link-analytic-regexp)
  453. (defun org-babel-detangle (&optional source-code-file)
  454. "Propagate changes in source file back original to Org-mode file.
  455. This requires that code blocks were tangled with link comments
  456. which enable the original code blocks to be found."
  457. (interactive)
  458. (save-excursion
  459. (when source-code-file (find-file source-code-file))
  460. (goto-char (point-min))
  461. (let ((counter 0) new-body end)
  462. (while (re-search-forward org-bracket-link-analytic-regexp nil t)
  463. (when (re-search-forward
  464. (concat " " (regexp-quote (match-string 5)) " ends here"))
  465. (setq end (match-end 0))
  466. (forward-line -1)
  467. (save-excursion
  468. (when (setq new-body (org-babel-tangle-jump-to-org))
  469. (org-babel-update-block-body new-body)))
  470. (setq counter (+ 1 counter)))
  471. (goto-char end))
  472. (prog1 counter (message "Detangled %d code blocks" counter)))))
  473. (defun org-babel-tangle-jump-to-org ()
  474. "Jump from a tangled code file to the related Org-mode file."
  475. (interactive)
  476. (let ((mid (point))
  477. start body-start end done
  478. target-buffer target-char link path block-name body)
  479. (save-window-excursion
  480. (save-excursion
  481. (while (and (re-search-backward org-bracket-link-analytic-regexp nil t)
  482. (not ; ever wider searches until matching block comments
  483. (and (setq start (point-at-eol))
  484. (setq body-start (save-excursion
  485. (forward-line 2) (point-at-bol)))
  486. (setq link (match-string 0))
  487. (setq path (match-string 3))
  488. (setq block-name (match-string 5))
  489. (save-excursion
  490. (save-match-data
  491. (re-search-forward
  492. (concat " " (regexp-quote block-name)
  493. " ends here") nil t)
  494. (setq end (point-at-bol))))))))
  495. (unless (and start (< start mid) (< mid end))
  496. (error "Not in tangled code"))
  497. (setq body (org-babel-trim (buffer-substring start end))))
  498. (when (string-match "::" path)
  499. (setq path (substring path 0 (match-beginning 0))))
  500. (find-file path) (setq target-buffer (current-buffer))
  501. (goto-char start) (org-open-link-from-string link)
  502. (if (string-match "[^ \t\n\r]:\\([[:digit:]]+\\)" block-name)
  503. (org-babel-next-src-block
  504. (string-to-number (match-string 1 block-name)))
  505. (org-babel-goto-named-src-block block-name))
  506. ;; position at the beginning of the code block body
  507. (goto-char (org-babel-where-is-src-block-head))
  508. (forward-line 1)
  509. ;; Use org-edit-special to isolate the code.
  510. (org-edit-special)
  511. ;; Then move forward the correct number of characters in the
  512. ;; code buffer.
  513. (forward-char (- mid body-start))
  514. ;; And return to the Org-mode buffer with the point in the right
  515. ;; place.
  516. (org-edit-src-exit)
  517. (setq target-char (point)))
  518. (org-src-switch-to-buffer target-buffer t)
  519. (prog1 body (goto-char target-char))))
  520. (provide 'ob-tangle)
  521. ;; Local variables:
  522. ;; generated-autoload-file: "org-loaddefs.el"
  523. ;; End:
  524. ;;; ob-tangle.el ends here