I am playing with an extension to the PlainTasks plugin.
I often grab code snippets and put them into my work log / todo lists either from the web or from other sources.
I want to make a tag like:
#+BEGIN_SRC python
# PYTHON CODE HERE
#+END_SRC
And have it be recognized as python code.
I can do something like this:
sourceblock:
- match: ‘#+BEGIN_SRC[ \t]+python’
push:
- include: ‘scope:source.python’
- meta_scope: todo.sourceblock
- match: ‘#+END_SRC’
pop: true
But then I will need to make a block per language I wish to support.
I thought I could also do something with captures but I can’t figure out a good way to make that work.
What I really want is something dynamic like:
sourceblock:
- match: ‘#+BEGIN_SRC[ \t]+(python|ruby|js)’
push:
- include: ‘scope:source.{{capture.1}}’
- meta_scope: todo.sourceblock
- match: ‘#+END_SRC’
pop: true
Where the included scope is determined by the capture, better yet just [a-z]+ allowing any defined source scope to be used as a moniker.
I’ve dug through the docs but I am not seeing anything that would take me beyond what I know right now.
Are there any syntax wizards out there with better ideas of how this could be handled?