From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rasmus Subject: Re: [BUG] Noweb reference eval syntax does not work Date: Sun, 08 May 2016 14:57:29 +0200 Message-ID: <87futs3dxi.fsf@gmx.us> References: <87h9ec2ngz.fsf@fm4d.net> <87shxsaojc.fsf@saiph.selenimh> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:49230) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1azOHF-0006Qt-H4 for emacs-orgmode@gnu.org; Sun, 08 May 2016 08:57:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1azOHB-0002cK-73 for emacs-orgmode@gnu.org; Sun, 08 May 2016 08:57:40 -0400 Received: from plane.gmane.org ([80.91.229.3]:50570) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1azOHA-0002cD-T5 for emacs-orgmode@gnu.org; Sun, 08 May 2016 08:57:37 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1azOH8-0003W1-Su for emacs-orgmode@gnu.org; Sun, 08 May 2016 14:57:34 +0200 Received: from ip-178-203-232-226.hsi10.unitymediagroup.de ([178.203.232.226]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 08 May 2016 14:57:34 +0200 Received: from rasmus by ip-178-203-232-226.hsi10.unitymediagroup.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 08 May 2016 14:57:34 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org Cc: aaronecay@gmail.com Hi, Nicolas Goaziou writes: > fm4d writes: > >> The noweb reference syntax that should insert results of >> evaluation of src block itself instead of src block as >> described in `org-babel-expand-noweb-reference` does not >> seems to work. >> >> >> Code for replication: >> >> * Assign >> >> First we assign abc: >> >> #+begin_src python :noweb-ref assign_abc >> abc = "abc" + "def" >> #+end_src >> >> * Use >> >> Then we use it in a function: >> >> #+begin_src python :noweb tangle :tangle noweb-test.py >> def x(): >> <> >> return abc >> >> print(x()) >> #+end_src >> >> >> <> does work, fails with this error: >> >> (error "Reference ‘assign_abc’ not found in this buffer") >> signal(error ("Reference ‘assign_abc’ not found in this buffer")) >> error("Reference `%s' not found in this buffer" "assign_abc") >> org-babel-ref-resolve("assign_abc()") >> ... >> >> >> I am not sure if this is a bug or I am doing something wrong, >> the documentation on this feature is not very comprehensive. > > I just discovered the :noweb-ref parameter. I have used :noweb yes in the past, but it seems :noweb-ref can be replaced by name in at least the single blog case: #+name: data #+BEGIN_SRC R set.seed(42) df1 <- data.frame(x=rnorm(10), y=rnorm(10)) #+END_SRC #+BEGIN_SRC R :noweb yes <> colMeans(df1) #+END_SRC As you mention, we’d loose the ability to chain together multiple blocks. I reckon they are meaningfully the same language, so I don’t see a loss. The example shown in the manual also does not convince me of the usefullness of this. > It is redundant with #+NAME: keyword and slightly broken. Also it > induces hacks like `org-babel-use-quick-and-dirty-noweb-expansion' to > work-around its shortcomings. > > Besides, it doesn't make much sense to add the same parameters to > a bunch of blocks, so I find the syntax dubious. > > I understand it can be a handy shortcut for inserting multiple blocks, > but, all in all, I tend to think it would be simpler to just remove the > feature, along with `:noweb-sep' and > `org-babel-use-quick-and-dirty-noweb-expansion'. I’m happy to kill it off in Org-9. I don’t know how widely the chaining of blocks is used, though, and whether the fix is always as simple as uniting the blocks. > What do you, and others, think? Is NAME enough for noweb syntax, or is > there a real need fo :noweb-ref? I've put Aaron in carbon copy as he’s quite familiar with ob. Rasmus -- Governments should be afraid of their people