Kungsgeten / yankpad

Paste snippets from an org-mode file
MIT License
216 stars 18 forks source link

Snippets can be used to execute functions: can you give some examples? #11

Closed zeltak closed 8 years ago

zeltak commented 8 years ago

Hi

just noticed the changelog that says: Snippets can be used to execute functions

can give some examples for this?

i was just wondering how one can insert an elisp command that will be executed when i insert a yankpad item

for example i envision something like this:

#+NAME: 
#+BEGIN_SRC R :session Rorg :results output graphics :file ~/ELISPINSERTDATE.png

#+END_SRC

where the ELISPINSERTDATE function i wrote will insert the current date. is that possible?

thx

Z

zeltak commented 8 years ago

ok for the second Q found a solution

 #+BEGIN_SRC R :session Rorg :results output graphics :file /home/zeltak/org/attach/bgu/courses/BGU.DM.R/images/`(z-insert-date-time)`.png

works well!

still would love to see examples for the snippet execute unless this is just the option to use elisp as above :)

Kungsgeten commented 8 years ago

You can find an example in the README, also see point 2 under usage. I haven't used the functionality very much myself, so its hard to come up with examples.

I'm not quite sure what you're trying to do. A snippet can execute an org-mode src-block, or an elisp function. There will be no text inserted into the buffer if you do this. However there may be a case for adding functionality to insert the "result" of the src-block into the buffer from where the snippet was run.

Kungsgeten commented 8 years ago

I provide an example of this functionality here: https://kungsgeten.github.io/yankpad13.html