From mboxrd@z Thu Jan 1 00:00:00 1970 From: edgar@openmail.cc Subject: org-babel noweb-ref Date: Sun, 29 Sep 2019 14:31:12 +0000 Message-ID: <96082171e6671d6c57fb729eef5009c0@openmail.cc> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:40326) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iEaEe-0002xL-Tt for emacs-orgmode@gnu.org; Sun, 29 Sep 2019 10:31:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iEaEa-00046G-Ts for emacs-orgmode@gnu.org; Sun, 29 Sep 2019 10:31:40 -0400 Received: from nl101-2.vfemail.net ([149.210.219.31]:32749 helo=freequeue.vfemail.net) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1iEaEa-0003z9-8D for emacs-orgmode@gnu.org; Sun, 29 Sep 2019 10:31:36 -0400 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 Hello dear list, First of all, this may be related: - https://lists.gnu.org/archive/html/emacs-orgmode/2018-02/msg00300.html - https://lists.gnu.org/archive/html/emacs-orgmode/2012-01/msg00044.html - Emacs: src_emacs-lisp{emacs-version} {{{results(=26.3=)}}} - Org: src_emacs-lisp{org-version} {{{results(=9.1.14=)}}} - Parabola GNU/Linux: src_bash{uname -r} {{{results(=5.2.5-gnu-1=)}}} I prepared the following hoping that it makes the issue clear. Let me know :) . #+CAPTION: This works if ~org-babel-use-quick-and-dirty-noweb-expansion~ is ~nil~, but I don't want to import everything from ~libraries~ #+BEGIN_SRC python :tangle routines1.py :noweb yes :shebang # -*- coding: utf-8 -*- <> <> #+END_SRC * Explanation with example - I noticed some differences between the output of tangling and previewing org-babel blocks. - ~org-babel-use-quick-and-dirty-noweb-expansion~ interferes with ~:noweb~ in a way that I did not expect I want to know 1. if this is the expected behaviour 2. how I can expand a named block (which has ~#+name: tag~) which is inside a subtree (subheading with the ~:noweb-ref~ property) ** Option 1 Set src_emacs-lisp{(setq org-babel-use-quick-and-dirty-noweb-expansion nil)} #+BEGIN_SRC python :tangle /tmp/routines1.py :noweb yes :shebang # -*- coding: utf-8 -*- <> <> #+END_SRC - Preview shows empty lines instead of ~imp1.py~ and no ~shebang~ #+BEGIN_SRC python def fun1(): pass def fun2(): pass #+END_SRC - Tangled ~/tmp/routines2.py~ shows ~shebang~, but no ~imp1.py~. #+BEGIN_SRC python # -*- coding: utf-8 -*- def fun1(): pass def fun2(): pass #+END_SRC *** What I expected 1. Both Preview and tangling to have the same content 2. for ~imp1.py~ to be expanded at the top of the code as ~import numpy as np~. ** Option 2 src_emacs-lisp{(setq org-babel-use-quick-and-dirty-noweb-expansion t)} #+BEGIN_SRC python :tangle /tmp/routines2.py :noweb yes :shebang # -*- coding: utf-8 -*- <> <> #+END_SRC - Preview shows #+BEGIN_SRC python import numpy as np #+END_SRC - Tangled ~/tmp/routines2.py~ shows #+BEGIN_SRC python # -*- coding: utf-8 -*- import numpy as np #+END_SRC *** What I expected According to the manual, ~<>~ would not be solved correctly (as shown), but I expected to have the ~shebang~ in the preview. A further comment can be made about the extra space (related to ~:noweb-sep~), but that is minor and I don't care. ** Routines :PROPERTIES: :header-args: :noweb-ref routines :noweb-sep "\n\n\n" :END: #+NAME: fun1.py #+BEGIN_SRC python def fun1(): pass #+END_SRC #+NAME: fun2.py #+BEGIN_SRC python def fun2(): pass #+END_SRC ** Libraries :PROPERTIES: :header-args: :noweb-ref libraries :END: #+NAME: imp1.py #+BEGIN_SRC python import numpy as np #+END_SRC #+NAME: imp2.py #+BEGIN_SRC python import os #+END_SRC ------------------------------------------------- This free account was provided by VFEmail.net - report spam to abuse@vfemail.net ONLY AT VFEmail! - Use our Metadata Mitigator to keep your email out of the NSA's hands! $24.95 ONETIME Lifetime accounts with Privacy Features! 15GB disk! No bandwidth quotas! Commercial and Bulk Mail Options!