emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* ':post' Direct execution via Emacs Lisp
@ 2015-03-27  8:46 Daimrod
  2015-03-27 13:46 ` John Kitchin
  0 siblings, 1 reply; 4+ messages in thread
From: Daimrod @ 2015-03-27  8:46 UTC (permalink / raw)
  To: emacs-orgmode

Hi,

We can read in the manual:
14.8.2.25 ‘:post’

The ‘:post’ header argument is used to post-process the results of a
code block execution.  When a post argument is given, the results of the
code block will temporarily be bound to the ‘*this*’ variable.  This
variable may then be included in header argument forms such as those
used in *note var:: header argument specifications allowing passing of
results to other code blocks, or direct execution via Emacs Lisp.
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

IIUC, it means that we can post process the data in Emacs Lisp, that is,
by calling an Emacs Lisp function, not another source block. However,
the example only shows how to do it with another source block.

Is my understanding correct or not? If so, how can I post process the
result with an Emacs Lisp function?

Cheers,

-- 
Daimrod/Greg

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

* Re: ':post' Direct execution via Emacs Lisp
  2015-03-27  8:46 ':post' Direct execution via Emacs Lisp Daimrod
@ 2015-03-27 13:46 ` John Kitchin
  2015-03-27 16:31   ` Charles C. Berry
  0 siblings, 1 reply; 4+ messages in thread
From: John Kitchin @ 2015-03-27 13:46 UTC (permalink / raw)
  To: Daimrod; +Cc: emacs-orgmode

I cannot see anyway to use direct execution of emacs lisp code in this
(and nothing I have tried actually works). Any emacs-lisp code seems to
get evaluated before running the block and *this* is not defined then.

As advertised, this works:

#+name: wrap
#+BEGIN_SRC emacs-lisp :var data=""
(concat "====================\n" data "================\n"))
#+END_SRC

#+BEGIN_SRC python :post wrap(*this*)
print 66
#+END_SRC

#+RESULTS:
: ====================
: 66
: ================

But I don't see a way in org-babel-ref-resolve to resolve emacs-lisp as
a :post argument.

Daimrod writes:

> Hi,
>
> We can read in the manual:
> 14.8.2.25 ‘:post’
>
> The ‘:post’ header argument is used to post-process the results of a
> code block execution.  When a post argument is given, the results of the
> code block will temporarily be bound to the ‘*this*’ variable.  This
> variable may then be included in header argument forms such as those
> used in *note var:: header argument specifications allowing passing of
> results to other code blocks, or direct execution via Emacs Lisp.
>                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> IIUC, it means that we can post process the data in Emacs Lisp, that is,
> by calling an Emacs Lisp function, not another source block. However,
> the example only shows how to do it with another source block.
>
> Is my understanding correct or not? If so, how can I post process the
> result with an Emacs Lisp function?
>
> Cheers,

--
tProfessor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu

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

* Re: ':post' Direct execution via Emacs Lisp
  2015-03-27 13:46 ` John Kitchin
@ 2015-03-27 16:31   ` Charles C. Berry
  2015-03-27 19:26     ` John Kitchin
  0 siblings, 1 reply; 4+ messages in thread
From: Charles C. Berry @ 2015-03-27 16:31 UTC (permalink / raw)
  To: John Kitchin; +Cc: Daimrod, emacs-orgmode

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1279 bytes --]

On Fri, 27 Mar 2015, John Kitchin wrote:

> I cannot see anyway to use direct execution of emacs lisp code in this
> (and nothing I have tried actually works). Any emacs-lisp code seems to
> get evaluated before running the block and *this* is not defined then.
>

The quoted part of the manual does suggest that lisp snippets should work 
like `:post (do-something *this*)'

But perhaps *this* (pun intended) is what was meant: an emacs-lisp block 
can refer to `*this*' without needing to pass the value as a header 
argument.


#+NAME: abc
#+BEGIN_SRC emacs-lisp
(concat *this* " and that")
#+END_SRC


#+BEGIN_SRC emacs-lisp :post abc()
"T-H-I-S"
#+END_SRC

#+RESULTS:
: T-H-I-S and that



[snip]

>> We can read in the manual:
>> 14.8.2.25 ‘:post’
>>
>> The ‘:post’ header argument is used to post-process the results of a
>> code block execution.  When a post argument is given, the results of the
>> code block will temporarily be bound to the ‘*this*’ variable.  This
>> variable may then be included in header argument forms such as those
>> used in *note var:: header argument specifications allowing passing of
>> results to other code blocks, or direct execution via Emacs Lisp.
>>                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


Chuck

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

* Re: ':post' Direct execution via Emacs Lisp
  2015-03-27 16:31   ` Charles C. Berry
@ 2015-03-27 19:26     ` John Kitchin
  0 siblings, 0 replies; 4+ messages in thread
From: John Kitchin @ 2015-03-27 19:26 UTC (permalink / raw)
  To: Charles C. Berry; +Cc: Daimrod, emacs-orgmode

that makes sense.

Charles C. Berry writes:

> On Fri, 27 Mar 2015, John Kitchin wrote:
>
>> I cannot see anyway to use direct execution of emacs lisp code in this
>> (and nothing I have tried actually works). Any emacs-lisp code seems to
>> get evaluated before running the block and *this* is not defined then.
>>
>
> The quoted part of the manual does suggest that lisp snippets should work
> like `:post (do-something *this*)'
>
> But perhaps *this* (pun intended) is what was meant: an emacs-lisp block
> can refer to `*this*' without needing to pass the value as a header
> argument.
>
>
> #+NAME: abc
> #+BEGIN_SRC emacs-lisp
> (concat *this* " and that")
> #+END_SRC
>
>
> #+BEGIN_SRC emacs-lisp :post abc()
> "T-H-I-S"
> #+END_SRC
>
> #+RESULTS:
> : T-H-I-S and that
>
>
>
> [snip]
>
>>> We can read in the manual:
>>> 14.8.2.25 ‘:post’
>>>
>>> The ‘:post’ header argument is used to post-process the results of a
>>> code block execution.  When a post argument is given, the results of the
>>> code block will temporarily be bound to the ‘*this*’ variable.  This
>>> variable may then be included in header argument forms such as those
>>> used in *note var:: header argument specifications allowing passing of
>>> results to other code blocks, or direct execution via Emacs Lisp.
>>>                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
>
> Chuck

--
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu

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

end of thread, other threads:[~2015-03-27 19:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-27  8:46 ':post' Direct execution via Emacs Lisp Daimrod
2015-03-27 13:46 ` John Kitchin
2015-03-27 16:31   ` Charles C. Berry
2015-03-27 19:26     ` John Kitchin

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