emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Re: :tangle header argument not picked up in #+PROPERTY line or :PROPERTIES: block
@ 2020-03-31  1:01 Thomas S. Dye
  2020-04-01 19:07 ` Joost Kremers
  0 siblings, 1 reply; 14+ messages in thread
From: Thomas S. Dye @ 2020-03-31  1:01 UTC (permalink / raw)
  To: joostkremers; +Cc: emacs-org list

Aloha Joost,

This link reflects my understanding of how properties accumulate, 
rather than overwrite: 
https://org-babel.readthedocs.io/en/latest/header-args/

hth,
Tom

--
Thomas S. Dye
https://tsdye.online/tsdye

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

* Re: :tangle header argument not picked up in #+PROPERTY line or :PROPERTIES: block
  2020-03-31  1:01 :tangle header argument not picked up in #+PROPERTY line or :PROPERTIES: block Thomas S. Dye
@ 2020-04-01 19:07 ` Joost Kremers
  0 siblings, 0 replies; 14+ messages in thread
From: Joost Kremers @ 2020-04-01 19:07 UTC (permalink / raw)
  To: Thomas S. Dye; +Cc: emacs-orgmode

Hi Thomas,

Thanks for that link. I really need to go over that document 
carefully. :-)

Best,

Joost



On Tue, Mar 31 2020, Thomas S. Dye wrote:
> Aloha Joost,
>
> This link reflects my understanding of how properties 
> accumulate, rather than
> overwrite: 
> https://org-babel.readthedocs.io/en/latest/header-args/
>
> hth,
> Tom


-- 
Joost Kremers
Life has its moments

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

* Re: :tangle header argument not picked up in #+PROPERTY line or :PROPERTIES: block
  2020-03-31  1:08               ` Berry, Charles via General discussions about Org-mode.
@ 2020-03-31 20:04                 ` Joost Kremers
  0 siblings, 0 replies; 14+ messages in thread
From: Joost Kremers @ 2020-03-31 20:04 UTC (permalink / raw)
  To: Berry, Charles; +Cc: emacs-orgmode, Ken Mankoff


On Tue, Mar 31 2020, Berry, Charles via General discussions about 
Org-mode. wrote:
> `org-babel-view-src-block-info' (C-c C-v C-i with point in the 
> src block below) reports

I didn't know about that command, it's proven to be very helpful.

Thanks!

Joost


-- 
Joost Kremers
Life has its moments

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

* Re: :tangle header argument not picked up in #+PROPERTY line or :PROPERTIES: block
  2020-03-31 15:14               ` Ken Mankoff
@ 2020-03-31 19:54                 ` Joost Kremers
  0 siblings, 0 replies; 14+ messages in thread
From: Joost Kremers @ 2020-03-31 19:54 UTC (permalink / raw)
  To: Ken Mankoff; +Cc: Berry, Charles, emacs-orgmode


On Tue, Mar 31 2020, Ken Mankoff wrote:
> Yes I'm sure. From the link Thomas sent,
>
> Any property specification, unless it is postfixed with a `+`, 
> will *reset*
> the value of that property to its current value.

Yes, I realise now I was mistaken. For some reason, I though that 
`:results function` meant something, which it doesn't.

> C-c C-v <TAB> (for me, Charles uses C-c C-v C-i) withitn a code 
> block shows
> you the header args that are set for that block. Useful for 
> debugging.

Yes, that turned out to be very useful. Thanks.

Joost


-- 
Joost Kremers
Life has its moments

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

* Re: :tangle header argument not picked up in #+PROPERTY line or :PROPERTIES: block
  2020-03-30 22:23             ` Joost Kremers
  2020-03-31  1:08               ` Berry, Charles via General discussions about Org-mode.
@ 2020-03-31 15:14               ` Ken Mankoff
  2020-03-31 19:54                 ` Joost Kremers
  1 sibling, 1 reply; 14+ messages in thread
From: Ken Mankoff @ 2020-03-31 15:14 UTC (permalink / raw)
  To: Joost Kremers; +Cc: Berry, Charles, emacs-orgmode

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

Yes I'm sure. From the link Thomas sent,

Any property specification, unless it is postfixed with a `+`, will *reset*
the value of that property to its current value.

C-c C-v <TAB> (for me, Charles uses C-c C-v C-i) withitn a code block shows
you the header args that are set for that block. Useful for debugging.

  -k.

On Mon, Mar 30, 2020 at 3:24 PM Joost Kremers <joostkremers@fastmail.fm>
wrote:

>
> On Mon, Mar 30 2020, Ken Mankoff wrote:
> > Header args overwrite. Change python to python+ to append header
> > args.
>
> Are you sure? That's not documented anywhere I can find and it
> seems to be belied by the fact that if I put the headers in the
> order:
>
> ```
> :PROPERTIES:
> :header-args:python: :tangle out1.py
> :header-args:python: :session py1 :results function
> :END:
> ```
>
> everything works as I would expect (the code blocks are tangled to
> a file `out1.py` *and* they are evaluated in a python session
> `py1`), meaning that *all* header args are picked up.
>
> If I reverse the order and add a `+` sign, like so:
>
> ```
> :PROPERTIES:
> :header-args:python+: :session py1 :results function
> :header-args:python+: :tangle out1.py
> :END:
> ```
>
> the code does indeed get tangled, but the `:results` header arg
> isn't picked up, because the code block doesn't produce any
> output.
>
> For reference, this is my test file:
>
> ```
> * Header 1
> :PROPERTIES:
> :header-args:python+: :session py1 :results function
> :header-args:python+: :tangle out1.py
> :END:
>
> #+begin_src python
> a=1
> b=2
> c=a+b
> return c
> #+end_src
>
> #+RESULTS:
> ```
>
>
> --
> Joost Kremers
> Life has its moments
>

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

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

* Re: :tangle header argument not picked up in #+PROPERTY line or :PROPERTIES: block
  2020-03-30 22:23             ` Joost Kremers
@ 2020-03-31  1:08               ` Berry, Charles via General discussions about Org-mode.
  2020-03-31 20:04                 ` Joost Kremers
  2020-03-31 15:14               ` Ken Mankoff
  1 sibling, 1 reply; 14+ messages in thread
From: Berry, Charles via General discussions about Org-mode. @ 2020-03-31  1:08 UTC (permalink / raw)
  To: Joost Kremers; +Cc: emacs-orgmode, Ken Mankoff



> On Mar 30, 2020, at 3:23 PM, Joost Kremers <joostkremers@fastmail.fm> wrote:
> 

[stuff deleted]

> 
> If I reverse the order and add a `+` sign, like so:
> 
> ```
> :PROPERTIES:
> :header-args:python+: :session py1 :results function
> :header-args:python+: :tangle out1.py
> :END:
> ```
> 
> the code does indeed get tangled, but the `:results` header arg isn't picked up, because the code block doesn't produce any output.


Not so.

`org-babel-view-src-block-info' (C-c C-v C-i with point in the src block below) reports

,----
| Lang: python
| Properties:
| 	:header-args 	nil
| 	:header-args:python 	:session py1 :results function :tangle out1.py
| Header Arguments:
| 	:cache		no
| 	:exports	code
| 	:hlines		no
| 	:noweb		no
| 	:results	function replace
| 	:session	py1
| 	:tangle		out1.py
`----

> 
> For reference, this is my test file:
> 
> ```
> * Header 1
> :PROPERTIES:
> :header-args:python+: :session py1 :results function
> :header-args:python+: :tangle out1.py
> :END:
> 
> #+begin_src python
> a=1
> b=2
> c=a+b
> return c
> #+end_src
> 
> #+RESULTS:
> ```

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

* Re: :tangle header argument not picked up in #+PROPERTY line or :PROPERTIES: block
  2020-03-29 23:44           ` Ken Mankoff
@ 2020-03-30 22:23             ` Joost Kremers
  2020-03-31  1:08               ` Berry, Charles via General discussions about Org-mode.
  2020-03-31 15:14               ` Ken Mankoff
  0 siblings, 2 replies; 14+ messages in thread
From: Joost Kremers @ 2020-03-30 22:23 UTC (permalink / raw)
  To: Ken Mankoff; +Cc: Berry, Charles, emacs-orgmode


On Mon, Mar 30 2020, Ken Mankoff wrote:
> Header args overwrite. Change python to python+ to append header 
> args.

Are you sure? That's not documented anywhere I can find and it 
seems to be belied by the fact that if I put the headers in the 
order:

```
:PROPERTIES:
:header-args:python: :tangle out1.py
:header-args:python: :session py1 :results function
:END:
```

everything works as I would expect (the code blocks are tangled to 
a file `out1.py` *and* they are evaluated in a python session 
`py1`), meaning that *all* header args are picked up.

If I reverse the order and add a `+` sign, like so:

```
:PROPERTIES:
:header-args:python+: :session py1 :results function
:header-args:python+: :tangle out1.py
:END:
```

the code does indeed get tangled, but the `:results` header arg 
isn't picked up, because the code block doesn't produce any 
output.

For reference, this is my test file:

```
* Header 1
:PROPERTIES:
:header-args:python+: :session py1 :results function
:header-args:python+: :tangle out1.py
:END:

#+begin_src python
a=1
b=2
c=a+b
return c
#+end_src

#+RESULTS:
```


-- 
Joost Kremers
Life has its moments

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

* Re: :tangle header argument not picked up in #+PROPERTY line or :PROPERTIES: block
  2020-03-29 22:41         ` Joost Kremers
@ 2020-03-29 23:44           ` Ken Mankoff
  2020-03-30 22:23             ` Joost Kremers
  0 siblings, 1 reply; 14+ messages in thread
From: Ken Mankoff @ 2020-03-29 23:44 UTC (permalink / raw)
  To: Joost Kremers; +Cc: Berry, Charles, emacs-orgmode

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

Header args overwrite. Change python to python+ to append header args.

Please excuse brevity. Sent from tiny pocket computer with non-haptic
feedback keyboard.

On Sun, Mar 29, 2020, 15:42 Joost Kremers <joostkremers@fastmail.fm> wrote:

>
> On Mon, Mar 30 2020, Joost Kremers wrote:
> > Looks like a bug, right?
>
> And while I'm at it, this doesn't work as expected either:
>
> ```
> #+PROPERTY: header-args :dir /home/joost/tmp/dlpy/
>
> * Header 1
> :PROPERTIES:
> :header-args:python: :tangle out1.py
> :header-args:python: :session py1 :results function
> :END:
>
> #+begin_src python
> a=1
> b=2
> c=a+b
> return c
> #+end_src
> ```
>
> I would expect that the file `out1.py` is created in the directory
> `/home/joost/tmp/dlpy`, but it's created in the same directory as
> the Org file.
>
> Are my expectations wrong or is this really a bug?
>
>
> --
> Joost Kremers
> Life has its moments
>
>

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

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

* Re: :tangle header argument not picked up in #+PROPERTY line or :PROPERTIES: block
  2020-03-29 22:07       ` Joost Kremers
@ 2020-03-29 22:41         ` Joost Kremers
  2020-03-29 23:44           ` Ken Mankoff
  0 siblings, 1 reply; 14+ messages in thread
From: Joost Kremers @ 2020-03-29 22:41 UTC (permalink / raw)
  To: Berry, Charles; +Cc: emacs-orgmode


On Mon, Mar 30 2020, Joost Kremers wrote:
> Looks like a bug, right?

And while I'm at it, this doesn't work as expected either:

```
#+PROPERTY: header-args :dir /home/joost/tmp/dlpy/

* Header 1
:PROPERTIES:
:header-args:python: :tangle out1.py
:header-args:python: :session py1 :results function
:END:

#+begin_src python
a=1
b=2
c=a+b
return c
#+end_src
```

I would expect that the file `out1.py` is created in the directory 
`/home/joost/tmp/dlpy`, but it's created in the same directory as 
the Org file.

Are my expectations wrong or is this really a bug?


-- 
Joost Kremers
Life has its moments

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

* Re: :tangle header argument not picked up in #+PROPERTY line or :PROPERTIES: block
  2020-03-29 20:41     ` Berry, Charles via General discussions about Org-mode.
@ 2020-03-29 22:07       ` Joost Kremers
  2020-03-29 22:41         ` Joost Kremers
  0 siblings, 1 reply; 14+ messages in thread
From: Joost Kremers @ 2020-03-29 22:07 UTC (permalink / raw)
  To: Berry, Charles; +Cc: emacs-orgmode


On Sun, Mar 29 2020, Berry, Charles via General discussions about 
Org-mode. wrote:
> What we really need is an ECM rather than snippets of code.

Yes, my apologies. It seems that having more than one `header-arg` 
line doesn't work properly. The following works:

```
* Header 1
:PROPERTIES:
:header-args:python: :tangle out1.py
:header-args:python: :session py1 :results function
:END:
#+begin_src python
a=1
b=2
c=a+b
return c
#+end_src

#+RESULTS:
: 3
```

But if I swap the two `header-args` lines, tangling stops working 
and at the same time evaluating the code block doesn't give any 
output at all:

```
* Header 1
:PROPERTIES:
:header-args:python: :session py1 :results function
:header-args:python: :tangle out1.py
:END:
#+begin_src python
a=1
b=2
c=a+b
return c
#+end_src

#+RESULTS:
```

With a `#+PROPERTY` line, I can't make it work at all:

```
#+PROPERTY: header-args:python :tangle out.py
#+PROPERTY: header-args:python :results function

* Header 1
#+begin_src python
a=1
b=2
c=a+b
return c
#+end_src

#+RESULTS:
: 3
```

