From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id CEiiCNXYFmM4PAAAbAwnHQ (envelope-from ) for ; Tue, 06 Sep 2022 07:21:25 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id mDu1CNXYFmNXLwAA9RJhRA (envelope-from ) for ; Tue, 06 Sep 2022 07:21:25 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id D171731EAC for ; Tue, 6 Sep 2022 07:21:24 +0200 (CEST) Received: from localhost ([::1]:40118 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oVR1W-0001pT-Tg for larch@yhetil.org; Tue, 06 Sep 2022 01:21:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58378) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oVLrx-0000R1-T2 for emacs-orgmode@gnu.org; Mon, 05 Sep 2022 19:51:09 -0400 Received: from mail-4319.protonmail.ch ([185.70.43.19]:21963) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oVLrs-0008E3-KM for emacs-orgmode@gnu.org; Mon, 05 Sep 2022 19:51:09 -0400 Date: Mon, 05 Sep 2022 23:50:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.ch; s=protonmail3; t=1662421860; x=1662681060; bh=4at0COVZdJPEwgzRC6HHV9f5bxyVkHZscltTZF2s80A=; h=Date:To:From:Reply-To:Subject:Message-ID:Feedback-ID:From:To:Cc: Date:Subject:Reply-To:Feedback-ID:Message-ID; b=X0WJVRmLfaktDX5XD5XFAoccc3Gg2fHaTHdG+JtWAZR2I/lNJOdhThlH2i5MNMS/S gwrJkN6wBZfTggG7YQ4jWePFGE1bGaVvQPs5T/Q7nXdMq3ryi7qhU92fph1bRvf2q9 Xt2FqCjzrdZ73Ew7IXrDmRxE2l+9kClYIkBKxuhn2L9wYsPqNiILh9NFRufLoZ8+QB FNbhR+3BXkGNsDXzFTzILqc2ocAPVYvMuuaMTEheteYDSuvmtyXhnnENg16FLjaboL 3B31iQ9dRhspoxw+NVCWPUhpAxCHer0v3ejen04JBuk3+n3ogbwqvvI/K1JBnuJZ4b 66+rAdYXuEfNw== To: "emacs-orgmode@gnu.org" From: Fedja Beader Subject: per-file (or, really, per buffer) allowing/disallowing code block execution Message-ID: Feedback-ID: 216965:user:proton MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=185.70.43.19; envelope-from=fedja@protonmail.ch; helo=mail-4319.protonmail.ch X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Tue, 06 Sep 2022 01:20:05 -0400 X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Fedja Beader Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1662441685; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=4at0COVZdJPEwgzRC6HHV9f5bxyVkHZscltTZF2s80A=; b=FKimYhUR7t/WlJQZZdrJkR/B95HamN/h0hWIO+Vi6l/sUAmZtIMqfYU22OzN2FX3yqm/Lf /tGOk5cgO53Mdo3LwzODYkWnIWZXx7cre6qH8LlTm0LE/DTrrWE/lY/M2F7WhMyvt5VQZn Jf6JOS/n477ZrraVM2QeXSe8etCFhWVu4tjpMiRjCPjY6j/Km0ohf/vQ5OcheiHKvRrFQA ryug6Vzu2xG387bx+rqWDclTfgYGdVSJhEHrWEPLoYVOqqNAi5BWeAWnQHmLy87qRBY6FI prycBjLMnrynADOVOFdQpkfVHKc/EnzO9U9UP3baeAPgEyFOguM8SPivoTDYZQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1662441685; a=rsa-sha256; cv=none; b=JBle6R5z+yw69Ad++6CeuY0zb8qL/lZxVCbmErjqTdSEVPlPbBzRPzuyubdS7OEdnnmyw3 SLcWQ0ECYhxM43KLmPqINlaI8o51sDk2rvgQBnklSglvu8Y/vSPq03kzJUZ7bGZhP909G6 xHH+c+M5o0KSjCGn//WNbmphER/a5Gj2wp115oxmO9qmoaefIcxxDViuBR6BWlHXpIHdWz z+91aMN2LDNrHNLHQam+ek22JQHwiaKDcX9Tl6e7pNYkr6fjrUPSqmx8L9zLi2UI+AtSoc cFIgCJ39uk/FvYmBrl4gfimUM/ohyETgTiWxGyYhWXfq8oqkAHJqiZl4pZzTqw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=protonmail.ch header.s=protonmail3 header.b=X0WJVRmL; dmarc=pass (policy=quarantine) header.from=protonmail.ch; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -2.28 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=protonmail.ch header.s=protonmail3 header.b=X0WJVRmL; dmarc=pass (policy=quarantine) header.from=protonmail.ch; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: D171731EAC X-Spam-Score: -2.28 X-Migadu-Scanner: scn1.migadu.com X-TUID: oB+fwZl/D0Jp Hello, Pressing C-c C-c in a code block asks the user whether to execute that code block or not. This soon becomes annoying. To remedy this, org-mode provides us the variable org-confirm-babel-evaluate. But this is not very user friendly. Additionally, as per documentation, this variable only controls whether org-mode (babel? Forgive me, I am sort of a new user of Emacs) will execute the code block without asking, or ask. What I would like to have, to safely and easily use org-mode as an interactive notebook, is to not have to overload this function and to be asked only once per buffer/file whether to: 1) Unconditionally allow executing all code blocks 2) Unconditionally disallow executing all code blocks 3) Ask for every block. Particularly the second case is the one that cannot be supported by simply defining org-confirm-babel-evaluate. This is what I cooked up as a solution, with help and advice from Ian Eure: #+BEGIN_SRC elisp (defvar-local org-babel-code-execute-mode nil) (defun org-babel-check-confirm-evaluate-wrapper (orig-fun &rest args) (pcase org-babel-code-execute-mode ("always" t) ("never" nil) ("query" (apply orig-fun args)) (- (progn (setq org-babel-code-execute-mode (completing-read ; can also return "" "Allow execution of code blocks in this buffer (always, never,= query)?" '(always never query) nil ; predicate t ; require match to one of the three options ) ) (apply orig-fun args) ) ) ) ) (advice-add 'org-babel-check-confirm-evaluate :around #'org-babel-check-con= firm-evaluate-wrapper) #+END_SRC I would like this functionality to become part of org-mode in the future. Sincerely, Fedja