Skip to content

Commit ad3c332

Browse files
authored
Merge pull request #13 from fredericgiquel/babel-evaluation
Permit code block evaluation for files in safelist
2 parents 50292af + bc129f8 commit ad3c332

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

org-auto-tangle.el

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ If nil (default), auto-tangle will only happen on buffers with
5656
the `#+auto_tangle: t' keyword. If t, auto-tangle will happen on
5757
all Org buffers unless `#+auto_tangle: nil' is set.")
5858

59+
(defvar org-auto-tangle-babel-safelist '()
60+
"List of full path of files for which code blocks need to be evaluated.
61+
62+
By default, code blocks are not evaluated during the auto-tangle to avoid
63+
possible code execution from unstrusted source. To enable code blocks evaluation
64+
for a specific file, add its full path to this list.")
65+
5966
(defun org-auto-tangle-find-value (buffer)
6067
"Search the `auto_tangle' property in BUFFER and extracts it when found."
6168
(with-current-buffer buffer
@@ -74,7 +81,8 @@ all Org buffers unless `#+auto_tangle: nil' is set.")
7481
`(lambda ()
7582
(require 'org)
7683
(let ((start-time (current-time))
77-
(non-essential t))
84+
(non-essential t)
85+
(org-confirm-babel-evaluate (not (member ,file ',org-auto-tangle-babel-safelist))))
7886
(apply #'org-babel-tangle-file ',args)
7987
(format "%.2f" (float-time (time-since start-time))))))
8088
(let ((message-string (format "Tangling %S completed after" file)))

0 commit comments

Comments
 (0)