Eric Abrahamsen writes: [...] > Here's another stab at it. Is "example" the only block that should be > verbatim? Will using `newline-and-indent' instead of inserting literal > newlines solve the indentation problem? > > > (defun org-insert-structure-template (type) > "Insert a block structure of the type #+BEGIN_FOO/#+END_FOO. > Prompts for a block type, and inserts the block. With an active > region, wrap the region in the block. With no active region, wrap the > current element." > (interactive "sBlock type: ") > (unless (use-region-p) > (org-mark-element)) > (let ((s (copy-marker (min (point) (mark)))) > (e (copy-marker (max (point) (mark))))) > (when (string-equal (downcase type) "example") > (org-escape-code-in-region s e)) > (goto-char s) > (beginning-of-line) > (insert (format "#+BEGIN_%s" type)) > (newline-and-indent) > (goto-char e) > (unless (bolp) > (end-of-line) > (newline-and-indent)) > (insert (format "#+END_%s" type)) > (newline-and-indent) > (set-marker s nil) > (set-marker e nil))) And here's an actual patch, with docs.