Evaluating the code block works, but tangling doesn't. Reversing 
the order of the `#+PROPERTY` lines has no effect in this case.

Looks like a bug, right?

-- 
Joost Kremers
Life has its moments

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

* Re: :tangle header argument not picked up in #+PROPERTY line or :PROPERTIES: block
  2020-03-29 20:13   ` Joost Kremers
@ 2020-03-29 20:41     ` Berry, Charles via General discussions about Org-mode.
  2020-03-29 22:07       ` Joost Kremers
  0 siblings, 1 reply; 14+ messages in thread
From: Berry, Charles via General discussions about Org-mode. @ 2020-03-29 20:41 UTC (permalink / raw)
  To: Joost Kremers; +Cc: emacs-orgmode



> On Mar 29, 2020, at 1:13 PM, Joost Kremers <joostkremers@fastmail.fm> wrote:
> 
> 
> On Sun, Mar 29 2020, Berry, Charles via General discussions about Org-mode. wrote:
>>> On Mar 28, 2020, at 3:00 PM, Joost Kremers <joostkremers@fastmail.fm> wrote:
>>> Is this expected behaviour? Am I doing something wrong?
>> 
>> IIUC what you did, then yes and yes.
>> 
>> This is the accepted idiom:
>> 
>> #+PROPERTY: header-args :tangle yes
> 


What we really need is an ECM rather than snippets of code.

This ECM works for me:

#+begin_src org

  ,* try python
  :PROPERTIES:
  :header-args:python: :tangle yes
  :END:
  ,#+begin_src python
  "a+b"
  ,#+end_src


#+end_src

producing a file of the same name with the .py extension with one line containing "a+b".

I am on release Org mode version 9.3.6 (release_9.3.6-442-g97f0f1 ), but this also work on release_9.3-34-g2eee3c

HTH,

Chuck

p.s. `M-x org-lint' may reveal some issues with your file that might not be obvious to the eye.

> I have tried:
> 
> #+begin_example
> #+PROPERTY: header-args:python :tangle yes :dir  /home/joost/tmp/dlpy
> #+end_example
> 
> which AFAICT is the syntax shown in the info node you mentioned. I have also tried a file name instead of =yes=, both with and without quotes, but it doesn't work.
> 
> What I really want is to have a property block with the =:tangle= arg under each top-level header, like so:
> 
> #+begin_example
> :PROPERTIES:
> :header-args:python: :tangle out1.py
> :END:
> #+begin_example
> 
> because I want the code below each top-level header to be tangled to a separate file. Again, AFAICT this is the syntax described in the info manual.
> 
> Hmm, experimenting a bit more I find that if I leave out the =python= part, it works:
> 
> #+begin_example
> :PROPERTIES:
> :header-args: :tangle out1.py
> :END:
> #+begin_example
> 
> But the info manual gives this example:
> 
> #+begin_example
> :PROPERTIES:
> :header-args:clojure:    :session *clojure-1*
> :END:
> #+begin_example
> 
> The same is true for the #+PROPERTY block at the top of the file: leave out the =python=, it works. Isn't it possible to restrict tangling to source blocks of a particular language? (Or, more specifically what I want: to specify different tangling targets for different language? I wanted to have both python and bash code blocks under one header and have them tangled to different files...)
> 
> Joost
> 
> 
> -- 
> Joost Kremers
> Life has its moments

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

