From: John Kitchin <jkitchin@andrew.cmu.edu>
To: Josh <jnfo-d@grauman.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: Macro that calls external program
Date: Mon, 11 Mar 2019 16:48:10 -0400 [thread overview]
Message-ID: <m2va0p16k5.fsf@andrew.cmu.edu> (raw)
In-Reply-To: <alpine.LRH.2.21.1903110356300.5443@colo.shuman.org>
See the variables org-export-before-processing-hook and
org-export-before-parsing-hook.
You can put something like this in a noexport tagged build heading in
your document. Here I run head on the org-file to just get the first
three lines. you can replace that with your external filter.:
#+BEGIN_SRC emacs-lisp
(let ((org-export-before-parsing-hook '((lambda (backend)
"lightly tested"
(let ((new-doc (shell-command-to-string (format "head -n 3 \"%s\"" (buffer-file-name)))))
(erase-buffer)
(insert new-doc))))))
(org-open-file (org-html-export-to-html)))
#+END_SRC
Josh <jnfo-d@grauman.com> writes:
> Thanks! This is very helpful.
>
> I have a related question. How can I run an external program right before Export
> that takes as input the current buffer and prints out to stdout an updated
> version of the org file that then is exported? Basically I want to pipe the org
> file through a filter that is an external program before it is exported.
>
> Thanks in advance!
>
> Josh
>
>> On Sunday, 10 Mar 2019 at 15:37, Josh wrote:
>>> Hi,
>>>
>>> I am new to emacs and orgmode. I spent the last couple days reading most
>>> of the docs before diving in, but I didn't see anywhere how I could have a
>>> macro that instead of replacing the macro with lisp code, calls an
>>> external program instead.
>>>
>>> Something like:
>>>
>>> #+MACRO: func call /home/josh/mybinary $1
>>
>> You could maybe do something along the lines of
>>
>> #+macro: func (eval (shell-command (concat "/home/josh/mybinary " "$1")))
>>
>> (untested).
>>
>> --
>> Eric S Fraga via Emacs 27.0.50, Org release_9.2.2-249-g51444a
>>
--
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
next prev parent reply other threads:[~2019-03-11 20:48 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-10 22:37 Macro that calls external program Josh
2019-03-11 7:46 ` Eric S Fraga
2019-03-11 11:19 ` Josh
2019-03-11 19:03 ` Eric Abrahamsen
2019-03-11 20:48 ` John Kitchin [this message]
2019-03-11 19:24 ` Ken Mankoff
2019-03-11 13:28 ` Josh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m2va0p16k5.fsf@andrew.cmu.edu \
--to=jkitchin@andrew.cmu.edu \
--cc=emacs-orgmode@gnu.org \
--cc=jnfo-d@grauman.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.