I use Emacs for writing, not for coding. Is there an easy way, in Emacs or Emacs org-mode, to define a text string as a variable so that I can use it repeatedly?

Example: I created a template invoice.org. It would be cool to put a variable like $CLIENTNAME in the headers, in the table, on the cover page, in #+TITLE:, and in the thank you, use that as a template, and then quickly generate a new PDF for each new client by just adding a line at the beginning like let $CLIENTNAME="Jane Doe".

How do I do this?


You want to use Macros (see the manual)

You can define them by using

#+MACRO: clientname Jane Doe

and then call them by inserting {{{clientname}}} in the document where desired.

On export {{{clientname}}} will expand to Jane Doe.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.