emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* shell scripts in yasnippet?
@ 2015-09-03 15:06 Tobias Frischholz
  2015-09-04 13:20 ` John Kitchin
  0 siblings, 1 reply; 3+ messages in thread
From: Tobias Frischholz @ 2015-09-03 15:06 UTC (permalink / raw)
  To: Org Mode Mailing List

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

Hi there,

right now I’m tinkering around with yasnippet.
I was wondering if there’s a possibility to run a shell script and write its results in the text file.

Specifically, I’m want to run “fortune” and put the results in a #+BEGIN_QUOTE…#+END_QUOTE block.
Would that be possible?
Best regards,
Tobias Frischholz

PGP PUBLIC KEY: http://pgp.mit.edu/pks/lookup?search=0xCD463AC1&op=index


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

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

* Re: shell scripts in yasnippet?
  2015-09-03 15:06 shell scripts in yasnippet? Tobias Frischholz
@ 2015-09-04 13:20 ` John Kitchin
       [not found]   ` <26CFED0F-553B-4E68-9006-E2A705FE8903@friolz.com>
  0 siblings, 1 reply; 3+ messages in thread
From: John Kitchin @ 2015-09-04 13:20 UTC (permalink / raw)
  To: Tobias Frischholz; +Cc: Org Mode Mailing List

This is kind of close:

#+BEGIN_SRC emacs-lisp
(yas-global-mode)
(with-temp-buffer
  (insert "# name : my-fortune
# key: myf
# expand-env: ((yas-indent-line nil)
# --

#+BEGIN_QUOTE:
${1:`(shell-command-to-string \"fortune\")`}
#END_QUOTE

$0
")
  (yas-load-snippet-buffer-and-close 'org-mode))
#+END_SRC

For some reason it is inserting some extra spaces before # for me, and I
cannot figure out why.

Tobias Frischholz writes:

> Hi there,
>
> right now I’m tinkering around with yasnippet.
> I was wondering if there’s a possibility to run a shell script and write its results in the text file.
>
> Specifically, I’m want to run “fortune” and put the results in a #+BEGIN_QUOTE…#+END_QUOTE block.
> Would that be possible?
> Best regards,
> Tobias Frischholz
>
> PGP PUBLIC KEY: http://pgp.mit.edu/pks/lookup?search=0xCD463AC1&op=index

--
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] 3+ messages in thread

* Re: shell scripts in yasnippet?
       [not found]           ` <7522ECBF-F9AB-4262-B6AF-58536E6C4D45@friolz.com>
@ 2015-09-06 16:34             ` John Kitchin
  0 siblings, 0 replies; 3+ messages in thread
From: John Kitchin @ 2015-09-06 16:34 UTC (permalink / raw)
  To: Tobias Frischholz; +Cc: emacs-orgmode@gnu.org

This will not work. That is not what yasnippets are for. What you want
is more like this:

http://kitchingroup.cheme.cmu.edu/blog/2013/10/14/Lisp-links-in-org-mode-to-dynamically-generated-content/

Or this:
* test fortune


#+BEGIN_SRC emacs-lisp :exports results :results org
(format "#+BEGIN_QUOTE:
%s
,#+END_QUOTE
" (shell-command-to-string "fortune"))
#+END_SRC

#+BEGIN_SRC emacs-lisp :exports none
(let ((org-export-babel-evaluate t))
  (browse-url (org-html-export-to-html nil t)))
#+END_SRC



Tobias Frischholz writes:

> On 05 Sep 2015, at 00:19, John Kitchin <jkitchin@andrew.cmu.edu> wrote:
>>
>> That code worked verbatim for me running it from the src block. You may not need the escaped quotes the way you are doing it.
>
> I tried to adopt it this way:
>
> #+TITLE: Wochenplan KW37
> #+AUTHOR: Tobias Frischholz
> #+OPTIONS: toc:nil
> #+LATEX_CLASS_OPTIONS: [a4paper]
> #+LATEX_HEADER: \usepackage[german]{isodate}
>
> #+BEGIN_SRC emacs-lisp
> #+BEGIN_QUOTE:
> ${1:`(shell-command-to-string "fortune")`}
> #+END_QUOTE
> #+END_SRC
>
> * Stundenplan
>
>   |----------------+--------------+-----------+------------+---------|
>   | Montag         | Dienstag     | Mittwoch  | Donnerstag | Freitag |
>   |----------------+--------------+-----------+------------+---------|
>   | Englisch 8dM   | Englisch 9dM | Mathe 9dM |            |         |
>   | Mathematik 9dM | Englisch 9dM |           |            |         |
>   |                | Englisch 9eM | Mathe 9eM |            |         |
>   | AWT 9dM        |              |           |            |         |
>   | AWT 9dM        | Sport 9abc   |           |            |         |
>   |                | Sport 9abc   |           |            |         |
>   |----------------+--------------+-----------+------------+---------|
>
> * Wochenplan
>
> ** Montag
> *** Englisch 8dM [3/3]
>     /Es fehlen: Hans, Sepp, Franzi/
> - [X] Wiederholung present progressive
> - [X] Buch, S. 17
> - [X] HA: Buch, S. 17/1-5
> Mit Schülern vereinbart, dass Nr. 5 wegfallen kann.
>
> *** Mathematik 9dM [0/3]
> - [ ] Pythagoras wiederholen
> - [ ] Üben, S. 12/4-5
> - [ ] HA, S. 13/6a,b
>
> ** Dienstag
> ** Mittwoch
> ** Donnerstag
> ** Freitag
>
> However nothing seems to get executed when I export to LaTeX PDF.
>
> —
> Tobi

--
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] 3+ messages in thread

end of thread, other threads:[~2015-09-06 16:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-03 15:06 shell scripts in yasnippet? Tobias Frischholz
2015-09-04 13:20 ` John Kitchin
     [not found]   ` <26CFED0F-553B-4E68-9006-E2A705FE8903@friolz.com>
     [not found]     ` <m28u8m2au0.fsf@johns-air.wv.cc.cmu.edu>
     [not found]       ` <930BB4CD-C957-45BA-8396-B79FAA8B7727@friolz.com>
     [not found]         ` <CAJ51ETrgz44VpAVTBFsbUo4yrGrUQEn5CxjRXdyu9dknJBNETQ@mail.gmail.com>
     [not found]           ` <7522ECBF-F9AB-4262-B6AF-58536E6C4D45@friolz.com>
2015-09-06 16:34             ` 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).