emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: edgar@openmail.cc
To: emacs-orgmode@gnu.org
Subject: org-babel noweb-ref
Date: Sun, 29 Sep 2019 14:31:12 +0000	[thread overview]
Message-ID: <96082171e6671d6c57fb729eef5009c0@openmail.cc> (raw)

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 -*-
   <<libraries>>


   <<routines>>
#+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 -*-
   <<imp1.py>>


   <<routines>>
#+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 -*-
   <<imp1.py>>


   <<routines>>
#+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, ~<<routines>>~ 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!  

                 reply	other threads:[~2019-09-29 14:31 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=96082171e6671d6c57fb729eef5009c0@openmail.cc \
    --to=edgar@openmail.cc \
    --cc=emacs-orgmode@gnu.org \
    /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).