From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id 6M+ONoTzml+gcAAA0tVLHw (envelope-from ) for ; Thu, 29 Oct 2020 16:53:24 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id 4FxtMoTzml/aMwAA1q6Kng (envelope-from ) for ; Thu, 29 Oct 2020 16:53:24 +0000 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 5E170940393 for ; Thu, 29 Oct 2020 16:53:24 +0000 (UTC) Received: from localhost ([::1]:55634 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kYBAv-0007A4-GZ for larch@yhetil.org; Thu, 29 Oct 2020 12:53:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59158) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kYBAG-00077l-Ft for emacs-orgmode@gnu.org; Thu, 29 Oct 2020 12:52:40 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]:43562) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kYBAD-0008Rm-AG for emacs-orgmode@gnu.org; Thu, 29 Oct 2020 12:52:40 -0400 Received: by mail-wr1-x429.google.com with SMTP id g12so3515573wrp.10 for ; Thu, 29 Oct 2020 09:52:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=M+9Ykt9Ur/+K4mDqQoC7PeDH/7w2XPf4yt+WrZWq044=; b=OkVvqhY1yHtHh+U8M9wVNQdUCEfUr+tq2aEwhbXyCwxISuDHMmqG+nBaB1b3d/gibs X78gsFHLg74ymc028sdDNrpYRC1Il/bH7p9sOO6OLSKvPb82SPROALkaDXvFzU5WSDhK pkTNk3qNQDEDnKosb/pMUibDZZshhXyj22LofSrgjwtvARbd/qWxpYUBgsd2nhPnYynr qw19//JaQAKsXdQNCCanNuYh6UJ1rYfYiMb9L4YtuTEIeWMI3NdYQuiuugA2gezPU1jj NTFmUkJCj4g0g8WKs830rf4e7nPmVB4y4XLms38FKVC/naOrZmRfGb/sZks7AB0FClEL jJ0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=M+9Ykt9Ur/+K4mDqQoC7PeDH/7w2XPf4yt+WrZWq044=; b=o53gIth3GN7tA752lm3g1pl68w2fRbSBflfmaatd7FoXkJ3C22bUJVyx0CQkwg9Fwf ltj3gRwDrlFl1p40xbGlR+DggJ7D4o3QOuL7/yac+jwePR52u7FvdF0PP6a0KykIdjNA nTUocSrAKAYP0tLeonZ1KF6uN0kO0Hbd7q84HR7dXF2EE0tG6m4rpNJsv+HboErrt8fY Rvwhm4MiLLkE/6pfFuRi4d5lJBnT8DGfS1ENFN8a2fbclDPpI9+MQvX/jFvjshL2cSG9 3vBQSnpQ5Gdi7TUTbFRnZJX2bPN8EdsHJlh6aacxebSKC1i22yt1g/VTU90Wz+Sqm3A6 uNEA== X-Gm-Message-State: AOAM532Yy3fNS3ajYZ2co64rfHeaYGFEtyNfZx1tmOGkOawtOUFXj+8+ piDcJa96NWzfWQHBDyL+JTx/brSxjSSQnZnPyeg= X-Google-Smtp-Source: ABdhPJwM9ffVWBX4bPy/uqt9fGnTbCUYSLoLj84WViyT31i+YdLZYRBDEXpUTRcwKEz4LQv85gAQt/j6P31Uzjns7/I= X-Received: by 2002:adf:deca:: with SMTP id i10mr6996458wrn.96.1603990352894; Thu, 29 Oct 2020 09:52:32 -0700 (PDT) MIME-Version: 1.0 References: <50a71862-dbde-41c1-aab8-b7570d9c5d3c@www.fastmail.com> In-Reply-To: <50a71862-dbde-41c1-aab8-b7570d9c5d3c@www.fastmail.com> From: Tom Gillespie Date: Thu, 29 Oct 2020 12:52:21 -0400 Message-ID: Subject: Re: Is reading nested simple lists into org-babel code blocks currently supported? To: James Boyle Content-Type: text/plain; charset="UTF-8" Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=tgbugs@gmail.com; helo=mail-wr1-x429.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: emacs-orgmode Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=OkVvqhY1; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Spam-Score: -0.71 X-TUID: PoV3PzAIM8ti Hi James, I would file this along with other ob-lang dependent features such as TRAMP remote execution support. For example, python works as in your other examples, but only if you define :var unordered="unordered" as another variable before the variable you pass the plain list to because python tries to dereference the symbol. A global solution like the one you propose breaks the semantics in cases where a language does correctly deal with quoted lists (e.g. common lisp). As a result each ob-lang will probably have to deal with this itself, or at least they will have to define how to consume quoted elisp lists without raising errors. That said, I'm not sure that org babel requires that ob-lang implementations handle this. Maybe it should? I've added this to my growing list of issues related to org babel regularization. Best! Tom On Thu, Oct 29, 2020 at 7:25 AM James Boyle wrote: > > Hi all, > > Since this is a bit of a long post, I've put my questions and summary > comment at the top, with the detailed context below. > > 1. What is the level of support for reading nested simple lists into > org-babel code blocks? > 2. When the manual (see link below) says that they are not supported, > is it known if it meant "not at all supported," or, that support is > currently language-dependent? > 3. Directionally, does the org-mode project care to support nested > simple lists? > > I'm happy to submit patches for both code and manual in any event, but > wanted to align on if there are goals for supporting reading nested > lists, and if so, at what level. > > At a minimum, I think updating the manual to be more precise would be > great. > > Thanks for your any assistance you can provide. > > Details: > > I was going through the manual on this page: > > https://orgmode.org/manual/Environment-of-a-Code-Block.html#Environment-of-a-Code-Block > > and testing out the example, "A simple named list." > > Contrary to this line in the manual: > > > Note that only the top level list items are passed along. Nested list items are ignored. > > It looks like the example org-babel block *does* work for nested > lists, depending upon the language. I am using org-mode 9.4. > > Here is the org block verbatim from the manual, with the > results that are supposed to occur: > > #+NAME: example-list > - simple > - not > - nested > - list > > #+BEGIN_SRC emacs-lisp :var x=example-list > (print x) > #+END_SRC > > #+RESULTS: > | simple | list | > > > And here is the same block, when I evaluate it locally, with the > actual results, showing that unordered, nested lists are not ignored. > > #+NAME: example-list > - simple > - not > - nested > - list > > #+BEGIN_SRC emacs-lisp :var x=example-list > (print x) > #+END_SRC > > #+RESULTS: > | simple | (unordered (not) (nested)) | > | list | | > > > I thought this was a nice surprise, until I noticed that whether or > not it works is language-dependent. > > In ruby, I get an error: > > #+begin_src ruby :var x=example-list > # This is the error I get: > > # `main': undefined local variable or method `unordered' for > # main:Object (NameError) > puts x > #+end_src > > #+RESULTS: > > And here is the equivalent error in js. Presumably other languages > have variable support for this feature. > > #+begin_src js :var x=example-list > // Below is a partial error trace: > > // /private/var/folders/mc/jylgk04j5r1f96hcsd3ywm8h0000gn/T/babel-shSmEq/js-script-xzngmd:2 > // var x=[["simple", [unordered, ["not"], ["nested"]]], ["list"]]; ^ > // ReferenceError: unordered is not defined > return x > #+end_src > > #+RESULTS: > > The error can be trivially "fixed" by some code like this, or making > the equivalent change in the actual source line to output a string > rather than a symbol. Changing L#2365 linked below to use "unordered" > (string) rather than 'unordered (symbol) seemed to fix it, and > produced no new test failures for me. > > #+begin_src emacs-lisp > ; See this line for where 'unordered is being spat out: > ; https://code.orgmode.org/bzg/org-mode/src/master/lisp/ob-core.el#L2365 > (defun patch-get-vars-output (vars) > "Substitute special Lisp symbols with a Lisp keyword. > This allows Ruby to not barf on an undefined variable error > for certain input structures like nested lists. > Argument VARS is a tree structure. See above example format." > (subst "unordered" 'unordered vars)) > > (advice-add 'org-babel--get-vars :filter-return #'patch-get-vars-output) > #+end_src > > Thanks again for any help or direction you can provide. > > James Boyle >