emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [BUG] org-babel-load-file, org-babel-tangle-use-relative-file-links and :tangle header [9.6.11 (release_9.6.11 @ /opt/emacs/share/emacs/30.0.50/lisp/org/)]
@ 2023-11-26  6:57 TAKAHASHI Yoshio
  2023-12-05 12:09 ` Ihor Radchenko
  0 siblings, 1 reply; 6+ messages in thread
From: TAKAHASHI Yoshio @ 2023-11-26  6:57 UTC (permalink / raw)
  To: emacs-orgmode

Hi emacs-orgmode developers,

When org-babel-tangle-use-relative-file-links is t (default),
org-babel-load-file ignores any source block that does not have `:tangle
"yes"' or `:tangle filepath' header.

Even if org-babel-default-header-args is changed like
  (setq org-babel-default-header-args
        (cons '(:tangle . "yes")
              (assq-delete-all :noweb org-babel-default-header-args)))
, the result is same.

When org-babel-tangle-use-relative-file-links is set to nil, it extracts
blocks have not :tangle header, in addition to have `:tangle "yes"' or
`:tangle filepath', and this is what I expect.

It may be too early to remove direcoty part from buffer file name in
org-babel-tangle-single-block.


test org-mode file:
#  --start--
#+begin_src emacs-lisp
  (setq a 1)
#+end_src

#+begin_src emacs-lisp :tangle (if t "yes" "no")
  (setq b 2)
#+end_src

#+begin_src emacs-lisp
  (setq c 3)
#+end_src

#+begin_src emacs-lisp :tangle "yes"
  (setq d 4)
#+end_src

#+begin_src emacs-lisp
  (setq e 5)
#+end_src
#  --end--

When invoke `(org-babel-load-file "ABOVEFILE.org")' with
org-babel-tangle-use-relative-file-links is t, the result .el file is:
#  --start--
(setq b 2)

(setq d 4)
#  --end--

With org-babel-tangle-use-relative-file-links is nil, the result is (as expected):
#  --start--
(setq a 1)

(setq b 2)

(setq c 3)

(setq d 4)

(setq e 5)
#  --end--


Emacs  : GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.33, cairo version 1.16.0)
 of 2023-11-19
Package: Org mode version 9.6.11 (release_9.6.11 @ /opt/emacs/share/emacs/30.0.50/lisp/org/)

-- 
TAKAHASHI Yoshio <yfb02119@nifty.com>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [BUG] org-babel-load-file, org-babel-tangle-use-relative-file-links and :tangle header [9.6.11 (release_9.6.11 @ /opt/emacs/share/emacs/30.0.50/lisp/org/)]
  2023-11-26  6:57 [BUG] org-babel-load-file, org-babel-tangle-use-relative-file-links and :tangle header [9.6.11 (release_9.6.11 @ /opt/emacs/share/emacs/30.0.50/lisp/org/)] TAKAHASHI Yoshio
@ 2023-12-05 12:09 ` Ihor Radchenko
  2023-12-06 13:07   ` TAKAHASHI Yoshio
  0 siblings, 1 reply; 6+ messages in thread
From: Ihor Radchenko @ 2023-12-05 12:09 UTC (permalink / raw)
  To: TAKAHASHI Yoshio; +Cc: emacs-orgmode

TAKAHASHI Yoshio <yfb02119@nifty.com> writes:

> When org-babel-tangle-use-relative-file-links is t (default),
> org-babel-load-file ignores any source block that does not have `:tangle
> "yes"' or `:tangle filepath' header.
>
> Even if org-babel-default-header-args is changed like
>   (setq org-babel-default-header-args
>         (cons '(:tangle . "yes")
>               (assq-delete-all :noweb org-babel-default-header-args)))
> , the result is same.

This is because the default value of `org-babel-default-header-args'
already contains (:tangle . "no"). So, you end up with:

( (:tangle . "yes")
    (:session . "none") (:results . "replace") (:exports . "code")
    (:cache . "no") (:hlines . "no")
  (:tangle . "no"))

As internal implementation detail, Org babel prefers the _last_ header
arg value in the above list. Which is why you end up seeing what you are seeing.

Not a bug.
Canceled.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [BUG] org-babel-load-file, org-babel-tangle-use-relative-file-links and :tangle header [9.6.11 (release_9.6.11 @ /opt/emacs/share/emacs/30.0.50/lisp/org/)]
  2023-12-05 12:09 ` Ihor Radchenko
@ 2023-12-06 13:07   ` TAKAHASHI Yoshio
  2023-12-07 13:09     ` TAKAHASHI Yoshio
  0 siblings, 1 reply; 6+ messages in thread
From: TAKAHASHI Yoshio @ 2023-12-06 13:07 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode

Ihor Radchenko <yantar92@posteo.net> writes:

