Subject: 26.3; Noweb cannot execute imported file inside buffer but works fine during export

From: Sarthak Adhikari <[email-masked]>
Date: Thu, 6 Aug 2020 12:57:26 +0545

I cannot use :noweb according to the documentation inside org-mode.
I get the error: "Reference 'function_name' not found in this buffer."

Steps to reproduce:
1) Start emacs with 'emacs -Q'.
2) Create the two files code.inc, and test.org

Inside code.inc:
# -*- mode: org; -*-
#+NAME: hello
#+BEGIN_SRC python :results output :exports results
print('Hello world!', end='')
#+END_SRC

Inside test.org:
#+NAME: printhello
#+INCLUDE: code.inc
#+BEGIN_SRC shell :noweb yes :results output
echo -n <<hello()>>
#+END_SRC

3) Load the following expression:
M-x: eval-expression:
(org-babel-do-load-languages
   'org-babel-load-languages
   `((python . t)))

4) Try to execute the printhello block with C-c

After Step 4) I get "Reference 'hello' not found in this buffer."
However, If I export the test.org to HTML, the text "Hello world!" is
displayed in the HTML page.
So, it is working, but not inside the buffer.

In GNU Emacs 26.3 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.14)
 of 2020-03-26, modified by Debian built on lcy01-amd64-020
Windowing system distributor 'The X.Org Foundation', version 11.0.12008000
System Description: Ubuntu 20.04.1 LTS

Recent messages:
org-babel-exp process shell at position 1275...
org-babel-exp process shell at position 1522...
Please answer yes or no.
org-babel-execute-src-block: No org-babel-execute function for python!
org-babel-ref-resolve: Reference ‘hello’ not found in this buffer
Auto-saving...
org-babel-ref-resolve: Reference ‘hello’ not found in this buffer
scroll-up-command: End of buffer [4 times]
Quit
delete-backward-char: Text is read-only [2 times]

Configured using:
 'configure --build x86_64-linux-gnu --prefix=/usr
 --sharedstatedir=/var/lib --libexecdir=/usr/lib
 --localstatedir=/var/lib --infodir=/usr/share/info
 --mandir=/usr/share/man --enable-libsystemd --with-pop=yes
 --enable-locallisppath=/etc/emacs:/usr/local/share/emacs/26.3/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/26.3/site-lisp:/usr/share/emacs/site-lisp
 --with-sound=alsa --without-gconf --with-mailutils --build
 x86_64-linux-gnu --prefix=/usr --sharedstatedir=/var/lib
 --libexecdir=/usr/lib --localstatedir=/var/lib
 --infodir=/usr/share/info --mandir=/usr/share/man --enable-libsystemd
 --with-pop=yes
 --enable-locallisppath=/etc/emacs:/usr/local/share/emacs/26.3/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/26.3/site-lisp:/usr/share/emacs/site-lisp
 --with-sound=alsa --without-gconf --with-mailutils --with-x=yes
 --with-x-toolkit=gtk3 --with-toolkit-scroll-bars 'CFLAGS=-g -O2
 -fdebug-prefix-map=/build/emacs-mEZBk7/emacs-26.3+1=.
-fstack-protector-strong
 -Wformat -Werror=format-security -Wall' 'CPPFLAGS=-Wdate-time
 -D_FORTIFY_SOURCE=2' 'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro''

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS GLIB
NOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM THREADS LIBSYSTEMD LCMS2

Important settings:
  value of $LC_MONETARY: ne_NP.UTF-8
  value of $LC_NUMERIC: ne_NP.UTF-8
  value of $LC_TIME: ne_NP.UTF-8
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: Org

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug sendmail org-id cl-extra help-mode
org-agenda ox-odt rng-loc rng-uri rng-parse rng-match rng-dt rng-util
rng-pttrn nxml-parse nxml-ns nxml-enc xmltok nxml-util ox-latex
ox-icalendar ox-html table ox-ascii ox-publish ox sh-script smie
executable ffap thingatpt url-parse auth-source eieio eieio-core cl-macs
eieio-loaddefs url-vars org-rmail org-mhe org-irc org-info org-gnus nnir
gnus-sum gnus-group gnus-undo gnus-start gnus-cloud nnimap nnmail
mail-source tls gnutls utf7 netrc nnoo parse-time gnus-spec gnus-int
gnus-range message rmc puny seq byte-opt gv bytecomp byte-compile cconv
rfc822 mml mml-sec password-cache epa derived epg epg-config mm-decode
mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader
gnus-win gnus nnheader gnus-util rmail rmail-loaddefs rfc2047 rfc2045
ietf-drums mail-utils mm-util mail-prsvr wid-edit org-docview doc-view
jka-compr image-mode org-bibtex bibtex org-bbdb org-w3m org-element
cl-seq avl-tree generator org advice org-macro org-footnote
org-pcomplete pcomplete org-list org-faces org-entities noutline outline
easy-mmode org-version ob-emacs-lisp ob ob-tangle org-src ob-ref ob-lob
ob-table ob-keys ob-exp ob-comint comint ansi-color ring ob-core ob-eval
org-compat org-macs org-loaddefs format-spec find-func cal-menu easymenu
calendar cal-loaddefs cl-loaddefs cl-lib dired dired-loaddefs elec-pair
time-date mule-util tooltip eldoc electric uniquify ediff-hook vc-hooks
lisp-float-type mwheel term/x-win x-win term/common-win x-dnd tool-bar
dnd fontset image regexp-opt fringe tabulated-list replace newcomment
text-mode elisp-mode lisp-mode prog-mode register page menu-bar
rfn-eshadow isearch timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core term/tty-colors frame cl-generic cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese composite charscript charprop
case-table epa-hook jka-cmpr-hook help simple abbrev obarray minibuffer
cl-preloaded nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote threads dbusbind
inotify lcms2 dynamic-setting system-font-setting font-render-setting
move-toolbar gtk x-toolkit x multi-tty make-network-process emacs)

Memory information:
((conses 16 233731 22894)
 (symbols 48 34810 2)
 (miscs 40 115 272)
 (strings 32 79532 3424)
 (string-bytes 1 2516276)
 (vectors 16 32203)
 (vector-slots 8 696374 25266)
 (floats 8 216 298)
 (intervals 56 600 38)
 (buffers 992 14))
Emacs  : GNU Emacs 26.3 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.14)
 of 2020-03-26, modified by Debian
Package: CC Mode 5.33.2 (Org)
Buffer Style: nil
c-emacs-features: (pps-extended-state col-0-paren posix-char-classes
gen-string-delim gen-comment-delim syntax-properties 1-bit)

current state:
==============
(setq
 c-basic-offset 'set-from-style
 c-comment-only-line-offset 'set-from-style
 c-indent-comment-alist 'set-from-style
 c-indent-comments-syntactically-p 'set-from-style
 c-block-comment-prefix "* "
 c-comment-prefix-regexp "//+\\|\\**"
 c-doc-comment-style 'set-from-style
 c-cleanup-list 'set-from-style
 c-hanging-braces-alist 'set-from-style
 c-hanging-colons-alist 'set-from-style
 c-hanging-semi&comma-criteria 'set-from-style
 c-backslash-column 'set-from-style
 c-backslash-max-column 'set-from-style
 c-special-indent-hook nil
 c-label-minimum-indentation 'set-from-style
 c-offsets-alist nil
 c-buffer-is-cc-mode nil
 c-tab-always-indent t
 c-syntactic-indentation t
 c-syntactic-indentation-in-macros t
 c-ignore-auto-fill '(string cpp code)
 c-auto-align-backslashes t
 c-backspace-function 'backward-delete-char-untabify
 c-delete-function 'delete-char
 c-electric-pound-behavior nil
 c-default-style '((java-mode . "java") (awk-mode . "awk") (other . "gnu"))
 c-enable-xemacs-performance-kludge-p nil
 c-old-style-variable-behavior nil
 defun-prompt-regexp nil
 tab-width 8
 comment-column 32
 parse-sexp-ignore-comments nil
 parse-sexp-lookup-properties nil
 auto-fill-function nil
 comment-multi-line nil
 comment-start-skip "^\\s-*#\\(?: \\|$\\)"
 fill-prefix nil
 fill-column 70
 paragraph-start "\\(?:\\*+ \\|\\[fn:[-_[:word:]]+\\]\\|%%(\\|[
]*\\(?:$\\||\\|\\+\\(?:-+\\+\\)+[       ]*$\\|#\\(?:
\\|$\\|\\+\\(?:BEGIN_\\S-+\\|\\S-+\\(?:\\[.*\\]\\)?:[
 ]*\\)\\)\\|:\\(?: \\|$\\|[-_[:word:]]+:[        ]*$\\)\\|-\\{5,\\}[
]*$\\|\\\\begin{\\([A-Za-z0-9*]+\\)}\\|CLOCK:\\|\\(?:[-+*]\\|\\(?:[0-9]+\\)[.)]\\)\\(?:[
       ]\\|$\\)\\)\\)"
 adaptive-fill-mode t
 adaptive-fill-regexp "[        ]*\\([-–!|#%;>*·•‣⁃◦]+[         ]*\\)*"
 )