emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Henry Blevins <heblevi@gmail.com>
To: Gennady Uraltsev <gennady.uraltsev@gmail.com>
Cc: emacs-orgmode@gnu.org
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	[thread overview]
Message-ID: <CABO_LA=hpqdsJ_G0sGkaWaUDfck8iSrceYWRRs92wqvO9S0wiA@mail.gmail.com> (raw)
In-Reply-To: <47e2ef70-4494-4d1a-d055-06587ba6e086@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 6154 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 14447 bytes --]

  reply	other threads:[~2018-06-23 20:08 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-23 15:50 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/)] Gennady Uraltsev
2018-06-23 20:07 ` Henry Blevins [this message]
2018-06-23 20:09 ` Nicolas Goaziou
  -- strict thread matches above, loose matches on Subject: below --
2018-06-23 13:34 Gennady Uraltsev
2018-06-26  9:44 ` Nicolas Goaziou
2018-06-10  5:42 Gennady Uraltsev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CABO_LA=hpqdsJ_G0sGkaWaUDfck8iSrceYWRRs92wqvO9S0wiA@mail.gmail.com' \
    --to=heblevi@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=gennady.uraltsev@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).