Nicolas Goaziou writes: > Hello, > > Eric Abrahamsen writes: > >> Kaushal Modi writes: > >>> I just tried it out, and it works great! >>> >>> I have a comment about >>> >>> (when (string-equal (downcase type) "example") >>> (org-escape-code-in-region s e)) >>> >>> I have never needed to escape org in example, blocks, but I *have* needed to do that in org src blocks. >>> >>> Should type string be also matched with "src org"? >>> >>> Actually should the type string be matched only with "src org"? Because I see the Org example blocks as
  blocks in HTML with no syntax highlighting.. so
>>> those can contain code from any language.
>>>
>>> Also as this is part of org and emacs, org-structure-predefined-blocks deserves "SRC org" and "SRC emacs-lisp" too? :)
>>
>> The template really only inserts the block type, not anything specific
>> like the source language or export backend. I think prompting for
>> "second-level" information like that might be a little overkill.
>>
>> As for what should be escaped and what shouldn't, I defer to Nicolas,
>> let's see what he says.
>
> "src" (not only with "org" language), "example" and "export", i.e.,
> verbatim, blocks need to be escaped.
>
> You should probably use something like
>
>   (when (string-prefix-p (regexp-opt '("example" "export" "src")) type t)
>    ...)

string-prefix-p doesn't appear to work with regular expressions, so I
used string-match-p.