> This is because the default value of `org-babel-default-header-args'
> already contains (:tangle . "no").
...
> As internal implementation detail, Org babel prefers the _last_ header
> arg value in the above list. Which is why you end up seeing what you are seeing.
>
> Not a bug.
> Canceled.

Your explanation is very clear.  Thank you.
-- 
TAKAHASHI Yoshio <yfb02119@nifty.com>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [BUG] org-babel-load-file, org-babel-tangle-use-relative-file-links and :tangle header [9.6.11 (release_9.6.11 @ /opt/emacs/share/emacs/30.0.50/lisp/org/)]
  2023-12-06 13:07   ` TAKAHASHI Yoshio
@ 2023-12-07 13:09     ` TAKAHASHI Yoshio
  2023-12-08 12:56       ` Ihor Radchenko
  0 siblings, 1 reply; 6+ messages in thread
From: TAKAHASHI Yoshio @ 2023-12-07 13:09 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode

TAKAHASHI Yoshio <yfb02119@nifty.com> writes:

>> This is because the default value of `org-babel-default-header-args'
>> already contains (:tangle . "no").
> Your explanation is very clear.  Thank you.

I did some tests.  Please check below transcript.  I expect to have the
same results in bloth case.


tkh:~$ cd /tmp
tkh:/tmp$ cat test1.org
* test1

#+begin_src emacs-lisp
  (print "1")
#+end_src

#+begin_src emacs-lisp :tangle "yes"
  (print "2")
#+end_src

#+begin_src emacs-lisp
  (print "3")
#+end_src

tkh:/tmp$ cat a.el
(require 'ox)
(setq org-babel-default-header-args
      (cons '(:tangle . "yes")
            (assq-delete-all :tangle org-babel-default-header-args)))
(org-babel-tangle-file "/tmp/test1.org" "/tmp/test1.el" "emacs-lisp")
tkh:/tmp$ emacs -Q -batch --eval="(setq org-babel-tangle-use-relative-file-links t)" -l a.el
Tangled 3 code blocks from test1.org
tkh:/tmp$ cat test1.el
(print "2")
tkh:/tmp$ emacs -Q -batch --eval="(setq org-babel-tangle-use-relative-file-links nil)" -l a.el
Tangled 3 code blocks from test1.org
tkh:/tmp$ cat test1.el
(print "1")

(print "2")

(print "3")
tkh:/tmp$

-- 
TAKAHASHI Yoshio <yfb02119@nifty.com>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [BUG] org-babel-load-file, org-babel-tangle-use-relative-file-links and :tangle header [9.6.11 (release_9.6.11 @ /opt/emacs/share/emacs/30.0.50/lisp/org/)]
  2023-12-07 13:09     ` TAKAHASHI Yoshio
@ 2023-12-08 12:56       ` Ihor Radchenko
  2023-12-08 13:57         ` TAKAHASHI Yoshio
  0 siblings, 1 reply; 6+ messages in thread
From: Ihor Radchenko @ 2023-12-08 12:56 UTC (permalink / raw)
  To: TAKAHASHI Yoshio; +Cc: emacs-orgmode

TAKAHASHI Yoshio <yfb02119@nifty.com> writes:

> TAKAHASHI Yoshio <yfb02119@nifty.com> writes:
>
>>> This is because the default value of `org-babel-default-header-args'
>>> already contains (:tangle . "no").
>> Your explanation is very clear.  Thank you.
>
> I did some tests.  Please check below transcript.  I expect to have the
> same results in bloth case.

I followed your steps using the latest main.
The results are identical for me.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [BUG] org-babel-load-file, org-babel-tangle-use-relative-file-links and :tangle header [9.6.11 (release_9.6.11 @ /opt/emacs/share/emacs/30.0.50/lisp/org/)]
  2023-12-08 12:56       ` Ihor Radchenko
@ 2023-12-08 13:57         ` TAKAHASHI Yoshio
  0 siblings, 0 replies; 6+ messages in thread
From: TAKAHASHI Yoshio @ 2023-12-08 13:57 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode

Ihor Radchenko <yantar92@posteo.net> writes:

> I followed your steps using the latest main.
> The results are identical for me.

Thank you for test.

My current environment is [1], org-mode in emacs master branch.  With
the latest org-mode main branch as of today, I get identical results,
too.

I'm happy to know the problem does not exist in org-mode main branch,
and will wait for merging them into emacs master branch.

Thank you for your time!


[1]
Emacs  : GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.33, cairo version 1.16.0)
 of 2023-11-19
Package: Org mode version 9.6.11 (release_9.6.11 @ /opt/emacs/share/emacs/30.0.50/lisp/org/)

-- 
TAKAHASHI Yoshio <yfb02119@nifty.com>


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-12-08 13:58 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-26  6:57 [BUG] org-babel-load-file, org-babel-tangle-use-relative-file-links and :tangle header [9.6.11 (release_9.6.11 @ /opt/emacs/share/emacs/30.0.50/lisp/org/)] TAKAHASHI Yoshio
2023-12-05 12:09 ` Ihor Radchenko
2023-12-06 13:07   ` TAKAHASHI Yoshio
2023-12-07 13:09     ` TAKAHASHI Yoshio
2023-12-08 12:56       ` Ihor Radchenko
2023-12-08 13:57         ` TAKAHASHI Yoshio

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).