From mboxrd@z Thu Jan 1 00:00:00 1970 From: Henry Blevins Subject: Re: Bug: org-babel-tangle sometimes does not respect header-args property [9.1.9 (release_9.1.9-65-g5e4542 @ /usr/share/emacs/26.1/lisp/org/)] Date: Sat, 23 Jun 2018 16:07:39 -0400 Message-ID: References: <47e2ef70-4494-4d1a-d055-06587ba6e086@gmail.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0000000000008289d5056f54b488" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:55413) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fWopG-0007PR-TB for emacs-orgmode@gnu.org; Sat, 23 Jun 2018 16:08:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fWopE-0000GP-UY for emacs-orgmode@gnu.org; Sat, 23 Jun 2018 16:08:02 -0400 Received: from mail-qt0-x241.google.com ([2607:f8b0:400d:c0d::241]:44341) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fWopE-0000GJ-Nb for emacs-orgmode@gnu.org; Sat, 23 Jun 2018 16:08:00 -0400 Received: by mail-qt0-x241.google.com with SMTP id 92-v6so4428154qta.11 for ; Sat, 23 Jun 2018 13:08:00 -0700 (PDT) In-Reply-To: <47e2ef70-4494-4d1a-d055-06587ba6e086@gmail.com> 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: Gennady Uraltsev Cc: emacs-orgmode@gnu.org --0000000000008289d5056f54b488 Content-Type: text/plain; charset="UTF-8" I did some additional testing, and found some interesting results that appear to point to the =org-babel-get-src-block-info= function as the culprit. Depending on whether this function is evaluated directly, or executed in source blocks in different locations through this file, the function returns different results. Running this block does indeed result in an incorrectly tangled file. However, jumping down to the nearly identical block named =correct-tangle= at the end of the file and running it generates a correctly tangled file. #+BEGIN_SRC emacs-lisp :results silent (org-babel-tangle) #+END_SRC Digging into the function, the problem seems to stem from the value returned by =org-babel-get-src-block-info=. Running the following block, we see that the =:tangle= property is ="no"= for the blocks that should be tangled due to the header property list. Note the correct value of ="yes"= for the =correct-block-info= source block towards the end of the file. #+BEGIN_SRC emacs-lisp :results pp (let (blocks) (org-babel-map-src-blocks (buffer-file-name) (push (org-babel-get-src-block-info 'light) blocks)) blocks) #+END_SRC #+RESULTS: #+begin_example (("emacs-lisp" "(org-babel-tangle)" ((:results . "silent") (:exports . "code") (:lexical . "no") (:tangle . "no") (:hlines . "no") (:noweb . "no") (:cache . "no") (:session . "none")) "" nil 5378 "(ref:%s)") ("emacs-lisp" "(let (blocks)\n (org-babel-map-src-blocks (buffer-file-name)\n (push (org-babel-get-src-block-info 'light)\n blocks))\n blocks) " ((:results . "pp replace") (:exports . "code") (:lexical . "no") (:tangle . "no") (:hlines . "no") (:noweb . "no") (:cache . "no") (:session . "none")) "" nil 3102 "(ref:%s)") ("emacs-lisp" "(message \"This should be tangled because of property list\")" ((:results . "replace") (:exports . "code") (:lexical . "no") (:tangle . "no") (:hlines . "no") (:noweb . "no") (:cache . "no") (:session . "none")) "" nil 2850 "(ref:%s)") ("emacs-lisp" "(message \"This should be tangled because of :tangle parameter\")" ((:results . "replace") (:exports . "code") (:tangle . "yes") (:lexical . "no") (:hlines . "no") (:noweb . "no") (:cache . "no") (:session . "none")) "" nil 2649 "(ref:%s)") ("emacs-lisp" "(let (blocks)\n (org-babel-map-src-blocks (buffer-file-name)\n (push (org-babel-get-src-block-info 'light)\n blocks))\n blocks) " ((:results . "pp replace") (:exports . "code") (:lexical . "no") (:tangle . "no") (:hlines . "no") (:noweb . "no") (:cache . "no") (:session . "none")) "" nil 975 "(ref:%s)") ("emacs-lisp" "(org-babel-tangle)" ((:results . "silent") (:exports . "code") (:lexical . "no") (:tangle . "no") (:hlines . "no") (:noweb . "no") (:cache . "no") (:session . "none")) "" nil 563 "(ref:%s)")) #+end_example * Code to tangle ** Because of =:tangle= parameter #+BEGIN_SRC emacs-lisp :tangle yes (message "This should be tangled because of :tangle parameter") #+END_SRC ** Because of properties :PROPERTIES: :header-args: :tangle yes :END: #+BEGIN_SRC emacs-lisp (message "This should be tangled because of property list") #+END_SRC The following block, when executed, results in the correct values for each source blocks =:tangle= property. #+name correct-block-info #+BEGIN_SRC emacs-lisp :results pp (let (blocks) (org-babel-map-src-blocks (buffer-file-name) (push (org-babel-get-src-block-info 'light) blocks)) blocks) #+END_SRC #+RESULTS: #+begin_example (("emacs-lisp" "(org-babel-tangle)" ((:results . "silent") (:exports . "code") (:tangle . "yes") (:lexical . "no") (:hlines . "no") (:noweb . "no") (:cache . "no") (:session . "none")) "" nil 3281 "(ref:%s)") ("emacs-lisp" "(let (blocks)\n (org-babel-map-src-blocks (buffer-file-name)\n (push (org-babel-get-src-block-info 'light)\n blocks))\n blocks) " ((:results . "pp replace") (:exports . "code") (:tangle . "yes") (:lexical . "no") (:hlines . "no") (:noweb . "no") (:cache . "no") (:session . "none")) "" nil 2987 "(ref:%s)") ("emacs-lisp" "(message \"This should be tangled because of property list\")" ((:results . "replace") (:exports . "code") (:tangle . "yes") (:lexical . "no") (:hlines . "no") (:noweb . "no") (:cache . "no") (:session . "none")) "" nil 2850 "(ref:%s)") ("emacs-lisp" "(message \"This should be tangled because of :tangle parameter\")" ((:results . "replace") (:exports . "code") (:tangle . "yes") (:lexical . "no") (:hlines . "no") (:noweb . "no") (:cache . "no") (:session . "none")) "" nil 2649 "(ref:%s)") ("emacs-lisp" "(let (blocks)\n (org-babel-map-src-blocks (buffer-file-name)\n (push (org-babel-get-src-block-info 'light)\n blocks))\n blocks) " ((:results . "pp replace") (:exports . "code") (:tangle . "yes") (:lexical . "no") (:hlines . "no") (:noweb . "no") (:cache . "no") (:session . "none")) "" nil 975 "(ref:%s)") ("emacs-lisp" "(org-babel-tangle)" ((:results . "silent") (:exports . "code") (:tangle . "yes") (:lexical . "no") (:hlines . "no") (:noweb . "no") (:cache . "no") (:session . "none")) "" nil 563 "(ref:%s)")) #+end_example Running the following block tangles correctly #+name correct-tangle #+BEGIN_SRC emacs-lisp :results silent (org-babel-tangle) #+END_SRC I apologize if this is difficult to read. To summarize, my findings indicate that =org-babel-get-src-block-info= is incorrectly processing or merging the properties of each block depending on how, or where, it is run. I unfortunately don't have time right now to untangle this fully, but I hope this helps. Best Regards, Henry Blevins --0000000000008289d5056f54b488 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I di= d some additional testing, and found some interesting results that appear t= o
point to the =3Dorg-babel-get-src-block-i= nfo=3D function as the culprit. Depending on
whether this function is evaluated directly, or executed in source blocks= in
different locations through this file, = the function returns different results.
Running this block does indeed result in = an incorrectly tangled file. However,
jumpi= ng down to the nearly identical block named =3Dcorrect-tangle=3D at the end= of
the file and running it generates a cor= rectly tangled file.

