emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [BUG] :colnames not applied to #+call input
@ 2013-06-28 17:23 Rick Frankel
  2013-06-30 23:21 ` Eric Schulte
  0 siblings, 1 reply; 5+ messages in thread
From: Rick Frankel @ 2013-06-28 17:23 UTC (permalink / raw)
  To: emacs-orgmode

it seems that the :colnames header is not being respected on parsing the 
input
to a `#+call:' line containing arguments, but is being applied to the 
output!

For example:

#+BEGIN_SRC org
* Identity
#+name: table
| a | b | c |
|---+---+---|
| 1 | 2 | 3 |

#+name: identity
#+BEGIN_SRC emacs-lisp :var table=table :colnames yes
	(mapcar 'identity table)
#+END_SRC

#+RESULTS: identity
| a | b | c |
|---+---+---|
| 1 | 2 | 3 |


#+call: identity()

#+RESULTS: identity()
| a | b | c |
|---+---+---|
| 1 | 2 | 3 |

#+call: identity(table=table)

#+RESULTS: identity(table=table)
| a | b | c |
|---+---+---|
| a | b | c |
|---+---+---|
| 1 | 2 | 3 |

* Mapping
#+name: map
#+BEGIN_SRC emacs-lisp :var table=table :colnames yes
	(mapcar (lambda (row) (mapcar 'identity row)) table)
#+END_SRC

#+RESULTS: map
| a | b | c |
|---+---+---|
| 1 | 2 | 3 |

#+call: map()

#+RESULTS: map()
| a | b | c |
|---+---+---|
| 1 | 2 | 3 |

All the following generate the error:

	 /Wrong type argument: sequencep, hline/

because the header and hline are not stripped from the input.

#+call: map(table=table)

#+call: map(table=table) :colnames yes

#+call: map[:colnames yes](table=table) :colnames yes

#+END_SRC

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

* Re: [BUG] :colnames not applied to #+call input
  2013-06-28 17:23 [BUG] :colnames not applied to #+call input Rick Frankel
@ 2013-06-30 23:21 ` Eric Schulte
  2013-07-02 14:32   ` Rick Frankel
  0 siblings, 1 reply; 5+ messages in thread
From: Eric Schulte @ 2013-06-30 23:21 UTC (permalink / raw)
  To: Rick Frankel; +Cc: emacs-orgmode

Rick Frankel <rick@rickster.com> writes:

> it seems that the :colnames header is not being respected on parsing the 
> input
> to a `#+call:' line containing arguments, but is being applied to the 
> output!
>
> For example:
>
> #+BEGIN_SRC org
> * Identity
> #+name: table
> | a | b | c |
> |---+---+---|
> | 1 | 2 | 3 |
>
> #+name: identity
> #+BEGIN_SRC emacs-lisp :var table=table :colnames yes
> 	(mapcar 'identity table)
> #+END_SRC

Emacs Lisp handles the :colnames header argument differently than other
languages, hence the "Note that the behavior of the ':colnames' header
argument may differ across languages." phrase in the manual.  If you
remove ":colnames yes" from the emacs-lisp code block in your example
everything should work fine.

Best,

-- 
Eric Schulte
http://cs.unm.edu/~eschulte

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

* Re: [BUG] :colnames not applied to #+call input
  2013-06-30 23:21 ` Eric Schulte
@ 2013-07-02 14:32   ` Rick Frankel
  2013-07-03 17:23     ` Eric Schulte
  0 siblings, 1 reply; 5+ messages in thread
From: Rick Frankel @ 2013-07-02 14:32 UTC (permalink / raw)
  To: Eric Schulte; +Cc: emacs-orgmode

On 2013-06-30 19:21, Eric Schulte wrote:
> Rick Frankel <rick@rickster.com> writes:
> 
> it seems that the :colnames header is not being respected on parsing 
> the
> input
> to a `#+call:' line containing arguments, but is being applied to the
> output!
> 
> For example:
> 
> #+BEGIN_SRC org
> * Identity
> #+name: table
> | a | b | c |
> |---+---+---|
> | 1 | 2 | 3 |
> 
> #+name: identity
> #+BEGIN_SRC emacs-lisp :var table=table :colnames yes
> (mapcar 'identity table)
> #+END_SRC
> 
> Emacs Lisp handles the :colnames header argument differently than other
> languages, hence the "Note that the behavior of the ':colnames' header
> argument may differ across languages." phrase in the manual.  If you
> remove ":colnames yes" from the emacs-lisp code block in your example
> everything should work fine.

I understand the differing handling of ':colnames' in different
langauages, but you "solution" does not address the issue of not being
able to call the block. It would mean handling the header and
hline in the called block in all cases. The problem i am addressing is
that the :colnames argument to the original source block is being
applied on the reassembly of the output regardless of the value of the
:colnames argument to the call line. This is a regresssion since 7.9
(see the 7.9 example at the end of this message). Let's try a
different example to make the issue clearer.


Given the same table, and the method:

#+name: map
#+BEGIN_SRC emacs-lisp :var table=table :colnames yes
(mapcar (lambda (row) (mapcar '1+ row)) table)
#+END_SRC

The results are:

#+RESULTS: map
| a | b | c |
|---+---+---|
| 2 | 3 | 4 |


If I call the function w/o a table argument i get the same results.
However, if i try to pass the table argument, i get the following
errors:

/mapcar: Wrong type argument: number-or-marker-p, "a"/ on:

#+call: map(table=table)
#+call: map(table=table) :colnames yes
#+call: map[:colnames yes](table=table) :colnames yes

/Wrong type argument: sequencep, 1/ on:

#+call: map(table=table[2:-1])

(since the (now one row) table is turned into a list.

So there is no way to call this function with a single-row table as an
argument.

If we have the following table instead:

#+name: table2
| a | b | c |
|---+---+---|
| 1 | 2 | 3 |
| 4 | 5 | 6 |

we get:

#+name: map2
#+BEGIN_SRC emacs-lisp :var table=table2 :colnames yes
(mapcar (lambda (row) (mapcar '1+ row)) table)
#+END_SRC

#+RESULTS: map2
| a | b | c |
|---+---+---|
| 2 | 3 | 4 |
| 5 | 6 | 7 |

#+call: map2(x="")

#+RESULTS: map2(x="")
| a | b | c |
|---+---+---|
| 2 | 3 | 4 |
| 5 | 6 | 7 |

#+call: map(table=table2[2:-1])

#+RESULTS: map(table=table2[2:-1])
| a | b | c |
|---+---+---|
| 2 | 3 | 4 |
| 5 | 6 | 7 |


which looks right, but we shouldn't have any header on the above
results as we have (supposedly) stripped it from the input with the
slice).

Here' are the results from 7.9.3f. Note that calling the source block
with a single row table is still impossible in 7.9, as the slice is
still turned into a list, and the :colnames argument is also not being
applied to the input (but is only being applied to the output if
specified in the call line):

#+name: map2
#+BEGIN_SRC emacs-lisp :var table=table2 :colnames yes
(mapcar (lambda (row) (mapcar '1+ row)) table)
#+END_SRC

#+RESULTS: map2
| a | b | c |
|---+---+---|
| 2 | 3 | 4 |
| 5 | 6 | 7 |

#+call: map2(x="")

#+RESULTS: map2(x="")
| 2 | 3 | 4 |
| 5 | 6 | 7 |

#+call: map2(x="") :colnames yes

#+RESULTS: map2(x=""):colnames yes
| a | b | c |
|---+---+---|
| 2 | 3 | 4 |
| 5 | 6 | 7 |

#+call: map(table=table2[2:-1])

#+RESULTS: map(table=table2[2:-1])
| 2 | 3 | 4 |
| 5 | 6 | 7 |

#+call: map(table=table2[2:-1]) :colnames yes

#+RESULTS: map(table=table2[2:-1]):colnames yes
| a | b | c |
|---+---+---|
| 2 | 3 | 4 |
| 5 | 6 | 7 |

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

* Re: [BUG] :colnames not applied to #+call input
  2013-07-02 14:32   ` Rick Frankel
@ 2013-07-03 17:23     ` Eric Schulte
  2013-07-09 15:29       ` Rick Frankel
  0 siblings, 1 reply; 5+ messages in thread
From: Eric Schulte @ 2013-07-03 17:23 UTC (permalink / raw)
  To: Rick Frankel; +Cc: emacs-orgmode, Eric Schulte

Currently colnames are not used for emacs-lisp code blocks (for
historical reasons).  Unfortunately, call lines are executed by
expanding first to a trivial emacs-lisp code block, which is then run to
collect and possibly re-package the results of the called function.
Thus colnames do not work well in call lines.

I think the best solution here is to add colnames support to Emacs Lisp
code blocks.  I can put this on my Org-mode queue, but can't promise to
get to it any time soon.

Cheers,

Rick Frankel <rick@rickster.com> writes:

> On 2013-06-30 19:21, Eric Schulte wrote:
>> Rick Frankel <rick@rickster.com> writes:
>> 
>> it seems that the :colnames header is not being respected on parsing 
>> the
>> input
>> to a `#+call:' line containing arguments, but is being applied to the
>> output!
>> 
>> For example:
>> 
>> #+BEGIN_SRC org
>> * Identity
>> #+name: table
>> | a | b | c |
>> |---+---+---|
>> | 1 | 2 | 3 |
>> 
>> #+name: identity
>> #+BEGIN_SRC emacs-lisp :var table=table :colnames yes
>> (mapcar 'identity table)
>> #+END_SRC
>> 
>> Emacs Lisp handles the :colnames header argument differently than other
>> languages, hence the "Note that the behavior of the ':colnames' header
>> argument may differ across languages." phrase in the manual.  If you
>> remove ":colnames yes" from the emacs-lisp code block in your example
>> everything should work fine.
>
> I understand the differing handling of ':colnames' in different
> langauages, but you "solution" does not address the issue of not being
> able to call the block. It would mean handling the header and
> hline in the called block in all cases. The problem i am addressing is
> that the :colnames argument to the original source block is being
> applied on the reassembly of the output regardless of the value of the
> :colnames argument to the call line. This is a regresssion since 7.9
> (see the 7.9 example at the end of this message). Let's try a
> different example to make the issue clearer.
>
>
> Given the same table, and the method:
>
> #+name: map
> #+BEGIN_SRC emacs-lisp :var table=table :colnames yes
> (mapcar (lambda (row) (mapcar '1+ row)) table)
> #+END_SRC
>
> The results are:
>
> #+RESULTS: map
> | a | b | c |
> |---+---+---|
> | 2 | 3 | 4 |
>
>
> If I call the function w/o a table argument i get the same results.
> However, if i try to pass the table argument, i get the following
> errors:
>
> /mapcar: Wrong type argument: number-or-marker-p, "a"/ on:
>
> #+call: map(table=table)
> #+call: map(table=table) :colnames yes
> #+call: map[:colnames yes](table=table) :colnames yes
>
> /Wrong type argument: sequencep, 1/ on:
>
> #+call: map(table=table[2:-1])
>
> (since the (now one row) table is turned into a list.
>
> So there is no way to call this function with a single-row table as an
> argument.
>
> If we have the following table instead:
>
> #+name: table2
> | a | b | c |
> |---+---+---|
> | 1 | 2 | 3 |
> | 4 | 5 | 6 |
>
> we get:
>
> #+name: map2
> #+BEGIN_SRC emacs-lisp :var table=table2 :colnames yes
> (mapcar (lambda (row) (mapcar '1+ row)) table)
> #+END_SRC
>
> #+RESULTS: map2
> | a | b | c |
> |---+---+---|
> | 2 | 3 | 4 |
> | 5 | 6 | 7 |
>
> #+call: map2(x="")
>
> #+RESULTS: map2(x="")
> | a | b | c |
> |---+---+---|
> | 2 | 3 | 4 |
> | 5 | 6 | 7 |
>
> #+call: map(table=table2[2:-1])
>
> #+RESULTS: map(table=table2[2:-1])
> | a | b | c |
> |---+---+---|
> | 2 | 3 | 4 |
> | 5 | 6 | 7 |
>
>
> which looks right, but we shouldn't have any header on the above
> results as we have (supposedly) stripped it from the input with the
> slice).
>
> Here' are the results from 7.9.3f. Note that calling the source block
> with a single row table is still impossible in 7.9, as the slice is
> still turned into a list, and the :colnames argument is also not being
> applied to the input (but is only being applied to the output if
> specified in the call line):
>
> #+name: map2
> #+BEGIN_SRC emacs-lisp :var table=table2 :colnames yes
> (mapcar (lambda (row) (mapcar '1+ row)) table)
> #+END_SRC
>
> #+RESULTS: map2
> | a | b | c |
> |---+---+---|
> | 2 | 3 | 4 |
> | 5 | 6 | 7 |
>
> #+call: map2(x="")
>
> #+RESULTS: map2(x="")
> | 2 | 3 | 4 |
> | 5 | 6 | 7 |
>
> #+call: map2(x="") :colnames yes
>
> #+RESULTS: map2(x=""):colnames yes
> | a | b | c |
> |---+---+---|
> | 2 | 3 | 4 |
> | 5 | 6 | 7 |
>
> #+call: map(table=table2[2:-1])
>
> #+RESULTS: map(table=table2[2:-1])
> | 2 | 3 | 4 |
> | 5 | 6 | 7 |
>
> #+call: map(table=table2[2:-1]) :colnames yes
>
> #+RESULTS: map(table=table2[2:-1]):colnames yes
> | a | b | c |
> |---+---+---|
> | 2 | 3 | 4 |
> | 5 | 6 | 7 |
>
>
>
>

-- 
Eric Schulte
http://cs.unm.edu/~eschulte

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

* Re: [BUG] :colnames not applied to #+call input
  2013-07-03 17:23     ` Eric Schulte
@ 2013-07-09 15:29       ` Rick Frankel
  0 siblings, 0 replies; 5+ messages in thread
From: Rick Frankel @ 2013-07-09 15:29 UTC (permalink / raw)
  To: Eric Schulte; +Cc: emacs-orgmode

On 2013-07-03 13:23, Eric Schulte wrote:
> Currently colnames are not used for emacs-lisp code blocks (for
> historical reasons).  Unfortunately, call lines are executed by
> expanding first to a trivial emacs-lisp code block, which is then run 
> to
> collect and possibly re-package the results of the called function.
> Thus colnames do not work well in call lines.
> 
> I think the best solution here is to add colnames support to Emacs Lisp
> code blocks.  I can put this on my Org-mode queue, but can't promise to
> get to it any time soon.

I'm confused by this response, as the behavior exhibited by org-mode
seems to indicate that :colnames IS affecting emacs-lisp code blocks,
but inconsistenly affecting "called" code blocks -- only applying to the
output but not the input as exhibited in an example in a previous
email.  As to the above, given:

#+name: table1
| 1 | 2 | 3 |
|---+---+---|
| 4 | 5 | 6 |

and the code:

#+name: map1
#+BEGIN_SRC emacs-lisp :var table=table1 :colnames yes
(mapcar (lambda (row) (mapcar '1+ row)) table)
#+END_SRC

I get:

#+RESULTS: map1
| 1 | 2 | 3 |
|---+---+---|
| 5 | 6 | 7 |

and the `*Message*' buffer contains:
#+BEGIN_EXAMPLE
executing Emacs-Lisp code block (map1)...

(table (quote ((4 5 6))))

Code block evaluation complete.
#+END_EXAMPLE

But, removing the :colnames argument:

#+name: map2
#+BEGIN_SRC emacs-lisp :var table=table1
(mapcar (lambda (row) (mapcar '1+ row)) table)
#+END_SRC

give the error "Wrong type argument: sequencep, hline", and the
message buffer shows:

#+BEGIN_EXAMPLE
executing Emacs-Lisp code block (map2)...

(table (quote ((1 2 3) hline (4 5 6))))

Wrong type argument: sequencep, hline
#+END_EXAMPLE

Finally,

#+name: mapp:
#+BEGIN_SRC emacs-lisp :var table=table1
(mapcar (lambda (row) (if (listp row) (mapcar '1+ row) row)) table)
#+END_SRC

#+RESULTS: mapp:
| 2 | 3 | 4 |
|---+---+---|
| 5 | 6 | 7 |

and the message buffer contains:

#+BEGIN_EXAMPLE
executing Emacs-Lisp code block (mapp:)...

(table (quote ((1 2 3) hline (4 5 6))))

Code block evaluation complete.
#+END_EXAMPLE


#+name: call1
#+call: map1()

works:

#+RESULTS: call1
| 1 | 2 | 3 |
|---+---+---|
| 5 | 6 | 7 |


with the message:

#+BEGIN_EXAMPLE
executing Emacs-Lisp code block (map1)...

(table (quote ((4 5 6))))

((1 2 3) hline (5 6 7))
executing Emacs-Lisp code block (call1)...

(results (quote ((1 2 3) hline (5 6 7))))

Code block evaluation complete.
#+END_EXAMPLE
but:
#+name: call2
#+call: map1(table=table1)

Generates the following message:

#+BEGIN_EXAMPLE
executing Emacs-Lisp code block (map1)...

(table (quote ((4 5 6))))

((1 2 3) hline (5 6 7))
executing Emacs-Lisp code block (call1)...

(results (quote ((1 2 3) hline (5 6 7))))

Code block evaluation complete.
Mark set [2 times]
#+END_EXAMPLE

rick

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

end of thread, other threads:[~2013-07-09 15:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-28 17:23 [BUG] :colnames not applied to #+call input Rick Frankel
2013-06-30 23:21 ` Eric Schulte
2013-07-02 14:32   ` Rick Frankel
2013-07-03 17:23     ` Eric Schulte
2013-07-09 15:29       ` Rick Frankel

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