branch: elpa/org-auto-tangle
commit ad3c332f062b5830e88b2ab13287a096ae434657
Merge: 50292af50d bc129f881b
Author: lispy-dobby <[email protected]>
Commit: GitHub <[email protected]>
Merge pull request #13 from fredericgiquel/babel-evaluation
Permit code block evaluation for files in safelist
---
org-auto-tangle.el | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/org-auto-tangle.el b/org-auto-tangle.el
index 95a8d0f684..554107a303 100644
--- a/org-auto-tangle.el
+++ b/org-auto-tangle.el
@@ -56,6 +56,13 @@ If nil (default), auto-tangle will only happen on buffers
with
the `#+auto_tangle: t' keyword. If t, auto-tangle will happen on
all Org buffers unless `#+auto_tangle: nil' is set.")
+(defvar org-auto-tangle-babel-safelist '()
+ "List of full path of files for which code blocks need to be evaluated.
+
+By default, code blocks are not evaluated during the auto-tangle to avoid
+possible code execution from unstrusted source. To enable code blocks
evaluation
+for a specific file, add its full path to this list.")
+
(defun org-auto-tangle-find-value (buffer)
"Search the `auto_tangle' property in BUFFER and extracts it when found."
(with-current-buffer buffer
@@ -74,7 +81,8 @@ all Org buffers unless `#+auto_tangle: nil' is set.")
`(lambda ()
(require 'org)
(let ((start-time (current-time))
- (non-essential t))
+ (non-essential t)
+ (org-confirm-babel-evaluate (not (member ,file
',org-auto-tangle-babel-safelist))))
(apply #'org-babel-tangle-file ',args)
(format "%.2f" (float-time (time-since start-time))))))
(let ((message-string (format "Tangling %S completed after" file)))