Browse Source

ob-tangle: adding pre-tangle hook for customization of tangle preparation

* lisp/ob-tangle.el (org-babel-pre-tangle-hook): defines new tangle
  hook
  (org-babel-tangle): calls new tangle hook
Eric Schulte 10 years ago
parent
commit
48114acd2a
1 changed files with 6 additions and 1 deletions
  1. 6 1
      lisp/ob-tangle.el

+ 6 - 1
lisp/ob-tangle.el

@@ -53,6 +53,11 @@ then the name of the language is used."
   :group 'org-babel
   :type 'hook)
 
+(defcustom org-babel-pre-tangle-hook '(save-buffer)
+  "Hook run at the beginning of `org-babel-tangle'."
+  :group 'org-babel
+  :type 'hook)
+
 (defun org-babel-find-file-noselect-refresh (file)
   "Find file ensuring that the latest changes on disk are
 represented in the file."
@@ -127,7 +132,7 @@ 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)
-  (save-buffer)
+  (run-hooks 'org-babel-pre-tangle-hook)
   (save-excursion
     (let ((block-counter 0)
 	  (org-babel-default-header-args