emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ken Mankoff <mankoff@gmail.com>
To: Max Nikulin <manikulin@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: [PATCH] lisp/ob-screen.el: Support ~:var~ header args for babel blocks
Date: Sat, 25 Feb 2023 07:14:52 -0800	[thread overview]
Message-ID: <877cw5aiab.fsf@t480.home> (raw)
In-Reply-To: <96a91a35-eeb6-55d3-683d-5d51ff6d496e@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 705 bytes --]

Hi Max,

On 2023-02-24 at 19:51 -08, Max Nikulin <manikulin@gmail.com> wrote:
> On 25/02/2023 01:33, Ken Mankoff wrote:
> I am unsure if Org markup is suitable for commit messages (~:var~)
> since it may appear in Emacs commit logs.

Fixed.

> The code still depends on on ob-shell. Is there a reason why calling
> `org-babel-variable-assignments:shell' is a worse variant than copy of
> the whole function body?

I didn't realize that was a dependency. I now use that function. This also means that arrays/tables/etc. are all supported by :var, although not in the default screen ":cmd sh" because sh doesn't support "declare", but it works with ":cmd bash".

Improved patch attached.

Thanks,

  -k.




[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-lisp-ob-screen.el-Support-var-header-args-for-babel-.patch --]
[-- Type: text/x-diff, Size: 1834 bytes --]

From 580499925644cdb9c2dd8c783ec03c095bec7a86 Mon Sep 17 00:00:00 2001
From: "Kenneth D. Mankoff" <mankoff@gmail.com>
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.

* etc/ORG-NEWS: Document as New Feature
---
 etc/ORG-NEWS      | 12 ++++++++++++
 lisp/ob-screen.el |  4 ++++
 2 files changed, 16 insertions(+)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 87ecd77cd..0da686354 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -106,6 +106,18 @@ 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 is now 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..bd8650f6b 100644
--- a/lisp/ob-screen.el
+++ b/lisp/ob-screen.el
@@ -55,8 +55,12 @@ 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:shell 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)))))
 
-- 
2.34.1


  reply	other threads:[~2023-02-25 15:15 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-24 17:03 [PATCH] lisp/ob-screen.el: Support ~:var~ header args for babel blocks Ken Mankoff
2023-02-24 18:33 ` Ken Mankoff
2023-02-25  3:51   ` Max Nikulin
2023-02-25 15:14     ` Ken Mankoff [this message]
2023-02-25 15:19       ` Ken Mankoff
2023-02-25 16:05       ` Max Nikulin
2023-02-25 16:47         ` Ken Mankoff
2023-02-26 10:11           ` Max Nikulin
2023-02-27  1:59             ` Ken Mankoff
2023-02-28 10:40               ` Ihor Radchenko
2023-03-16  4:12                 ` Ken Mankoff
2023-03-16 10:22                   ` Ihor Radchenko
2023-03-16 15:09                     ` [PATCH v4] " Max Nikulin
2023-03-17 11:41                       ` Max Nikulin
2023-03-18 12:08                       ` Ihor Radchenko
2023-03-19 14:42                       ` Ken Mankoff
2023-03-21 14:12                         ` Max Nikulin
2023-03-02 13:38               ` [PATCH] " Max Nikulin
2023-02-26 12:18           ` Ihor Radchenko
2023-02-27  1:59             ` Ken Mankoff
2023-02-27 19:43               ` Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877cw5aiab.fsf@t480.home \
    --to=mankoff@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=manikulin@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).