8

Related to this question: How to define template for org-mode HTML export?

I'd like to customize the template inserted by hitting C-c C-e t such that I get a few customizations and even some help notes in some comments on what to put.

Maybe it would be better to use some other Emacs way to insert a text snippet? Or to use org-mode template expansion?

2 Answers 2

4

Short Answer: Does not look to be easily accomplished to modify the structure dramatically. There are some export-options suggested like org-export-plist-vars but I personally have not played with them.

Digging for the Answer: When you call C-c C-e t, you are invoking the org-mode function org-insert-export-options-template. I did a quick help on the function (C-h f) and didn't see any helping text or options to pass to it, so I had to look at the source of the function (M-x find-function ENTER org-insert-export-options-template ENTER>).

Reading through the org-insert-export-options-template function, I see that it is acquiring the text to insert via org-get-current-options. No help on configuring it's behavior in it's description, so off to view it's source as well. There you will see the familiar full bodied paragraph of template information that is inserted into the text when you call org-insert-export-options-template. The values populate are from various other org variables, buffer name, etc.

Recommendation: What I personally have done is spent some time deciding which options I'd like and copied those from other org files when I start a new one. I have also thought about using AutoInsertMode to auto-populate a new org file for me but have put it off.

0

In addition to the "insert snippet" option, you may also be interested in #+SETUPFILE: /path/to/template.org . This is useful if you wish to have pre-defined settings set for export. You can create as many as you need. I combine this with yasnippet todo the following:

# -*- mode: snippet; require-final-newline: nil -*-
# name: blogtemplate
# key: <bl
# --
#+SETUPFILE: ~/.emacs.d/org-templates/level-$1.org
#+DATE: $2
#+KEYWORDS: $3 

#+BEGIN_HTML
<h1 class="title">$0</h1>
#+END_HTML

The $1, $2 and so on define tabs stops so you can fill it out like a webform.

EDIT:

Details on writing yasnippets and tab stops in particular can be found here: https://joaotavora.github.io/yasnippet/snippet-development.html

But essentially, after you insert a snippet it will place you at $1 then pressing tab will place you at $2 and so on. That way you can quickly fill in what you need to.

1
  • Please clarify the $1, $2 parts. Any doc ref? Thanks!! Jan 7, 2015 at 19:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .