emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Export Dispatcher Insert Template Not Working?
@ 2014-01-31 16:50 Soapy Smith
  2014-01-31 17:04 ` Bastien
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Soapy Smith @ 2014-01-31 16:50 UTC (permalink / raw)
  To: emacs-orgmode

Hello, I'm having trouble with the export dispatcher not inserting a
template.  I'm not sure I'm entering the commands correctly.  I am
attempting to insert the template for LaTeX.


Here are the 2 different attempts which fail:

C-c C-e   (successfully opens the dispatcher buffer)

l # l ret

In mini-buffer:  "Wrong type argument: arrayp, nil"

or

# l ret

Same error in mini-buffer:  "Wrong type argument: arrayp, nil"

Am I entering the commands incorrectly?

Regards,
Greg

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

* Re: Export Dispatcher Insert Template Not Working?
  2014-01-31 16:50 Export Dispatcher Insert Template Not Working? Soapy Smith
@ 2014-01-31 17:04 ` Bastien
  2014-01-31 21:05   ` Soapy Smith
  2014-01-31 21:24 ` Python Code Block error with header option :results output Soapy Smith
  2014-01-31 21:45 ` Code block option :results raw does not replace #+RESULTS Soapy Smith
  2 siblings, 1 reply; 12+ messages in thread
From: Bastien @ 2014-01-31 17:04 UTC (permalink / raw)
  To: Soapy Smith; +Cc: emacs-orgmode

Hi Greg,

Soapy Smith <soapy-smith@comcast.net> writes:

> Hello, I'm having trouble with the export dispatcher not inserting a
> template.  I'm not sure I'm entering the commands correctly.  I am
> attempting to insert the template for LaTeX.
>
>
> Here are the 2 different attempts which fail:
>
> C-c C-e   (successfully opens the dispatcher buffer)
>
> l # l ret

You need

l # l TAB RET

I push a change in master which make

l # l RET

work now.

Let me know,

-- 
 Bastien

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

* Re: Export Dispatcher Insert Template Not Working?
  2014-01-31 17:04 ` Bastien
@ 2014-01-31 21:05   ` Soapy Smith
  0 siblings, 0 replies; 12+ messages in thread
From: Soapy Smith @ 2014-01-31 21:05 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode

Thank you Bastien, the change is confirmed working!

Regards,
Greg


On Fri, 2014-01-31 at 18:04 +0100, Bastien wrote:
> Hi Greg,
> 
> Soapy Smith <soapy-smith@comcast.net> writes:
> 
> > Hello, I'm having trouble with the export dispatcher not inserting a
> > template.  I'm not sure I'm entering the commands correctly.  I am
> > attempting to insert the template for LaTeX.
> >
> >
> > Here are the 2 different attempts which fail:
> >
> > C-c C-e   (successfully opens the dispatcher buffer)
> >
> > l # l ret
> 
> You need
> 
> l # l TAB RET
> 
> I push a change in master which make
> 
> l # l RET
> 
> work now.
> 
> Let me know,
> 

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

* Python Code Block error with header option :results output
  2014-01-31 16:50 Export Dispatcher Insert Template Not Working? Soapy Smith
  2014-01-31 17:04 ` Bastien
@ 2014-01-31 21:24 ` Soapy Smith
  2014-01-31 21:33   ` Ahmadou Dicko
  2014-01-31 21:33   ` Eric Schulte
  2014-01-31 21:45 ` Code block option :results raw does not replace #+RESULTS Soapy Smith
  2 siblings, 2 replies; 12+ messages in thread
From: Soapy Smith @ 2014-01-31 21:24 UTC (permalink / raw)
  To: emacs-orgmode

Hello-

I am not a user of Python (yet).  During a comparison of code block
behavior between Clojure and Python, I discovered a possible Python
error.

Here is the code block:

#+begin_src python :results output
 a = (1, 2, 3, 4)
 return a
#+end_src

The evaluation of this block results in this error:

  File "<stdin>", line 2
SyntaxError: 'return' outside function

Could someone please comment if this is expected Python behavior?

I am using org 8.2.4.

Regards,
Greg

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

* Re: Python Code Block error with header option :results output
  2014-01-31 21:24 ` Python Code Block error with header option :results output Soapy Smith
@ 2014-01-31 21:33   ` Ahmadou Dicko
  2014-01-31 21:33   ` Eric Schulte
  1 sibling, 0 replies; 12+ messages in thread
From: Ahmadou Dicko @ 2014-01-31 21:33 UTC (permalink / raw)
  To: Soapy Smith; +Cc: emacs-orgmode

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

I'm not a Python expert too but I don't that return statement can be used
as is on the fly.
So, yes is the expected behavior of Python

Try instead

#+begin_src python :results output
  a = (1, 2, 3, 4)
  print(a)
#+end_src

#+RESULTS:
: (1, 2, 3, 4)



On Fri, Jan 31, 2014 at 9:24 PM, Soapy Smith <soapy-smith@comcast.net>wrote:

> Hello-
>
> I am not a user of Python (yet).  During a comparison of code block
> behavior between Clojure and Python, I discovered a possible Python
> error.
>
> Here is the code block:
>
> #+begin_src python :results output
>  a = (1, 2, 3, 4)
>  return a
> #+end_src
>
> The evaluation of this block results in this error:
>
>   File "<stdin>", line 2
> SyntaxError: 'return' outside function
>
> Could someone please comment if this is expected Python behavior?
>
> I am using org 8.2.4.
>
> Regards,
> Greg
>
>
>


-- 
Ahmadou H. DICKO
statistician economist (Ingénieur Statisticien Économiste)
PhD candidate in Climate change economics
Faculty of economics and managment - Cheikh Anta Diop University
West African Science Service Center on Climate Change and Adaptated Land
Use (WASCAL)
Center for Development Research (ZEF) - University of Bonn
email : ahmadou.dicko@ucad.edu.sn
twitter : @dickoah
github : github/dickoa <https://github.com/dickoa>
tel : +221 33 827 55 16
portable: +221 77 123 81 69

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

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

* Re: Python Code Block error with header option :results output
  2014-01-31 21:24 ` Python Code Block error with header option :results output Soapy Smith
  2014-01-31 21:33   ` Ahmadou Dicko
@ 2014-01-31 21:33   ` Eric Schulte
  2014-02-01  6:56     ` Christian Moe
  1 sibling, 1 reply; 12+ messages in thread
From: Eric Schulte @ 2014-01-31 21:33 UTC (permalink / raw)
  To: Soapy Smith; +Cc: emacs-orgmode

Soapy Smith <soapy-smith@comcast.net> writes:

> Hello-
>
> I am not a user of Python (yet).  During a comparison of code block
> behavior between Clojure and Python, I discovered a possible Python
> error.
>
> Here is the code block:
>
> #+begin_src python :results output
>  a = (1, 2, 3, 4)
>  return a
> #+end_src
>
> The evaluation of this block results in this error:
>
>   File "<stdin>", line 2
> SyntaxError: 'return' outside function
>
> Could someone please comment if this is expected Python behavior?
>

You should only use "return" like that in a python code block when you
have ":results value".

>
> I am using org 8.2.4.
>
> Regards,
> Greg
>
>

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D

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

* Code block option :results raw does not replace #+RESULTS
  2014-01-31 16:50 Export Dispatcher Insert Template Not Working? Soapy Smith
  2014-01-31 17:04 ` Bastien
  2014-01-31 21:24 ` Python Code Block error with header option :results output Soapy Smith
@ 2014-01-31 21:45 ` Soapy Smith
  2014-01-31 21:54   ` John Hendy
  2014-01-31 23:16   ` Nick Dokos
  2 siblings, 2 replies; 12+ messages in thread
From: Soapy Smith @ 2014-01-31 21:45 UTC (permalink / raw)
  To: emacs-orgmode

Hello-

Here is an example Python code block:

#+begin_src python :results value raw
 a = (1, 2, 3, 4)
 return a
#+end_src

#+RESULTS:
(1, 2, 3, 4)
(1, 2, 3, 4)

The #+RESULT block above is after 2 evaluations.
The default behavior of "replace" is not happening.  The result "stack"
will continue to grow with additional evaluations.

I also confirmed the same behavior with a Clojure code block.

Is this the expected behavior for this option?

Regards,
Greg

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

* Re: Code block option :results raw does not replace #+RESULTS
  2014-01-31 21:45 ` Code block option :results raw does not replace #+RESULTS Soapy Smith
@ 2014-01-31 21:54   ` John Hendy
  2014-01-31 23:16   ` Nick Dokos
  1 sibling, 0 replies; 12+ messages in thread
From: John Hendy @ 2014-01-31 21:54 UTC (permalink / raw)
  To: Soapy Smith; +Cc: emacs-orgmode

On Fri, Jan 31, 2014 at 3:45 PM, Soapy Smith <soapy-smith@comcast.net> wrote:
> Hello-
>
> Here is an example Python code block:
>
> #+begin_src python :results value raw
>  a = (1, 2, 3, 4)
>  return a
> #+end_src
>
> #+RESULTS:
> (1, 2, 3, 4)
> (1, 2, 3, 4)
>
> The #+RESULT block above is after 2 evaluations.
> The default behavior of "replace" is not happening.  The result "stack"
> will continue to grow with additional evaluations.
>

I was going to suggest using a #+name line above #+begin_src... but
with :results value raw, I was getting the same behavior.

With :results output, it works properly when I replace =return a= with
=print(a)=. Does =output= not work for you, requiring =value raw= (at
least thinking it could help you in the immediate future). Someone
else will need to chime in on the behavior of =value raw=

#+begin_src python :results output
a = (1, 2, 3, 4)
print(a)
#+end_src

#+RESULTS:
: (1, 2, 3, 4)

I can C-c C-c on that block repeatedly and it does not grow.


John




John

> I also confirmed the same behavior with a Clojure code block.
>
> Is this the expected behavior for this option?
>
> Regards,
> Greg
>
>

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

* Re: Code block option :results raw does not replace #+RESULTS
  2014-01-31 21:45 ` Code block option :results raw does not replace #+RESULTS Soapy Smith
  2014-01-31 21:54   ` John Hendy
@ 2014-01-31 23:16   ` Nick Dokos
  2014-02-01 12:01     ` Soapy Smith
  1 sibling, 1 reply; 12+ messages in thread
From: Nick Dokos @ 2014-01-31 23:16 UTC (permalink / raw)
  To: emacs-orgmode

Soapy Smith <soapy-smith@comcast.net> writes:

> Hello-
>
> Here is an example Python code block:
>
> #+begin_src python :results value raw
>  a = (1, 2, 3, 4)
>  return a
> #+end_src
>
> #+RESULTS:
> (1, 2, 3, 4)
> (1, 2, 3, 4)
>
> The #+RESULT block above is after 2 evaluations.
> The default behavior of "replace" is not happening.  The result "stack"
> will continue to grow with additional evaluations.
>
> I also confirmed the same behavior with a Clojure code block.
>
> Is this the expected behavior for this option?
>

Yes - raw does not keep track of where the results begin and end and
cannot erase the old ones before adding the new ones. Try
calling org-babel-remove-result: you'll see that it gets rid of the
#+RESULTS: line but it doesn't touch the actual results. Once it has
inserted them, they become part of the buffer, outside the jurisdiction
of the code block/babel.

Nick

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

* Re: Python Code Block error with header option :results output
  2014-01-31 21:33   ` Eric Schulte
@ 2014-02-01  6:56     ` Christian Moe
  2014-02-01 12:34       ` Soapy Smith
  0 siblings, 1 reply; 12+ messages in thread
From: Christian Moe @ 2014-02-01  6:56 UTC (permalink / raw)
  To: Eric Schulte; +Cc: Soapy Smith, emacs-orgmode


Eric Schulte writes:

> Soapy Smith <soapy-smith@comcast.net> writes:
>
>> Hello-
>>
>> I am not a user of Python (yet).  During a comparison of code block
>> behavior between Clojure and Python, I discovered a possible Python
>> error.
>>
>> Here is the code block:
>>
>> #+begin_src python :results output
>>  a = (1, 2, 3, 4)
>>  return a
>> #+end_src
>>
>> The evaluation of this block results in this error:
>>
>>   File "<stdin>", line 2
>> SyntaxError: 'return' outside function
>>
>> Could someone please comment if this is expected Python behavior?
>>
>
> You should only use "return" like that in a python code block when you
> have ":results value".