#+BEGIN_SRC emacs-lisp :results silent
(org-babel-tangle)
#+END_SRC

Digging= into the function, the problem seems to stem from the value returned by
=3Dorg-babel-get-src-block-info=3D. Running t= he following block, we see that the
=3D:tan= gle=3D property is =3D"no"=3D for the blocks that should be tangl= ed due to the header
property list.=C2=A0

Note th= e correct value of =3D"yes"=3D for the =3Dcorrect-block-info=3D s= ource block towards
the end of the file.

#+BEGIN_= SRC emacs-lisp :results pp
=C2=A0 (let (blo= cks)
=C2=A0 =C2=A0 (org-babel-map-src-block= s (buffer-file-name)
=C2=A0 =C2=A0 =C2=A0 (= push (org-babel-get-src-block-info 'light)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 blocks))
=C2=A0 =C2=A0 blocks)=C2=A0
#+E= ND_SRC

#+RESULTS:
#+begin_example
(("emacs-lisp" "(org-babel-tangle)"
=C2=A0 ((:results . "silent")
=
=C2=A0 =C2=A0(:exports . "code")
=
=C2=A0 =C2=A0(:lexical . "no")
=C2=A0 =C2=A0(:tangle . "no")
=C2=A0 =C2=A0(:hlines . "no")
=C2=A0 =C2=A0(:noweb . "no")
=C2=A0 =C2=A0(:cache . "no")
=C2=A0 =C2=A0(:session . "none"))
=C2=A0 "" nil 5378 "(ref:%s)")
=C2=A0("emacs-lisp" "(let (blocks)\n= =C2=A0 (org-babel-map-src-blocks (buffer-file-name)\n=C2=A0 =C2=A0 (push (o= rg-babel-get-src-block-info 'light)\n=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= blocks))\n=C2=A0 blocks) "
=C2=A0 ((:= results . "pp replace")
=C2=A0 = =C2=A0(:exports . "code")
=C2=A0 = =C2=A0(:lexical . "no")
=C2=A0 = =C2=A0(:tangle . "no")
=C2=A0 =C2= =A0(:hlines . "no")
=C2=A0 =C2=A0= (:noweb . "no")
=C2=A0 =C2=A0(:ca= che . "no")
=C2=A0 =C2=A0(:sessio= n . "none"))
=C2=A0 "" = nil 3102 "(ref:%s)")
=C2=A0("= ;emacs-lisp" "(message \"This should be tangled because of p= roperty list\")"
=C2=A0 ((:result= s . "replace")
=C2=A0 =C2=A0(:exp= orts . "code")
=C2=A0 =C2=A0(:lex= ical . "no")
=C2=A0 =C2=A0(:tangl= e . "no")
=C2=A0 =C2=A0(:hlines .= "no")
=C2=A0 =C2=A0(:noweb . &qu= ot;no")
=C2=A0 =C2=A0(:cache . "n= o")
=C2=A0 =C2=A0(:session . "non= e"))
=C2=A0 "" nil 2850 &quo= t;(ref:%s)")
=C2=A0("emacs-lisp&q= uot; "(message \"This should be tangled because of :tangle parame= ter\")"
=C2=A0 ((:results . "= ;replace")
=C2=A0 =C2=A0(:exports . &q= uot;code")
=C2=A0 =C2=A0(:tangle . &qu= ot;yes")
=C2=A0 =C2=A0(:lexical . &quo= t;no")
=C2=A0 =C2=A0(:hlines . "n= o")
=C2=A0 =C2=A0(:noweb . "no&qu= ot;)
=C2=A0 =C2=A0(:cache . "no")=
=C2=A0 =C2=A0(:session . "none")= )
=C2=A0 "" nil 2649 "(ref:%= s)")
=C2=A0("emacs-lisp" &qu= ot;(let (blocks)\n=C2=A0 (org-babel-map-src-blocks (buffer-file-name)\n=C2= =A0 =C2=A0 (push (org-babel-get-src-block-info 'light)\n=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 blocks))\n=C2=A0 blocks) "
=C2=A0 ((:results . "pp replace")
=C2=A0 =C2=A0(:exports . "code")
=C2=A0 =C2=A0(:lexical . "no")
=C2=A0 =C2=A0(:tangle . "no")
=C2=A0 =C2=A0(:hlines . "no")
=C2=A0 =C2=A0(:noweb . "no")
= =C2=A0 =C2=A0(:cache . "no")
=C2= =A0 =C2=A0(:session . "none"))
= =C2=A0 "" nil 975 "(ref:%s)")
=C2=A0("emacs-lisp" "(org-babel-tangle)"
=C2=A0 ((:results . "silent")
=C2=A0 =C2=A0(:exports . "code")
=C2=A0 =C2=A0(:lexical . "no")
=C2=A0 =C2=A0(:tangle . "no")
=C2=A0 =C2=A0(:hlines . "no")
=C2=A0 =C2=A0(:noweb . "no")
=C2=A0 =C2=A0(:cache . "no")
=C2=A0 =C2=A0(:session . "none"))
=C2=A0 "" nil 563 "(ref:%s)"))
#+end_example


* Code to tan= gle
** Because of =3D:tangle=3D parameter

=C2=A0 = =C2=A0#+BEGIN_SRC emacs-lisp :tangle yes
= =C2=A0 =C2=A0 =C2=A0(message "This should be tangled because of :tangl= e parameter")
=C2=A0 =C2=A0#+END_SRC

** Beca= use of properties
=C2=A0 =C2=A0:PROPERTIES:=
=C2=A0 =C2=A0:header-args: :tangle yes
=C2=A0 =C2=A0:END:

=C2=A0 =C2=A0#+BEGIN_SRC emacs-li= sp
=C2=A0 =C2=A0 =C2=A0(message "This = should be tangled because of property list")
=C2=A0 =C2=A0#+END_SRC
=C2=A0 =C2=A0=
=C2=A0 =C2=A0The following block, when exe= cuted, results in the correct values for each
=C2=A0 =C2=A0source blocks =3D:tangle=3D property.

=C2=A0 =C2=A0#+name correct= -block-info
=C2=A0 =C2=A0#+BEGIN_SRC emacs-= lisp :results pp
=C2=A0 =C2=A0 =C2=A0(let (= blocks)
=C2=A0 =C2=A0 =C2=A0 =C2=A0(org-bab= el-map-src-blocks (buffer-file-name)
=C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0(push (org-babel-get-src-block-info 'light)=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0blocks))
=C2=A0 =C2=A0 =C2=A0 = =C2=A0blocks)=C2=A0
=C2=A0 =C2=A0#+END_SRC<= /div>

=C2=A0= =C2=A0#+RESULTS:
=C2=A0 =C2=A0#+begin_exam= ple
=C2=A0 =C2=A0(("emacs-lisp" &= quot;(org-babel-tangle)"
=C2=A0 =C2=A0= =C2=A0((:results . "silent")
=C2= =A0 =C2=A0 =C2=A0 (:exports . "code")
=C2=A0 =C2=A0 =C2=A0 (:tangle . "yes")
=C2=A0 =C2=A0 =C2=A0 (:lexical . "no")
=C2=A0 =C2=A0 =C2=A0 (:hlines . "no")
=C2=A0 =C2=A0 =C2=A0 (:noweb . "no")
<= div class=3D"gmail_extra">=C2=A0 =C2=A0 =C2=A0 (:cache . "no")
=C2=A0 =C2=A0 =C2=A0 (:session . "none&q= uot;))
=C2=A0 =C2=A0 =C2=A0"" nil= 3281 "(ref:%s)")
=C2=A0 =C2=A0 (= "emacs-lisp" "(let (blocks)\n=C2=A0 (org-babel-map-src-block= s (buffer-file-name)\n=C2=A0 =C2=A0 (push (org-babel-get-src-block-info = 9;light)\n=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 blocks))\n=C2=A0 blocks) "= ;
=C2=A0 =C2=A0 =C2=A0((:results . "pp= replace")
=C2=A0 =C2=A0 =C2=A0 (:expo= rts . "code")
=C2=A0 =C2=A0 =C2= =A0 (:tangle . "yes")
=C2=A0 =C2= =A0 =C2=A0 (:lexical . "no")
=C2= =A0 =C2=A0 =C2=A0 (:hlines . "no")
=C2=A0 =C2=A0 =C2=A0 (:noweb . "no")
=C2=A0 =C2=A0 =C2=A0 (:cache . "no")
=C2=A0 =C2=A0 =C2=A0 (:session . "none"))
=C2=A0 =C2=A0 =C2=A0"" nil 2987 "(ref:%s)= ")
=C2=A0 =C2=A0 ("emacs-lisp&quo= t; "(message \"This should be tangled because of property list\&q= uot;)"
=C2=A0 =C2=A0 =C2=A0((:results = . "replace")
=C2=A0 =C2=A0 =C2=A0= (:exports . "code")
=C2=A0 =C2= =A0 =C2=A0 (:tangle . "yes")
=C2= =A0 =C2=A0 =C2=A0 (:lexical . "no")
=C2=A0 =C2=A0 =C2=A0 (:hlines . "no")
=C2=A0 =C2=A0 =C2=A0 (:noweb . "no")
=C2=A0 =C2=A0 =C2=A0 (:cache . "no")
=C2=A0 =C2=A0 =C2=A0 (:session . "none"))
<= div class=3D"gmail_extra">=C2=A0 =C2=A0 =C2=A0"" nil 2850 "(= ref:%s)")
=C2=A0 =C2=A0 ("emacs-l= isp" "(message \"This should be tangled because of :tangle p= arameter\")"
=C2=A0 =C2=A0 =C2=A0= ((:results . "replace")
=C2=A0 = =C2=A0 =C2=A0 (:exports . "code")
=C2=A0 =C2=A0 =C2=A0 (:tangle . "yes")
=C2=A0 =C2=A0 =C2=A0 (:lexical . "no")
=C2=A0 =C2=A0 =C2=A0 (:hlines . "no")
=C2=A0 =C2=A0 =C2=A0 (:noweb . "no")
=C2=A0 =C2=A0 =C2=A0 (:cache . "no")
<= div class=3D"gmail_extra">=C2=A0 =C2=A0 =C2=A0 (:session . "none"= ))
=C2=A0 =C2=A0 =C2=A0"" nil 264= 9 "(ref:%s)")
=C2=A0 =C2=A0 (&quo= t;emacs-lisp" "(let (blocks)\n=C2=A0 (org-babel-map-src-blocks (b= uffer-file-name)\n=C2=A0 =C2=A0 (push (org-babel-get-src-block-info 'li= ght)\n=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 blocks))\n=C2=A0 blocks) "
=C2=A0 =C2=A0 =C2=A0((:results . "pp rep= lace")
=C2=A0 =C2=A0 =C2=A0 (:exports = . "code")
=C2=A0 =C2=A0 =C2=A0 (:= tangle . "yes")
=C2=A0 =C2=A0 =C2= =A0 (:lexical . "no")
=C2=A0 =C2= =A0 =C2=A0 (:hlines . "no")
=C2= =A0 =C2=A0 =C2=A0 (:noweb . "no")
=C2=A0 =C2=A0 =C2=A0 (:cache . "no")
=C2=A0 =C2=A0 =C2=A0 (:session . "none"))
=C2=A0 =C2=A0 =C2=A0"" nil 975 "(ref:%s)"= )
=C2=A0 =C2=A0 ("emacs-lisp" &qu= ot;(org-babel-tangle)"
=C2=A0 =C2=A0 = =C2=A0((:results . "silent")
=C2= =A0 =C2=A0 =C2=A0 (:exports . "code")
=C2=A0 =C2=A0 =C2=A0 (:tangle . "yes")
=C2=A0 =C2=A0 =C2=A0 (:lexical . "no")
=C2=A0 =C2=A0 =C2=A0 (:hlines . "no")
=C2=A0 =C2=A0 =C2=A0 (:noweb . "no")
<= div class=3D"gmail_extra">=C2=A0 =C2=A0 =C2=A0 (:cache . "no")
=C2=A0 =C2=A0 =C2=A0 (:session . "none&q= uot;))
=C2=A0 =C2=A0 =C2=A0"" nil= 563 "(ref:%s)"))
=C2=A0 =C2=A0#+= end_example
=C2=A0 =C2=A0
=C2=A0 =C2=A0Running the following block tangles correctly=

=C2= =A0 =C2=A0#+name correct-tangle
=C2=A0 =C2= =A0#+BEGIN_SRC emacs-lisp :results silent
= =C2=A0 =C2=A0 =C2=A0(org-babel-tangle)
=C2= =A0 =C2=A0#+END_SRC

=C2=A0 =C2=A0I apologize if this is difficult to read.=C2=A0<= /div>

=C2=A0= =C2=A0To summarize, my findings indicate that =3Dorg-babel-get-src-block-i= nfo=3D is
=C2=A0 =C2=A0incorrectly processi= ng or merging the properties of each block depending on
=C2=A0 =C2=A0how, or where, it is run.

=C2=A0 =C2=A0I unfortunately = don't have time right now to untangle this fully, but I hope
=C2=A0 =C2=A0this helps.

=C2=A0 =C2=A0Best Regards,

=C2=A0 =C2=A0= Henry Blevins

--0000000000008289d5056f54b488--