Inhibiting Babel Evaluate Confirmation On The Mode Line

In Setting the Babel Evaluate Confirm Status, I wrote about Org-mode's Babel asking for confirmation before executing a code block and why it's sometimes convenient to turn that behavior off. In the post, I presented a simple Emacs Lisp function, babel-confirm to test the status of org-confirm-babel-evaluate and to optionally toggle its value. It's often convenient to be able to turn off the confirmation question, especially when the code block gets called many times, such as when a table full of computable cells is evaluated.

Sometimes we have a file that we know is safe and that we often update and evaluate. One such example is my daily steps file, which has an R code block to generate the statistics max, min, mean, median, and standard deviation. Every day I enter the previous day's steps and type 【Ctrl+c Ctrl+c】 to calculate the statistics. Each time I do this, Babel asks me to confirm that I really want to evaluate the code block. Notice that babel-confirm doesn't help here because it takes more typing than just answering y to the question.

Yesterday, I saw this post on the Emacs reddit, which suggests another method: just put a mode line at the top of your file that turns org-confirm-babel-evaluate off. That way you get rid of the annoying question for that one file but keep the security of asking for confirmation for other files. To do this, just put

# -*- org-confirm-babel-evaluate: nil -*-

at the top of your file.

What could be simpler? It's easy to forget the power of the mode line and that's too bad because sometimes it's just what you need.

This entry was posted in General and tagged , , . Bookmark the permalink.