* Re: :tangle header argument not picked up in #+PROPERTY line or :PROPERTIES: block
  2020-03-29 17:45 ` Berry, Charles via General discussions about Org-mode.
@ 2020-03-29 20:13   ` Joost Kremers
  2020-03-29 20:41     ` Berry, Charles via General discussions about Org-mode.
  0 siblings, 1 reply; 14+ messages in thread
From: Joost Kremers @ 2020-03-29 20:13 UTC (permalink / raw)
  To: Berry, Charles; +Cc: emacs-orgmode


On Sun, Mar 29 2020, Berry, Charles via General discussions about 
Org-mode. wrote:
>> On Mar 28, 2020, at 3:00 PM, Joost Kremers 
>> <joostkremers@fastmail.fm> wrote:
>> Is this expected behaviour? Am I doing something wrong?
>
> IIUC what you did, then yes and yes.
>
> This is the accepted idiom:
>
> #+PROPERTY: header-args :tangle yes

I have tried:

#+begin_example
  #+PROPERTY: header-args:python :tangle yes :dir 
  /home/joost/tmp/dlpy
#+end_example

which AFAICT is the syntax shown in the info node you mentioned. I 
have also tried a file name instead of =yes=, both with and 
without quotes, but it doesn't work.

What I really want is to have a property block with the =:tangle= 
arg under each top-level header, like so:

#+begin_example
  :PROPERTIES:
  :header-args:python: :tangle out1.py
  :END:
#+begin_example

because I want the code below each top-level header to be tangled 
to a separate file. Again, AFAICT this is the syntax described in 
the info manual.

Hmm, experimenting a bit more I find that if I leave out the 
=python= part, it works:

#+begin_example
  :PROPERTIES:
  :header-args: :tangle out1.py
  :END:
#+begin_example

But the info manual gives this example:

#+begin_example
  :PROPERTIES:
  :header-args:clojure:    :session *clojure-1*
  :END:
#+begin_example

The same is true for the #+PROPERTY block at the top of the file: 
leave out the =python=, it works. Isn't it possible to restrict 
tangling to source blocks of a particular language? (Or, more 
specifically what I want: to specify different tangling targets 
for different language? I wanted to have both python and bash code 
blocks under one header and have them tangled to different 
files...)

Joost


-- 
Joost Kremers
Life has its moments

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

* Re: :tangle header argument not picked up in #+PROPERTY line or :PROPERTIES: block
  2020-03-28 22:00 Joost Kremers
@ 2020-03-29 17:45 ` Berry, Charles via General discussions about Org-mode.
  2020-03-29 20:13   ` Joost Kremers
  0 siblings, 1 reply; 14+ messages in thread
From: Berry, Charles via General discussions about Org-mode. @ 2020-03-29 17:45 UTC (permalink / raw)
  To: Joost Kremers; +Cc: emacs-orgmode



> On Mar 28, 2020, at 3:00 PM, Joost Kremers <joostkremers@fastmail.fm> wrote:
> 
> Hi list,
> 
> I'm having trouble tangling an Org file. Basically, if I put a =:tangle= header argument in a =#+PROPERTY= line at the top of the file or in a =:PROPERTIES:= block under a header, it is not picked up and the code blocks to which (I think) it should apply are not tangled. Only when I put a =:tangle= argument at the top of the source block itself is the source block tangled.
> 
> Is this expected behaviour? Am I doing something wrong?

IIUC what you did, then yes and yes.

This is the accepted idiom:

#+PROPERTY: header-args :tangle yes

Remember that if you add or change that line you need to update with C-c C-c or `org-mode-restart'.

Maybe you omitted the `header-args'. That used to be correct syntax but was obsoleted some time back.

See (info "(org) Using Header Arguments")

HTH,

Chuck


> 
> Emacs 26.3, Org 9.3.6.
> 
> TIA
> 
> Joost
> 
> 
> -- 
> Joost Kremers
> Life has its moments
> 
> 

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

* :tangle header argument not picked up in #+PROPERTY line or :PROPERTIES: block
@ 2020-03-28 22:00 Joost Kremers
  2020-03-29 17:45 ` Berry, Charles via General discussions about Org-mode.
  0 siblings, 1 reply; 14+ messages in thread
From: Joost Kremers @ 2020-03-28 22:00 UTC (permalink / raw)
  To: emacs-orgmode

Hi list,

I'm having trouble tangling an Org file. Basically, if I put a 
=:tangle= header argument in a =#+PROPERTY= line at the top of the 
file or in a =:PROPERTIES:= block under a header, it is not picked 
up and the code blocks to which (I think) it should apply are not 
tangled. Only when I put a =:tangle= argument at the top of the 
source block itself is the source block tangled.

Is this expected behaviour? Am I doing something wrong?

Emacs 26.3, Org 9.3.6.

TIA

Joost


-- 
Joost Kremers
Life has its moments

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

end of thread, other threads:[~2020-04-01 19:08 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-31  1:01 :tangle header argument not picked up in #+PROPERTY line or :PROPERTIES: block Thomas S. Dye
2020-04-01 19:07 ` Joost Kremers
  -- strict thread matches above, loose matches on Subject: below --
2020-03-28 22:00 Joost Kremers
2020-03-29 17:45 ` Berry, Charles via General discussions about Org-mode.
2020-03-29 20:13   ` Joost Kremers
2020-03-29 20:41     ` Berry, Charles via General discussions about Org-mode.
2020-03-29 22:07       ` Joost Kremers
2020-03-29 22:41         ` Joost Kremers
2020-03-29 23:44           ` Ken Mankoff
2020-03-30 22:23             ` Joost Kremers
2020-03-31  1:08               ` Berry, Charles via General discussions about Org-mode.
2020-03-31 20:04                 ` Joost Kremers
2020-03-31 15:14               ` Ken Mankoff
2020-03-31 19:54                 ` Joost Kremers

Code repositories for project(s) associated with this 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).