From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id 6Nh5GikD+WNBTQEAbAwnHQ (envelope-from ) for ; Fri, 24 Feb 2023 19:34:17 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id 6H6IGikD+WNUAAEA9RJhRA (envelope-from ) for ; Fri, 24 Feb 2023 19:34:17 +0100 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 2C3D722F6C for ; Fri, 24 Feb 2023 19:34:17 +0100 (CET) Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=jydRmse7; 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"; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=key1; d=yhetil.org; t=1677263657; a=rsa-sha256; cv=none; b=nmj+g8mk+128IPaUmF2V5v46G4Jrljh8UcSP7M26Pv76DNqLggosxr2G9pBS1tkD2IHLfS +kEpJ2gBsgDu0TyYouGQEz9/6YsrkyTqi8tEI7oGTrXpnDgXCEhjkARj+7M1thOzQGdAou t2SNw7Sk5RRzYpJIBX2b/cT/m/ArpkSA7QLGLdEFVkoIhUZYgueI2y+d1a2O0fP03Mnz3w 2M4d4Yso2wfR9PcaBUfszm/SZyD4cv5/+ef3U0oEyweN18BsXHDTEWkhlxRMHJAsTZh6p2 k5aNYWEIZ6yToZbdqgBZJeHprKTAe82p0SpyBpTORTCExeXNccDJaB37q4L/CA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=jydRmse7; 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"; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1677263657; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=/flshKMw61r4uHrZBPQQSEtRuQr6G3zNwGPBzFuXAE0=; b=smBzVs0IBz6CqyjyEZoMVe+0+18sLfHVGlJg/aE7HFjAGFvgaWHhyq6RleG3UOuyD2lvVM 8Kzn7lhbE456p8yRqdOoOhN5ufmFF2H14c4m/Il2LFXmAu7LFNWFBwX3dy+yuXQ0qxl0RE zqJa8ozCaT8H4cy3BD8M+7W8cNHrRbxBq27M1vC5Tp2+7CmK/+/0iYr1v6Su4sjpY32hIk tb/qpuZklwmod01Lz7rvhRPMyW7LtNa/nr2aIe1QLlDYphkAzb3Sup7ZgRp08JyWRsJrsz EG4ENhcYMAiuevB6BlRJbsZ/PwYFNE4oeJoZDTQFnxAl3/Pj8sKEzWNwUZE1mw== Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pVcsx-0001Wt-FA; Fri, 24 Feb 2023 13:33:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVcsu-0001Wj-W5 for emacs-orgmode@gnu.org; Fri, 24 Feb 2023 13:33:33 -0500 Received: from mail-lf1-x12c.google.com ([2a00:1450:4864:20::12c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pVcst-00007d-1r for emacs-orgmode@gnu.org; Fri, 24 Feb 2023 13:33:32 -0500 Received: by mail-lf1-x12c.google.com with SMTP id n2so244554lfb.12 for ; Fri, 24 Feb 2023 10:33:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:message-id:date:in-reply-to:subject:to:from:user-agent :references:from:to:cc:subject:date:message-id:reply-to; bh=/flshKMw61r4uHrZBPQQSEtRuQr6G3zNwGPBzFuXAE0=; b=jydRmse70MnFWpZ8ianQeSRBk1kTA+B93aRSuNVpo9OVGuMRUTi0ZMf8NxZ9JIJKl3 NN7zlGqvZ8UvDP1CUMfZVUYgwiM4RCOrWwK+bowCDKJnhZrOU+MiFYRAo1j7jamrbCA+ rMV4aLsDsBUpGVtu6yoZ9YGwUkgb6jyvI+U/siaVuJLBQ9Hs5qNuZs9rFGXI82+c/dkm 5Ew95lxifySC2y2z0UiSgkh6z+sAmjH6QCJDZeIEZU8Zz8WvITwPzpRtRvojFXI317gi K+Ejm1I0knyJvoYo30PjQqGvYivetHSFgD1aK+jDTLt4eCYuNf/VNMF1ZCRQybEijkCX i6rA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:date:in-reply-to:subject:to:from:user-agent :references:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=/flshKMw61r4uHrZBPQQSEtRuQr6G3zNwGPBzFuXAE0=; b=snVfPXyGSRoddxYryHsAHIr64OrhUvTAqF9F90gOx6v+XRyodVhe5Gz6vTx822M6zs i6HPuJDjwF9kqgu7zybDG96KHdVsDy8qsVS7pDJwjsDavat5uCGy5yNXKoXcIUH0dvNc 66rts8VqfCGarm4UgKtW7Kmu31x8Xh7HnT0jaSrMTB5FIwLlAn4UtRC84NNFS8/Zmwqg G/rIfcCNZ/YKjywVOOJ2LM1bvlOOqBJs/jJfv0VCIyyI6/UsxSE21Q4DilfzJtxiXY5W kVCGBcLT1VSSDo60apWlaBpyOC4+gQP2yLz+Y9sdqZpoxilmftfVRnOY3FGGML8QwEmj yVlw== X-Gm-Message-State: AO0yUKVALnwyRbPlNXs1pPn+8egRXm8X751E8FU0YXxTsEw/z4vPB6BT nS2Ck80m1qtOpqUHtehbwYUr0xFvetbQQAwk X-Google-Smtp-Source: AK7set9AuV5S4eBHzT98ZA/w3JAgfuUgpNDCSBYOg1+K3Cfp47Kp6TbhHR+9KQN/F9t2dmqJVfw6og== X-Received: by 2002:ac2:51c6:0:b0:4db:3e39:e8e2 with SMTP id u6-20020ac251c6000000b004db3e39e8e2mr5732347lfm.68.1677263608805; Fri, 24 Feb 2023 10:33:28 -0800 (PST) Received: from t480 ([152.115.35.237]) by smtp.gmail.com with ESMTPSA id l14-20020ac2554e000000b004d858fa34ebsm1187110lfk.112.2023.02.24.10.33.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Feb 2023 10:33:28 -0800 (PST) References: <87pm9z8089.fsf@t480.home> User-agent: mu4e 1.8.13; emacs 27.1 From: Ken Mankoff To: Org-mode Subject: Re: [PATCH] lisp/ob-screen.el: Support ~:var~ header args for babel blocks In-reply-to: <87pm9z8089.fsf@t480.home> Date: Fri, 24 Feb 2023 10:33:24 -0800 Message-ID: <87y1om7w23.fsf@t480.home> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2a00:1450:4864:20::12c; envelope-from=mankoff@gmail.com; helo=mail-lf1-x12c.google.com 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: X-Migadu-Queue-Id: 2C3D722F6C X-Spam-Score: -6.70 X-Migadu-Spam-Score: -6.70 X-Migadu-Scanner: scn0.migadu.com List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-TUID: CIJ1Zdd9GaYt --=-=-= Content-Type: text/plain I realize the patch should be an attachment, not the body of the email. Sorry. R-sending as attachment. -k. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-lisp-ob-screen.el-Support-var-header-args-for-babel-.patch >From 5a4707cc16fb5f10cd394762f41d50d8830db240 Mon Sep 17 00:00:00 2001 From: "Kenneth D. Mankoff" Date: Mon, 20 Feb 2023 21:40:39 -0800 Subject: [PATCH] lisp/ob-screen.el: Support ~:var~ header args for babel blocks * ob-screen.el: (org-babel-execute:screen): Parse header params for `:var', then inject into screen session. (org-babel-variable-assignments:screen): Copied from ob-shell.el org-babel-variable-assignments:shell * etc/ORG-NEWS: Document as New Feature This change only supports single-value variables (e.g., ~:var x=42~), not tables or arrays as is currently supported by some other languages. --- etc/ORG-NEWS | 13 +++++++++++++ lisp/ob-screen.el | 21 +++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 87ecd77cd..d4b454d13 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -106,6 +106,19 @@ selection. TODO state, priority, tags, statistics cookies, and COMMENT keywords are allowed in the tree structure. +*** ob-screen now supports :var header arguments + +The ~:var~ header arg now supports simple single-value variables +(arrays and tables are not supported). + +#+BEGIN_src org +,#+BEGIN_SRC screen :var x=42 +,echo $x +,#+END_SRC +#+END_src + + + * Version 9.6 ** Important announcements and breaking changes diff --git a/lisp/ob-screen.el b/lisp/ob-screen.el index 269538e79..d8f361e50 100644 --- a/lisp/ob-screen.el +++ b/lisp/ob-screen.el @@ -55,11 +55,32 @@ In case you want to use a different screen than one selected by your $PATH") (message "Sending source code block to interactive terminal session...") (save-window-excursion (let* ((session (cdr (assq :session params))) + (var-lines (org-babel-variable-assignments:screen params)) (socket (org-babel-screen-session-socketname session))) (unless socket (org-babel-prep-session:screen session params)) + (mapcar (lambda (var) + (org-babel-screen-session-execute-string session var)) + var-lines) (org-babel-screen-session-execute-string session (org-babel-expand-body:generic body params))))) +(defun org-babel-variable-assignments:screen (params) + "Return list of shell statements assigning the block's variables." + ;; From ob-shell but change function name from ":shell" to ":screen" + (let ((sep (cdr (assq :separator params))) + (hline (when (string= "yes" (cdr (assq :hlines params))) + (or (cdr (assq :hline-string params)) + "hline")))) + (mapcar + (lambda (pair) + (if (string-suffix-p "bash" shell-file-name) + (org-babel--variable-assignments:bash + (car pair) (cdr pair) sep hline) + (org-babel--variable-assignments:sh-generic + (car pair) (cdr pair) sep hline))) + (org-babel--get-vars params)))) + + (defun org-babel-prep-session:screen (_session params) "Prepare SESSION according to the header arguments specified in PARAMS." (let* ((session (cdr (assq :session params))) -- 2.34.1 --=-=-=--