To expand briefly on that (since this can be perplexing): 

The need to use `return' at all when returning the value is a special
quirk of Python code blocks, and does not apply to (any?) other languages.

As explained on Worg, with `:results value' (the default), 

"Internally, the value is obtained by wrapping the code in a function
definition in the external language, and evaluating that
function. Therefore, code should be written as if it were the body of
such a function. In particular, note that Python does not automatically
return a value from a function unless a return statement is present, and
so a ‘return’ statement will usually be required in Python."

http://orgmode.org/manual/Results-of-evaluation.html

So when using `:results output', using `return' causes an error
because there is no function to return anything from.

Yours,
Christian 

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

* Re: Code block option :results raw does not replace #+RESULTS
  2014-01-31 23:16   ` Nick Dokos
@ 2014-02-01 12:01     ` Soapy Smith
  0 siblings, 0 replies; 12+ messages in thread
From: Soapy Smith @ 2014-02-01 12:01 UTC (permalink / raw)
  To: Nick Dokos; +Cc: emacs-orgmode

On Fri, 2014-01-31 at 18:16 -0500, Nick Dokos wrote:
> > Is this the expected behavior for this option?
> >
> 
> Yes - raw does not keep track of where the results begin and end and
> cannot erase the old ones before adding the new ones. Try
> calling org-babel-remove-result: you'll see that it gets rid of the
> #+RESULTS: line but it doesn't touch the actual results. Once it has
> inserted them, they become part of the buffer, outside the jurisdiction
> of the code block/babel.
> 
> Nick

That makes sense as I don't see the #RESULTS: line repeated.

I'm adding that to my notes.  Thank you for the explanation!

Regards,
Greg

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

* Re: Python Code Block error with header option :results output
  2014-02-01  6:56     ` Christian Moe
@ 2014-02-01 12:34       ` Soapy Smith
  0 siblings, 0 replies; 12+ messages in thread
From: Soapy Smith @ 2014-02-01 12:34 UTC (permalink / raw)
  To: Christian Moe; +Cc: emacs-orgmode, Eric Schulte

On Sat, 2014-02-01 at 07:56 +0100, Christian Moe wrote:
> > You should only use "return" like that in a python code block when you
> > have ":results value".
> 
> To expand briefly on that (since this can be perplexing): 
> 
> The need to use `return' at all when returning the value is a special
> quirk of Python code blocks, and does not apply to (any?) other languages.
> 
> As explained on Worg, with `:results value' (the default), 
> 
> "Internally, the value is obtained by wrapping the code in a function
> definition in the external language, and evaluating that
> function. Therefore, code should be written as if it were the body of
> such a function. In particular, note that Python does not automatically
> return a value from a function unless a return statement is present, and
> so a ‘return’ statement will usually be required in Python."
> 
> http://orgmode.org/manual/Results-of-evaluation.html
> 
> So when using `:results output', using `return' causes an error
> because there is no function to return anything from.
> 
> Yours,
> Christian 

Thank you Christian for the detailed explanation.  It is indeed
perplexing at first!

Regards,
Greg

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

end of thread, other threads:[~2014-02-01 12:35 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-31 16:50 Export Dispatcher Insert Template Not Working? Soapy Smith
2014-01-31 17:04 ` Bastien
2014-01-31 21:05   ` Soapy Smith
2014-01-31 21:24 ` Python Code Block error with header option :results output Soapy Smith
2014-01-31 21:33   ` Ahmadou Dicko
2014-01-31 21:33   ` Eric Schulte
2014-02-01  6:56     ` Christian Moe
2014-02-01 12:34       ` Soapy Smith
2014-01-31 21:45 ` Code block option :results raw does not replace #+RESULTS Soapy Smith
2014-01-31 21:54   ` John Hendy
2014-01-31 23:16   ` Nick Dokos
2014-02-01 12:01     ` Soapy Smith

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