emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Bug: org-babel-tangle sometimes does not respect header-args pro


From: Henry Blevins
Subject: Re: [O] 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

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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]