diff options
author | Eric Schulte <schulte.eric@gmail.com> | 2010-07-08 11:53:51 -0700 |
---|---|---|
committer | Eric Schulte <schulte.eric@gmail.com> | 2010-07-08 11:58:20 -0700 |
commit | abcb76891b1aa7d7c7f4798f7fd78bffb184d361 (patch) | |
tree | 71e5683226a06222d55944fa331ebf7990d17868 | |
parent | 19e98b1b0fee13506f4861699ae53c889179df3c (diff) | |
download | org-mode-abcb76891b1aa7d7c7f4798f7fd78bffb184d361.tar.gz |
org-babel-post-tangle-hook run in code files tangled by `org-babel-tangle'
* lisp/ob-tangle.el (org-babel-post-tangle-hook): adding hook which
can be used to call functions from inside of code files tangled by
org-babel-tangle
(org-babel-tangle): added call to org-babel-post-tangle-hook
-rw-r--r-- | lisp/ob-tangle.el | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el index 484309b..4401b5c 100644 --- a/lisp/ob-tangle.el +++ b/lisp/ob-tangle.el @@ -47,6 +47,11 @@ then the name of the language is used." (string "Language name") (string "File Extension")))) +(defcustom org-babel-post-tangle-hook nil + "Hook run in code files tangled by `org-babel-tangle'." + :group 'org-babel + :type 'hook) + ;;;###autoload (defun org-babel-load-file (file) "Load the contents of the Emacs Lisp source code blocks in the @@ -138,7 +143,7 @@ exported source code blocks by language." (delete-file file-name)) ;; drop source-block to file (with-temp-buffer - (if (fboundp lang-f) (funcall lang-f)) + (when (fboundp lang-f) (funcall lang-f)) (when (and she-bang (not (member file-name she-banged))) (insert (concat she-bang "\n")) (setq she-banged (cons file-name she-banged))) @@ -160,6 +165,13 @@ exported source code blocks by language." (org-babel-tangle-collect-blocks lang)) (message "tangled %d code block%s" block-counter (if (= block-counter 1) "" "s")) + ;; run `org-babel-post-tangle-hook' in all tangled files + (when org-babel-post-tangle-hook + (mapc + (lambda (file) + (with-temp-filebuffer file + (run-hooks 'org-babel-post-tangle-hook))) + path-collector)) path-collector))) (defun org-babel-tangle-clean () |