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/)]

2018-06-26 Thread Nicolas Goaziou
Hello,

Gennady Uraltsev  writes:

> Running =(org-babel-tangle)= from inside a =src= block ignores
> =header-args= properties
> Consider the following org-mode file set for tangling.
>
> This code should run the command =org-babel-tangle=
>
> #+BEGIN_SRC emacs-lisp  :results silent
> (org-babel-tangle)
> #+END_SRC
>
> that should tangle the stuff in the next header.
>
> ** Observed behaviour
> Running the first code block tangles only the first code block below
> Running =org-babel-tangle= tangles both code blocks below
>
>
> ** Expected behaviour
> Running the above code block or =org-babel-tangle= tangles both code
> blocks below
>
>
> * Code to tangle
> ** Because of =:tangle= parameter
> This block gets tangled both by executing =org-babel-tangle= from the
> =src= code block or directly via M-x.
>
>   #+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:
>
> This block gets tangled only by executing =org-babel-tangle=  directly
> via M-x but it *doesn't* get tangled by executing =org-babel-tangle=
> from the =src= code block.
>
>   #+BEGIN_SRC emacs-lisp
>   (message "This should be tangled because of property list")
>   #+END_SRC

I cannot reproduce your issue. You may want to double check your
configuration.

Regards,

-- 
Nicolas Goaziou



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/)]

2018-06-23 Thread Nicolas Goaziou
Hello,

Gennady Uraltsev  writes:

> Running =(org-babel-tangle)= from inside a =src= block ignores
> =header-args= properties
> Consider the following org-mode file set for tangling.
>
> This code should run the command =org-babel-tangle=
>
> #+BEGIN_SRC emacs-lisp  :results silent
> (org-babel-tangle)
> #+END_SRC
>
> that should tangle the stuff in the next header.
>
> ** Observed behaviour
> Running the first code block tangles only the first code block below
> Running =org-babel-tangle= tangles both code blocks below
>
>
> ** Expected behaviour
> Running the above code block or =org-babel-tangle= tangles both code
> blocks below
>
>
> * Code to tangle
> ** Because of =:tangle= parameter
> This block gets tangled both by executing =org-babel-tangle= from the
> =src= code block or directly via M-x.
>
>   #+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:
>
> This block gets tangled only by executing =org-babel-tangle=  directly
> via M-x but it *doesn't* get tangled by executing =org-babel-tangle=
> from the =src= code block.
>
>   #+BEGIN_SRC emacs-lisp
>   (message "This should be tangled because of property list")
>   #+END_SRC

FWIW, I cannot reproduce your issue, i.e., both blocks are tangled.

Regards,

-- 
Nicolas Goaziou



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/)]

2018-06-23 Thread Henry Blevins
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