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 ab...@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!